Quantcast
Channel: Blogs from Jim McKeeth - Embarcadero Community
Viewing all 252 articles
Browse latest View live

3D Credits Scroll with Delphi

$
0
0

A little fun with Delphi for today’s Star Wars day!

3D Credits Scroll with Delphi - May The Fourth

This is a pretty simple 3D form with a 3D layout at an angle, and then a 2D layout with text and images is animated up the 3D layout. The only code is populating the labels as the animation kicks off automatically.

3D Scroll - MayTheFourth-StructureDownload the code and run the full credit scroll, or change the message to share with your friends. It is FireMonkey, and while I only tested it on Windows, it should work on Android, iOS, macOS, and even Linux if you are running FMX Linux.

CreditScroll3D Source for 10.2.3 Delphi

May the Fourth be with You!


Read more

SHA Hash with C++Builder and Delphi

$
0
0

SHA Family Hashes Icon by Uwe Martens - Used under CC BY-SA 4.0I've always been fascinated by encryption & compression, but my favorite is probably the cryptographic hash function. A hash function is a one-way algorithm that takes an input of any size and always produces the same size output. It is one-way in that there is information loss -- you can't easily go from the output to the input again. The cryptographic hash is a more secure version of the hash function. It is most often used in signing to validate that data hasn't been modified. 

Per Wikipedia, the ideal cryptographic hash function has five main properties:

  • it is deterministic so the same message always results in the same hash
  • it is quick to compute the hash value for any given message
  • it is infeasible to generate a message from its hash value except by trying all possible messages
  • a small change to a message should change the hash value so extensively that the new hash value appears uncorrelated with the old hash value
  • it is infeasible to find two different messages with the same hash value

SHA Family Icon by Uwe Martens - Used under CC BY-SA 4.0

