Monthly Archives: July 2014

Xojo: THE Canvas reference book

Program the Canvas Control with Xojo Desktop

Program the Canvas Control with Xojo Desktop

I Wish I Knew How To… Program the Canvas Control with Xojo Desktop is the latest book of Eugene Dakin in his excellent I Wish I Knew How To… series.

If you ever wondered how stuff is done with the canvas control in Xojo, this is the book you need to have on your virtual shelf. In his well known swift (no pun intended) style, Eugene has written the reference manual for you. Alwaysbusy’s Corner did some humble contributions to the more advanced topics.

For the novice Xojo user, you quickly can get started and learn about the basics of graphics. Step by step you learn more and more when you move through the more advanced topics. This 400 page volume covers a lot of interesting chapters and includes a lot of useful examples with source code:

Topics included in the book:

Text
Chart Fundamentals
Objects
2D Objects
Graphics
Blurring
Cropping
Gaussian Blur
Building basic controls
Animation
and there are two games with step-by-step code explanations to help you build your own.

So head over to Eugene’s Personal Website and get your copy. Also check out his other books in the series on topics like SQLite, XML, PostgreSQL, Office etc…

Click here to Donation if you like my work


Xojo: ABThinkGear – Mind Reading with the computer

Using the MindWave in Xojo

Using the MindWave in Xojo

Use the force Luke… In Xojo! ABThinkGear is a wrapper around the ThinkGear engine to use the NeuroSky Mindwave device in Xojo. The wrapper is Windows only.

The MindWave is a cheap mind reader device ($79.99) you can buy online e.g. here. It can do some very basic mind wave readings, so don’t expect it to recognize thoughts or so.

Measurements:
– Raw signal
– Neuroscience defined EEG power spectrum (Alpha, Beta, etc.)
– eSense meter for Attention
– eSense meter for Meditation
– eSense Blink Detection
– On-head detection

But still, it’s a fun little thing to play with!

As always, I tried to build an easy to use framework. Here is the structure:
ABThinkGearStructure
ABThinkGearDLL
The actual wrapper around the DLL.
ABThinkGearState
A class containing all the data of one reading (Attention, Meditation, Blinkstrenght, Alpha, Beta, etc…)
ABThinkGear
A thread that polls the data from the device. The data of a MindWave device is only updated once a second, so the poll happens also only once every second. This is the class you’ll use in Xojo the most.

Some code on the use of the framework:

First we need to initialize the MindWave:

  if not MyThinkGear.Connect("COM9", BAUD_57600, true) then
    MsgBox "Could not connect to headset!"
  else
     ' enable the blink detection
    dim ret as boolean = MyThinkGear.EnableBlinkDetection(true)
  end if

The ABThinkGear class has only one event:

ThinkGearChanged(State as ABThinkGearState)

In this event you receive a State containing all the data of the last reading. It is then up to you to do something useful with this data. In the attached demo, I displayed the incoming data.

Mindwave incoming data display in Xojo

Mindwave incoming data display in Xojo

You get quite a bit of info (although not that accurate as it only uses one sensor):

Properties of the ABThinkGearState class

Properties of the ABThinkGearState class

But you can for example start interpreting the data. e.g. if the Attention level is above 80 (in a range of 0 to 100) you could consider performing a certain action.

A couple of days ago, a project using Google Glass was shown doing exactly that. When the attention level reaches a certain point, they take a picture with Glass. On the next attention peak, they post it to twitter. But this can be done now also with Xojo! (take a picture with the webcam, send it to some social media site using the RESt api, et voila!

Here is a video of the Glass project:

The source code of the framework and Demo can be downloaded from http://gorgeousapps.com/ABThinkGear.zip

This framework will be part of the ABXVision framework later.

Cogito ergo sum

“I think, therefore I am”

Happy programming!

Alwaysbusy

Click here to Donation if you like my work


B4i Update: Looks so cool!


Can’t wait to play with this. When you’re used to work with B4A, this looks/feels so natural. I bet the learning curve will be absolutely flat.

…Note that the device is not connected with a cable to any computer.
The debugger is almost fully working. You can put breakpoints, monitor the variables and run watch expressions…

Well done Erel!


%d bloggers like this: