(this is not my jewellery CNC blog, that's here : http://digital-jeweller.blogspot.com/)
Android Adventures!
I poked around a bit with Android Studio for kicks and the outcome was a heap of nonsense and them some marginally interesting apps with purpose.
RingSize converter.
This one is for jewellers only, it will convert between the most common types of ring finger sizes.
The onscreen sizer only works well with 400DPI screens, but the right hand slider will allow you to compensate/calibrate for other screen DPI's
Density converter, again for jewellers, to convert between most common metal types or from wax/resin to a metal etc.
Download: https://drive.google.com/open?id=0B5yCbfbC75zDREN5LVExckNGVm8
NFC card reader/Writer. Self explanatory, it allows you to write to NFC, or read.
(this is not my jewellery CNC blog, that's here : http://digital-jeweller.blogspot.com/)
Blinking an LED on the UP.. Sounds simple? If you have done the below correctly you should have an outcome as this: (or if you are lazy, download the project HERE)
UP LED FIRST....
The majority of "makers" being targeted by the myriad of new SBC's on the market are not professional coders, most are not even amateur coders.. for the large part they are people like me.. interested in learning a new technology, and willing to google for snippets and copy-paste a working program together.
The success of boards like the Raspberry Pi and the Arduino series are largely due to their plain English, down to earth API's, aimed at "makers" with ample clear instructions and tutorials making the learning curve fast. SO: it was a little disappointing to have run into such a lot of headaches with my UP Board, and so little documentation to try figure it out. Anyhow, getting back to Blink...
Lets examine this simplest of programs on a few other platforms.. lighting up an LED.
using Windows.Devices.Gpio; ledPin = gpio.OpenPin(3); ledPin.SetDriveMode(GpioPinDriveMode.Output); ledPin.Write(GpioPinValue.High);
RPi running Rasbian: import RPi.GPIO as GPIO GPIO.setmode(GPIO.Board) ledPin = 3 GPIO.setup(ledPin,GPIO.OUT) GPIO.output(ledPin,GPIO.HIGH) There is a commonality of implementation that makes it simple to understand the process..
include a library if required, set the pin direction, set the pin value.
Now lets examine doing the the same on UP Board, using C# in windows 10.
Firstly the SETUP Steps:
You will need to download the SDK and Framework, below are the ones used in this example. I don't maintain these files so they are subject to change. SDK: http://www.dropbox.com/s/uamv9p4tt5881jm/Dio.rar?dl=0 FrameWork : http://www.dropbox.com/s/ha0nxu0kmdnfta9/Hi-Safe_v2_20161017.rar?dl=0 The framework contains some drivers. Install the drivers using the adequate advice in the PDF in the folder. In the SDK is an example project called DIO, (written in CS).
Copy the DIO project to a handy location and copy out the file aaeonEAPI.dll. Now open the DIO project in VS and leave it open.. we will need to copy some stuff over later. (if you attempt to compile the project as is in VS15 you will hit a wall, search my name CeeBee on the UP forum for instructions on how to bypass this issue, but for now we only want to copy files from this project, not run it, so onwards...) Create a new Project:
In your new project right click the project name in solution explorer, and then [ADD EXISTING]. Add the aaeonEAPI.dll file we copied out earlier, then set the aaeonEAPI.dll to "copy always" in properties.
Now lets go back to the DIO projects main application code and copy and paste the lines near the top of it which import the DLL calls from the aaeonEAPI.dll, into your program. Open and copy all the content EAPI.CS file main body.
(its been done in the region wrappers in the code below)
Now finally you are ready to start actually coding.. you can close the DIO example. Returning to our examples above we can immediately write the following code and expect a result.
BUT... It didn't work, did it? The current API has a glitch, either by mistake or by design the pin numbering is out by -1... changing 3 to 2 in example above woudl make pin 3 light up... BUT, what is input, what is output, what is high, what is low, and boy is that code ugly, all those uint's and 0xFFFFFFFF's which we have no idea about, why are we looking at them?
SO, lets fix that.. and make it look prettier.. (and fix that pesky bug)
Add these variables to the top of your code,and then add these two voids into your code (these are the most basic examples to get it working without any error checking code!!)
This is also now far more legible, noting you can call these voids anything you like, or return an error etc. ..its my void, and I'll can int if I want to... <sung to "It's my Party" - Leslie Gore> If you own your board, and the code is for you, to be added to existing projects, you don't need to go much past this, For the rest, lets move onto SuperBlinky...
BLINKY
So the first actual "Blinky" program for the UP board... .. based on the above cleanup and fixes, its a little beefier, with selectable pin, selectable millisecond delay and the number of repeats.. and some basic error catch. (you can delete the form, BlinkPin and Start_Click and basically have a template ready to start working in.) Methods created are : EnableSDIO() which with return with an int ERR if there is one. SetPinDirection(int pin, uint direction) which will accept the pin number and either INPUT or OUTPUT as a uint variable, it will return an int err if it went kooky on you.(status.text is updated) GetPinDirection(int pin, uint direction) which will accept the pin number and a variable to pass to the API for the pin direction. it will return and int of either ERR (status.text is updated) or 1(input) or 0(output). SetPinState(int pin, uint state) which will accept the pin number and either HIGH or LOW as a uint variable, it will return an int ERR if it went kooky on you. (status.text is updated) GetPinState(int pin, uint state) which will accept the pin number and a variable to pass to the API for the pin state. it will return and int of either ERR (status.text is updated) or 1(high) or 0(low).
(errors and values as int as its a PITA to keep having to convert between uint's to do if/then compares to other ints, change as required)
You will need to create a form with these components
and hopefully you get the same result as me, a nice easy to use blinker app! (To keep yourself sane, use #region ~ #endregion wrappers to hide the stuff you don't want to see while you are working so your actual code ends up looking like bleow)
In Conclusion:
I still don't know what a bitmask is, or how and why and when it would be used, I still don't know how to write a PWM value, or read an analog pin... Much work to be done deciphering the API documentation...
(this is not my jewellery CNC blog, that's here : http://digital-jeweller.blogspot.com/)
360 CAM
The goal was to build a rotating camera table, that was a bit more programmable than the others in the market place, and in so doing learn c#, java and interfacing with IoT and Arduino. I already know a teensy bit about electronics from my CNC building days (it all runs on magic smoke...)
Anyhow, I have a hectic job, lots of international travel and time to get to this has been limited, but finally its looking near complete.
The Windows10 app here. [UPDATE] it now also runs on RPi @ IoT just dandy. Arduino Code updated to accept either.
Interestingly, it gave me chance to review the RPi code and revise the timings, and now its actually not bad at all.. I'm a tad stunted in terms of judging interface speed, because [A] I am viewing the output over remote desktop over wifi which taxes the RPi.. and [B] causes or has a sluggish refresh rate because of either [A] or just simply bad wifi signal, or both, but I think once I have the screen plugged in directly I may not need a bigger SBC board at all, I'm sure ill put the BananaPi and Firefly to good use though)
The source code for both the Arduino and UWP windows app will be in one of my usual threads somewhere on http://3dcadjewelry.com/
The Arduino/RPi build and wiring (edit: slightly out of date, I'll upload new image this weekend). it runs the same as its windows cousin, just dump the RPi, and any wiring connected to it or keep them both wired up, it will accept feedback and input from both PC and RPi, but you will have to have a webcam plugged into the one you want to capture with.
As an interesting aside, I hacked an old A490 canon to run CHDK to enable USB +5v trigger and added camera support, so it will capture from both.
Not much video of the relay switches in action because I am waiting for my build, but here you go.
and the Android will come soon after i finished that damned NFC project..
The large build has been reduced significantly to this
Which now also runs on a regular windows forms App (limited audience on UWP)
the
The Python Version is complete too. Code as follows, adding UART access now.. bit stuck on that currently..