A cryptographic hash function (specifically SHA-1) at work. A small change in the input (in the word

The Message Digest family of cryptographic hashes used to be the main players in the area, but they were found to be insecure. Now SHA family rules as the main workhorse of modern cryptography. 

The basis of hash support first appeared in the RTL around the 2009 release but in XE8 (2015) we got the System.Hash unit, which brought the MD5, SHA-1, and Bob Jenkins hashes. Then in 10.0 Seattle (2015) it was expanded with SHA-2 support. Most recently in 10.2 Tokyo (2017) the hash functions were expanded to accept either a string or stream in addition to the original bytes input. 

The SHA Family includes SHA-0, SHA-1, SHA-2, & SHA-3 family of hashes. SHA-0 is obsolete, and SHA-3 is an improvement on SHA-2. In practice I see most hashes using either SHA-1 or SHA-2. SHA-1 always produces a 160-bit (20-byte) hash (digest), while SHA-2 includes 224, 256, 384, and 512-bit outputs, making it both more secure and more flexible. SHA 256 & 512 represent 32 and 64-bit word size hash algorithms. The 224, 256, & 384 size digests are truncated versions of the 256 & 512 algorithms. 

So how do you use it in C++Builder and Delphi? I'm glad you asked. Once you have included the System.Hash unit then you can use the methods of the THashSHA2 class to create the digest. I'll show you how to use GetHashString, but know there are other variations you can use too. The GetHashString takes either a string or a stream and returns a hexadecimal string of the hash. 

In C++Builder your code would look like:

Edit512->Text = THashSHA2::GetHashString(
    EditMessage->Text, 
    THashSHA2::TSHA2Version::SHA512);

 and in Delphi your code would look like:

Edit512.Text := THashSHA2.GetHashString(
    EditMessage.Text, 
    THashSHA2.TSHA2Version.SHA512).ToUpper;

I made a little sample app that generates all the different hashes from the text you provide. It is a FireMonkey app, so will work on all the platforms, but the hash code will work in any type of app. There are both C++ and Delphi versions included.

SHA Hash Sample
[ShaHashSample.7z - Delphi & C++Builder 10.2.3 Tokyo - 401 KB ]


Read more

Connect to All the Data with FireDAC Enterprise Connectors

$
0
0

Move, integrate, and analyze data with ease utilizing FireDAC Enterprise Connectors, powered by CData. These components allow you to integrate 80+ Enterprise applications, simplifying connectivity into a standard model using SQL. Everything from Salesforce & eBay to Google Sheets & Twilio. In this webinar learn how to leverage your SQL skills and the powerful FireDAC framework to access all the data with Enterprise Connectors

[YouTube Replay]


 

 

More downloads to come!


Read more

Use the Source!

$
0
0

One of the great things about Delphi is not only is it written in Delphi (mostly), but it ships with the VCL, RTL, & FMX source code. You can use this source code in lots of different ways, which I’ll cover in a bit, but sometimes it is a matter of finding the source file with the code you want. There are over 2,234 Delphi source files in the source folder, so it can take a while to find the right file if you don’t know where to look. Not to mention the 1,711 C files, and a few thousand other assorted files.

Source Folder Files

I used to use various GREP and full text searching tools to find the code I was looking for, but then I realized Windows 10 (and earlier versions) has a search function built into it, but you need to make a few configuration changes to use it effectively. So I thought I would outline those for you.

Your source folder is usually located in
C:\Program Files (x86)\Embarcadero\Studio\19.0
but it might be different depending on your installation. I usually Pin it to Quick Access, which makes it easy to access since I find I’m there a lot.

Source Folder

Windows Search and Indexing Options

The next thing to do is configure your Indexing Options. This is what makes it quick to search for files you need. You can find Indexing Options in Control Panel, or just runcontrol.exe srchadmin.dll.

control.exe srchadmin.dll

There are two steps to get the most out of Windows search for your source code. The first is you need to activate Windows search for the file extensions you want, and the second it to tell it to index your folders.

Indexing Options

To add PAS files to indexing click Advanced and go to File Types. You can just type PAS in the list of file types and it will find it for you. You don’t need to add a new extension. PAS files are already listed, but just not indexed by default. Just put a check next to it, and change the “How should this file be indexed?” to “Index Properties and File Contents” that will index all the text contents of the file

Indexing File Types

By default all your user folders are indexed, but Source is in your Program Files folder, so you need to explicitly add it. From the main Indexing Options window click Modify and from there you can add any folder you want to search.

Indexed Locations - Source

It takes a while a while to build and update the index after this change. You just gave it 2,000 more files to index. It has to read all the text out of them, which takes a while. Once it is done then just go to your source folder and use the search box to quickly find the code you are looking for.

Search Results

Everything Search

Everything Software IconAnother great tool to use, to search by file name is the Everything desktop search engine by Voidtools. The thing I love about using Everything is it searches all the file names on your system quickly. The difference between it and Windows Search is Everything only searches the file names, but it searches all the file names.

Everything Search

I find I usually remember the name of a file, but not exactly where I left it. This makes Everything indispensable for me.

Using the Source

So how useful is it that Delphi, RAD Studio and C++Builder includes all this source code? What all can you do with it?

  • Finding that function – You know how I said I can remember the name of a file, but not where I put it? I do the same things with classes and functions. I can remember the name of the method or class, but not which unit it is in. Being able to search all of the source instantaneously to find the source file you need is a huge help.
  • Learning – Just reading source isn’t the best way to learn to program, but having access to the source code is a great way to gain a deeper understanding.
  • Debugging – Sometimes your program doesn’t behave the way you expect it to. When all you have is a blackbox then you are unable to figure out what is happening behind the scenes. When you have the source code you can not only see how that method is implemented, but also debug into the source code, using all the great debugger features.
  • Adding New Features – Maybe there is a new API that was just released, or you need to access an obscure API or 3rd party feature. Since you have access to all the source you can see how other similar APIs are accessed and use that as a roadmap.
  • Fixing or Changing Functionality – One man’s bug is another man’s feature. Sometimes there are bugs you need to fix in the shipping source code, other times you just want to change the way things work. For small changes I just copy the source file out into my project directory. Then my code will use my modifications instead of the original implementation. While you can’t redistribute changed source code, you can compile the code into your program. If you do need to share your changes or fixes you can share a change-set that only contains your changes.

What else do you use the source for?


Read more

Celebrating Five Amazing Years with Embarcadero

$
0
0

This month I am celebrating my five-year anniversary with Embarcadero Technologies. It’s been an amazing adventure and I am looking forward to more. I saw a graphic similar to the following today and it reminded me how great it is to be doing what I am doing (plus I love Venn diagrams).

Loving what I do at Embarcadero

I truly do love what I am doing, and I love the people I work with. Everyone I work with inside Embarcadero is amazing, plus I get to work closely with the MVPs, Tech Partners, and all the amazing members of the community. Most of what I do is stuff I used to do as an MVP before coming to Embarcadero. It was essentially my hobby. I would even take vacation time and spend my own money to travel to speak at conferences.

I frequently talk to developers who express their appreciation of the work I do as a developer advocate – I love training and sharing what I know. Not to mention all the gratitude I hear from developers for the productivity they get from Embarcadero’s tools. The reality is Embarcadero’s tools help developers make the world a better place.

RAD Studio speaks AndroidI started right before the release of RAD Studio XE5 in 2013, which added support for Android. iOS and macOS were great, but once RAD Studio had Android it was a gamechanger. So many people just added Android as a target to their iOS apps, made a few layout tweaks, and they had a native Android app!

Since then we’ve added so many great features, plus Linux and the new Free Community Edition!

When it comes to monetary pay I’m really looking for a way to take care of my family. Beyond that, my job pays a lot in satisfaction because I believe in what I do. It certainly helps that Software Developer was rated the #1 job this year. I’m not directly a developer, but software development is a big part of my job, and I work with a lot of amazing developers.

 

It’s been an amazing five years. Despite a few bumps I am so happy for where we are going, what I do here, and where Delphi, RAD Studio, and Embarcadero are headed. It is always rough when you go through a merger, but the new Community Edition is a direct result of the changes in philosophy that Idera brought. And now I get to work with Sencha, RanorexGurock, and others that make up the Idera family.

I’m looking forward to many more years doing what I love here with Embarcadero!

ILoveDelphi


Read more

API Limits with #FDEC

$
0
0

API Limits with FireDAC Enterprise ConnectorsThe FireDAC Enterprise Connectors (#FDEC) by CData and Embarcadero make it really easy to work with various APIs just like you would any SQL database. For example if you want to publish the results of a query to a Google Sheet (which I find incredibly useful) then it is just a few FireDAC components and you are off to the races. You might run into an API limit though.

What is an API limit? Most rest services have a limit to how often a client can call a specific API within a certain amount of time. Google calls this their usage limit:

This version of the Google Sheets API has a limit of 500 requests per 100 seconds per project, and 100 requests per 100 seconds per user. Limits for reads and writes are tracked separately. There is no daily usage limit.

That may seem like a lot, but I found I was running into that limit pretty quick once I moved my project into production. Luckily FireDAC and the FireDAC Enterprise Connectors have a simple workaround: Batch Processing.

Using the Array DML features of FireDAC you can batch multiple DML (Data Manipulation Language) operations into a single API call. The FDEC Google Sheets documentation from CData doesn’t cover Array DML, but the component supports this (they are updating the documentation). The Elasticsearch documentation does cover Batch Processing with an example, and I’ve used this with Sheets and it works great!

Bulk Insert

The following example prepares a single batch that inserts records in bulk.

FDConnection1.ResourceOptions.ServerOutput := True; FDQuery1.SQL.Text := 'insert into Account values (:Name, :Id )'; FDQuery1.Params.ArraySize := 100; FDQuery1.Params[0].AsStrings[0]:= 'MyName1'; FDQuery1.Params[1].AsStrings[0]:= 'MyId1'; //next statement FDQuery1.Params[0].AsStrings[1]:= 'MyName2'; FDQuery1.Params[1].AsStrings[1]:= 'MyId2'; ... FDQuery1.Execute(FDQuery1.Params.ArraySize); ShowMessage(IntToStr(FDQuery1.RowsAffected));

To retrieve the Ids of the new records, query the LastResultInfo#TEMP table:

sName := FDQuery1.Open('SELECT * FROM [LastResultInfo#TEMP]');

Bulk Update

The following example prepares a single batch that inserts records in bulk.

FDQuery1.SQL.Text := 'update Account set Name = :Name WHERE Id = :Id'; FDQuery1.Params.ArraySize := 100; FDQuery1.Params[0].AsStrings[0]:= 'Floppy Disks'; FDQuery1.Params[1].AsStrings[0]:= 'Id1'; //next statement FDQuery1.Params[0].AsStrings[1]:= 'Jon Doe'; FDQuery1.Params[1].AsStrings[1]:= 'Id2'; ... FDQuery1.Execute(FDQuery.Params.ArraySize); ShowMessage(IntToStr(FDQuery1.RowsAffected));

Bulk Delete

The following example prepares a single batch that inserts records in bulk:

FDQuery1.SQL.Text := 'delete Account where Id = :Id'; FDQuery1.Params.ArraySize := 100; FDQuery1.Params[0].AsStrings[0]:= 'MyId1'; //next statement FDQuery1.Params[0].AsStrings[1]:= 'MyId2'; ... FDQuery1.Execute(FDQuery.Params.ArraySize); ShowMessage(IntToStr(FDQuery1.RowsAffected));

If you want to learn more about Array DML check out these videos:

Array DML Skill Sprint with Pawel Glowacki

FireDAC in Depth with Cary Jensen

Also check out Cary Jensen’s book on the topic of FireDAC in Depth.


Read more

Make Your Apps Scalable and Web-Enabled

$
0
0

This blog post accompanies the webinar Make Your Apps Scalable and Web-Enabled - Leverage your Business Logic with a Fast Flexible Multi-Tier Architecture - Using RAD Server and REST Services.

Create high performance, scalable applications by adopting a multi-tier architecture. By separating the UI/presentation layer, the server and the data layer, your apps will scale more easily with changing business needs and accommodate larger numbers of users. Multi-tier architecture also allows dev team members to focus on their strengths and add new services through a loosely coupled architecture which keeps the impact of changes small. This webinar demonstrates how easy it is to create a services-based app using REST/JSON, database integration, and RAD Server. We will look at the use case of the RAD Server Field Services Application Template and also provide examples of web-enabling your application with an Ext JS front-end.

SlidesYouTube Replay  

[GoogleDocsButton url=https://docs.google.com/presentation/d/1CFJYqrlhMYgKdCpiYH2lMP1XL11RhiVFCNhjtYhK-6Q/edit?usp=sharing][YoutubeButton url='https://youtu.be/q2nNMEwVyNc']

Agenda

  1. The Monolithic Problem
  2. Architecture Types
  3. Why Does Scalability Matter?
  4. Microservices vs. Monolithic Services
  5. Making Your Business Logic Scalable
  6. Field Services RAD Server Template
  7. Using Ext JS for Web-Enablement
  8. Different Editions of RAD Studio

The Monolithic Problem

We all start with the monolith. This is the app that is easy to develop, just drop our data access controls on the form, mixing the business logic with the data access and the user interface. The monolith gets us to market quickly, but over time is harder to maintain.

  1. Does Everything in one tightly coupled module:
        UI, Logic, Data, etc.
  2. Quick when Apps are Small
  3. Doesn't Scale Well. Can't easily adjust as features, new users, and new platforms are added
  4. Doesn’t scale and typically only available via one platform (usually desktop), and not web enabled
  5. Difficult to Maintain as App Grows

Software Architectural Coupling

When our software modules are coupled they are hard to maintain. Wikipedia has an article on coupling, and Nick Hodges covers it in his books.

  1. Coupling is the degree of interdependence between software modules
  2. Disadvantages of tightly coupled systems:
    1. A change in one module forces a ripple effect of changes in other modules
    2. Adding and removing modules requires more effort due to increased dependencies
    3. Module are harder to reuse and test because inter-dependence
  3. Loose coupling is characterized by well defined & limited interactions

Why Scalability Matters?

As the app does more and gets more workload, the need to scale goes up. Horizontal scaling allows the software to handle more workload without the cost per unit of work going up.

  1. More important with growth
  2. Support more users & workload 
  3. Reduce cost per users & work unit
  4. Allows for horizontal scale

Microservices vs. Monolithic Services

Going straight for Microservices usually isn't a good plan.

  1. Martin Fowler suggests Monolith First
  2. Microservices require additional overhead
  3. Introduce Microservices to solve complexity issues
  4. Optimizing early may fix wrong problems (YAGNI You Aren’t Gonna Need It)
  5. Shortens time to market, allows for scale over time

Migrating your Business Logic with RAD Server

RAD Server makes it easy to make your monolithic app scalable.

  1. RAD Server’s EMS Packages are built with either Data Modules or Units.
  2. Refactor your code into loosely coupled Data Modules
  3. Move Data Modules to RAD Server
  4. Use remote calls to access endpoints
  5. Be aware of latency issues
  6. See Nick Hodges’ RAD Server Story

Remote Data Call Latency Tips

  1. When moving from LAN to WAN the response time of each request increases
  2. Bundle multiple requests into one request
  3. Utilize local cache instead of repeating the same call
  4. Parallel requests can be faster than a series of requests
  5. Proper architecture can prevent latency issues

Field Services RAD Server Template

There are a few different Industry Templates available in GetIt. They are a great resource to learn more about RAD Server and scalable app development.

  1. Available via GetIt Package Manager in the IDE
  2. Includes full source and graphic resources
  3. Written in Delphi (the technology all works with C++Builder too)
  4. Includes Field Service App, Admin, Server (uses RAD Server), & Setup
  5. Designed for mobile and desktop use
  6. Includes detailed documentation and video instructions
  7. Great resource to learn about REST services & RAD Server
  8. Use this template as a base to build your own solutions

Why Web Enable?

You are a big fan of native app development. What does the web give you? Adding a web interface is one way to take advantage of your new scalable architecture. 

  1. Minimal friction for new users to connect
  2. Compatible across more devices and platforms
  3. Trade-off some performance and features from native apps
  4. No installation required - access from shared computers
  5. On-ramp to move users to native experience

Sencha Ext JS

The go to choice for web front ends is Sencha's Ext JS.

  1. Ext JS helps you build data-intensive web apps
  2. Uses JavaScript, HTML, & CSS
  3. Includes 115+ UI components including calendar, grids, charts, pivot grid, and more
  4. Two flavors:
    • Classic: Focused on Desktop and greater compatibility
    • Modern: Focused on modern standards & Mobile (FKA Sencha Touch)
    • Also Universal Applications for both Desktop and Mobile (using both Modern and Classic)
  5. More information
  6. Take a look at Kitto2 and UNIGui as additional resources to integrate Ext JS
  7. Web Development with ExtJS for Delphi Developers

RAD Server + Ext JS

  • Tokyo 10.2.2 included a new FireDAC TFDBatchMoveJSONWriter component to generate JSON for a Sencha Ext JS client. 
  • Tokyo 10.2.3 expanded RAD Server to host static HTML, JS, CSS files (and any other files)

ColumbusEgg4Delphi

Useful framework in refactoring your Monolithic App to multi-tier to make it more scalable.

  1. A simple to use Delphi framework to correctly write business logic in Delphi "RAD style" applications
  2. Provides a single point for the Business Logic code
  3. Forms and data modules are free of Business Logic code
  4. You can do unit tests; Business Logic can be unit tested using in-memory datasets.
  5. You can still use the RAD approach to design you forms
  6. If your data comes from an application server, you can fill in-memory datasets (or virtual dataset) and still use the same Business Logic.
  7. Free and Open Source

RAD Server Resources

  1. RAD Servier Video Playlist: https://embt.co/RADServerVideos
    • Migrating to RAD Server Webinar Replay
    • Deep Dive - Creating a Department Store Retail Solution
    • RAD Server Multi-Tenancy
    • Building a Microservices Architecture with RAD Server
  2. Build Flexible and Robust Apps with a Multi-Tier Architecture
  3. RAD Server & EMS DocWiki
  4. Case Study Foresiight & Migrating to RAD Server https://embt.co/ForesiightRADServer (YouTube)

RAD Server Field Services Template

  1. Available from GetIt Package Manager in the IDE
  2. Includes detailed documentation
  3. Overview post: https://embt.co/FieldServicesOverview
  4. Deep Dive Article: https://embt.co/FieldServicesDeepDive
  5. YouTube Videos: https://embt.co/FieldServicesVideos
    • Setup & Configuration
    • Development Server
    • Admin Application
    • Client Application
    • UI Tips and Tricks

 


Read more

Deep Delphi Discussions

$
0
0

Deep Delphi Discussions

Delphi

Everyone knows Delphi is the best Rapid Application Development tool. Delphi, C++Builder, and RAD Studio set the standard that everyone else is still trying to follow. Nothing will get you to market quicker with a great native experience for your users.

Delphi is also a top choice for large, long lived, and complex applications. Many of these are line of business applications that automate the internal operations of so many companies. I’ve worked on or seen a few of these large scale line of business applications over the years, and I’m sure many of you have too. Some of them are still maintained with the original version of Delphi they were written in, while many of them are moving forward with new releases adding new features and platforms.

Embarcadero Cool App ContestWe’ve been running the Cool App Contest as a way to highlight some of the cool and exciting apps that were developed with Delphi, C++Builder, and RAD Studio. Most of the entries and winners were consumer focused, like EarMaster for iPad, 1Password for Windows, Expresii, or 3D Train Studio. There were some in the Line of Business category too, like BeePOS, Where On the Map, FrameForge Previz Studio, and MalyKangurek POS. We even had some developer focused tools like BEAM, RAD & Installer, and Visuino.

But we really didn’t do a good job of highlighting large scale, internal, line of business applications. That is where this new blog series comes in. I’m going to interview architects and lead developers on some of their projects that are built and maintained by teams of developers and are core to different businesses. We’ll talk about some of the challenges they faced, why they use Delphi, and some of the more elegant solutions they’ve created.

Based on my experience some of the reasons Delphi is the ideal choice for these sorts of applications include:

  • Database Access was a key feature of Delphi from the very first release. The BDE was ahead of its time and FireDAC takes those core concepts and brings them forward to a modern, lightweight framework. Now with the REST Client Components and the Enterprise Connectors you can access data from anywhere like Salesforce, CouchBase, Google Sheets, etc.

  • A Commitment to Backwards Compatibility is something else that sets Delphi apart from so many other development tools out there. Many developers I talk to who are using other languages and tools spend a good portion of their time rewriting their programs to work with the latest version of the tools. With Delphi the changes necessary to upgrade to the latest version are minimal if any. This is because Embarcadero respects the investment you have in your code.

  • Rapid Application Development is so important in business. It gets you to market quicker, and helps your line of business applications evolve and change as your business does. When I worked at Micron Computer my co-worker was a Visual C++ developer, and he came to me and said I was making him look bad by turning around all the change requests I got with Delphi so fast. After that whenever there was a change request my stock answer was “That’ll take at least a week, but only if we’re in spacedock!” He eventually switched to Delphi as well.

Stay tuned to this series as we discuss what makes Delphi ideal for so many of these key line of business applications. I’m lining up Delphi Experts to talk with now, but am also open to your suggestions.

Why I Love Delphi



 
 
 
 
Delphi's DNA

Read more

Pictures from the 10.3 Rio Preview in Brazil

$
0
0

We just shared a preview of 10.3 Rio in Brazil on Tuesday, the 23 of October here at the Embarcadero Conference in São Paulo. Over 750 developers were in attendance, and the speakers included many Embarcadero and Sencha MVPs. I snapped a few pictures from the event that I thought I would share.

With a name like 10.3 Rio is great we were able to do a preview event in Brazil as part of their annual developer conference. I’ve been in attendance every year since I started at Embarcadero, and it is something I always look forward to. Most years the attendance is around 400 to 500. I’m sure the news about 10.3 Rio and the recent Community Edition helped contribute to the high attendance numbers this year. Either way it is great to see the Delphi developer community continue to grow.

I hope to get some more of the pictures I was in with the MVPs and other speakers, as well as some other general conference pictures. I’ll share those later when I get them.

Multiple sessions in the same room

All the sessions were the same room with the attendees using headsets to switch between the audio tracks. If you didn’t have a headset the room was pretty quiet.

David Millington kicking off the Keynote

David Millington kicking off the Keynote where we previewed some 10.3 Rio features

The Exhibit Hall

The Exhibit Hall with some great partners

This is me in front of the welcome sign

This is me in front of the welcome sign

David Millington in front of a sign that says Embarcadero.com/br with a cityscape and reg icons for Delphi and different mobile and desktop platforms

David Millington in front of the welcome sign

RGB Rio Glasses

I’m wearing the Rio RGB Glasses with the Delphi powered controller on my Android phone

Kelver and Fernando with David and I

Kelver and Fernando with David and I

David Millington in front of a screen showing new Delphi language features

David Millington showing new Delphi language features

Stay tuned for more news about 10.3 Rio and other pictures from the event!


Read more

Arduino & Delphi Cosplay

$
0
0
Me with a Spartan Boba Fett, but I thought he was more of a Delphi Dude ?(FanX Salt Lake City - 2018)Me with a Spartan Boba Fett. I thought he was more of a Delphi Dude (FanX Salt Lake City – 2018)

Cosplay (aka costume-play) takes the fun and imagination of childhood dress-up to extreme levels only justifiable by an adult! Not only is it expensive, and needs a large time commitment, but it is rarely comfortable.

Comic conventions are the usual place to find cosplay, but Halloween is also a good excuse for some cosplay fun. I’m a huge fan of creative cosplay and love getting my picture with cosplayers.

In writing this post I realized I am frequently attaching LEDs to my face.

The V character from Cyberpunk 2077. Cosplayer Maul. photo by eosAndy.The V character from Cyberpunk 2077. Cosplayer Maul. photo by eosAndy. His cosplay is much better than mine.

This year I am putting together my Ultimate Cyberpunk cosplay. The first part is a jacket based on the main character from the game Cyberpunk 2077 by CD Projekt RED. Neuromancer, by William Gibson, inspired the Cyberpunk 2020 RPG by Mike Pondsmith. They both inspired this unreleased video game Cyberpunk 2077.

I’m a big fan of both the book and the original RPG and am looking forward to the video game. I combined elements from all three sources for my cosplay. The character V is more of a Street Samurai / Solo, while I wanted to go for more of a Decker / Netrunner (a little Shadowrun RPG influence in there too).

At this point the secret is out, I’m a huge nerd. I love Role Playing Games, and Cyberpunk & Shadowrun are my favorite genres.

I didn’t have my RGB Shades in time for Salt Lake FanX, so I justed glued some extra LEDs (NeoPixel 4×4 grids) to my face. They represent cybernetic enhancements, which is why I left the wires exposed. I used an Arduino MEGA 2560 by ELEGOO as the controller. It also controlled the string of NeoPixel lights in the collar. I attached a Bluetooth keyboard to one wrist and an Android Pixel phone to the other. The phone was decorative for now.

  • Cyberpunk 2077 cosplay LEDs straight on. They changed colors, and weren't always red and green.Cyberpunk 2077 cosplay LEDs straight on. They changed colors, and weren’t always red and green.
  • Arduino MEGA 2560 behind my back controlled everything.Arduino MEGA 2560 behind my back controlled everything. 
  • Wrist mounted smartphone, light up collar, LEDs glued to my face, and el wire on my arm. Not pictured is the bluetooth keyboard on my other wrist.Wrist mounted smartphone, light up collar, LEDs glued to my face, and el wire on my arm. 

Later I got my RGB LED Shades which will become the key to my outfit for this Halloween. The RGB LED Shades use an Arduino Mini as the brains. I added an HC-06 Serial Bluetooth module to control the leds remotely.

  • Wearing the RGB LED ShadesWearing the RGB LED Shades
  • Attaching the HC-06 to the RGB LED ShadesAttaching the HC-06 to the RGB LED Shades
  • Arduino Mini pinout

After soldering the HC-06 onto my shades I can power them up and pair my Android phone with the HC-06 module. One note about my soldering is that if you look you will see that it is connected to two analog pins instead of digital pins. On most Arduinos the analog pins can double as digital pins (see the Pinout).

Android Bluetooth Pairing DialogAndroid Bluetooth Pairing Dialog

After that, a TBluetooth component is able to open a socket to the shades. Start the pairing with Bluetooth1.DiscoverDevices( 5000 ); In the DiscoveryEnd event handler the following code will open a socket to the HC-06 module (Thanks to Boian Mitov for the basis of this code):

var ADevice : TBluetoothDevice; AService : TBluetoothService; begin for ADevice in ADeviceList do begin // HC-06 is the name of the bluetooth device if ADevice.DeviceName = 'HC-06' then begin Bluetooth1.Pair( ADevice ); for AService in ADevice.LastServiceList do begin // FSocket is a TBluetoothSocket with larger scope FSocket := ADevice.CreateClientSocket( AService.UUID, False ); If Assigned( FSocket ) then begin FSocket.Connect; Break; end; end; Break; end; end; end;

Once the socket is open you can send characters with this code.

FSocket.SendData( TEncoding.UTF8.GetBytes( 'D' ));

It is so easy to work with Classic Serial Bluetooth in Delphi (or C++Builder) and the TBluetooth component. You even could send a whole string or other binary data. For this project a single character was all I needed to change modes on the shades. A single character is also easier to process on the Arduino side. (Technically Bluetooth Classic works on all platforms, but on iOS you need special approval from Apple on a per app basis.)

RGB Rio ShadesI’m wearing the Rio RGB Shades with the Delphi powered controller on my Android phone

I took my RGB Shades with me to Sao Paulo Brazil for the 10.3 Rio preview. Even though the Bluetooth worked before the conference, my phone couldn’t make the connection on stage. When I opened my phone’s Bluetooth connection window it was obvious that with 750+ people in attendance there were a few hundred Bluetooth devices broadcasting on the same wavelength.

David Millington kicking off the KeynoteDavid Millington kicking off the 10.3 Keynote

My next project involves Bluetooth LE with these RGB LED Steampunk Goggles.

Jim wearing LED Steampunk GogglesRGB LED Steampunk Goggles

I built them a year ago from an AdaFruit kit. Later I added a Bluetooth LE Module to make them controllable. Unfortunately, my soldering didn’t hold up and I need to rebuild them. This makes them both my previous and next cosplay project.

RGB LED Goggles, a horse mask, and a Los Angeles Kings hockey jerseyRGB LED Goggles, a horse mask, and a Los Angeles Kings hockey jersey (don’t ask)

I’m considering salvaging the NeoPixels and rebuilding them with an ESP32 microcontroller. The ESP32 is a little larger than the original Trinket microcontroller. This is because it has integrated Bluetooth LE, WiFi, and more pins. I’d also like to get some 50% mirrors to create an infinite LED tunnel effect (I’ll post pictures when I get them – it is really amazing).

I met Star Lord!I met Star Lord!

I’ve worked with the TBluetoothLE component before and it is even easier to work with than TBluetooth. So I’m really looking forward to this project.

On the Arduino side, you can use the Arduino IDE and flex your C programming skills. Or you can do like I usually do and use Visuino by Boian Mitov of Mitov Software. It provides a visual drag and drop interface for programming Arduino devices. It won the Embarcadero Cool App contest in April 2017 as Boian used Delphi to develop Visuino. Boian also recently added RGB LED Shades support to Visuino (along with unboxing and assembly videos.)

Visuino makes Arduino and LED RGB Shade development easy. It is an Embarcadero Cool App developed with Delphi!Visuino makes Arduino and LED RGB Shade development easy. It is an Embarcadero Cool App developed with Delphi!

I think Boian is a great guy who makes some great technology. Most of it has a free version and the commercial prices are very reasonable too. He is always very helpful as well.

Boian and Jim at the 2017 SoCal CodeCamp in Los AngelesBoian and Jim at the 2017 SoCal CodeCamp in Los Angeles

So what’s next (after the Bluetooth LE RGB Steampunk Goggles obviously)? I’m working on a design for an electronic physical polyhedral die with Bluetooth LE. So you roll a physical die of a single size and it can become any number of sides you need, all controlled via your phone. Did I mention how much of a nerd I am?

I love polyhedral diceI love polyhedral dice
Read more

Unexpected Benefit of Inline Variables: Conditional Blocks

$
0
0

Inline variables is one of the cool new feature coming in 10.3. The obvious huge use case is loop control variables, but I just discovered another great use case while reviewing some code. 

procedure DoesSomething; var var1, var2: Integer; begin // use var1 {$IFDEF Something} // use var1 & var2 {$ENDIF Something} end;

This is a pattern I see a lot, and it generates a hint on var2 being unused based on the current compiler directive status.

[dcc32 Hint] myUnit.pas(123): H2164 Variable 'var2' is declared but never used in 'DoesSomething'

Now there are a number of ways to deal with this with more compiler directives, which is what I’ve done in the past, but I never like adding more compiler directives. It makes the code way more complicated and harder to maintain. Now with Inline Variables I can simplify it, make it easier to maintain, and hande the hint! (all of which makes me so happy!)

procedure DoesSomething; var var1: Integer; begin // use var1 {$IFDEF Something} var var2: Integer; // use var1 and var2 {$ENDIF Something} end; Happy dance commencing in T-minus 10 seconds. 

What are some interesting ways you see inline variables benefiting you?


Read more

Android Z-Order, Native Controls, and 10.3 Rio

$
0
0
Android Z-Order and the Native Controls - Coming soon to a RAD Studio 10.3 Rio Near you!

Before 10.3 Rio when you used a a platform-native control, like TWebBrowser or TMediaPlayer, you were not able to put other controls on top of them. That stacking of controls is knowns as Z-Order. This was especially annoying when you were using them with the TMultiView (one of my favorite controls), because the drawer would slide out under instead of over the platform-native control. There were ways around it, but it was still frustrating.

Z-order represents stacking controlsZ-order represents stacking controls

In XE7 we introduced the ControlType property for iOS, and then in Seattle we brought it to Windows. Setting it to Platform switches a FireMonkey control to a platform-native control at runtime.

Now with the upcoming 10.3 Rio release the ControlType property is coming to Android, and it is brining two significant benefits: More Native Controls, and corrected Z-Ordering.

More Android Native Controls

The TWebBrowser, TMediaPlayer, TBannerAd, and TMapView are always platform native controls (they are rendered by the underlying Android OS and not by FireMonkey.) But in 10.3 Rio there are 4 new controls that are optionally platform native.

TSwitch component

That means when you set the ControlType property on these controls they will be rendered by the Android system instead of FireMonkey. You may notice some slight changes in the way they look and work because of this.

This is especially important in the TEdit as there are certain behaviors that are attached to the way users provide keyboard input and edit text. Here are some of the advantages your users will now have when you use a ControlType of Platform with your TEdit

  • Auto-Correction: Words are suggested while typing, these can be used by clicking on the space bar.
  • Define: You can select a word and click on Define to see the definition of such word in the dictionary.
  • “.” Shortcut: Double tapping the space bar inserts a period followed by a space.
  • Text Shortcuts:? That will expand into the word or phrase as you type.

Some of these behaviors vary from one Android platform to others (for example Samsung has a Clipboard feature). You can configure these settings on your Android devices in Settings > General > Keyboard.

Native Aware Android Z-Ordering

Additionally many controls now are able to handle a Z-Order over a platform native control. Now you can put control buttons over your TMediaPlayer for example. These controls have a ControlType property that when you set it to Platform it will maintain the Z-Order with other platform-native controls.

Setting their ControlType to Platform doesn’t make these platform-native, it just makes them work correctly with other platform native controls.

What’s Next?

10.3 Rio is in beta (which means these features are subject to change) and available to update subscription customers. Once it is released you can learn more about all of these features in the DocWiki. Also, if you are already using Platform native ControlType on iOS or Windows then those control will take advantage of the Android Platform native ControlType right away!


Read more
Viewing all 252 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>