I’m a bit ‘old-school’ as I started teaching computer programming, or coding, in 1968 and I like DOCUMENTATION. I do not want to guess or try this to see if it will work if the guy I bought a device from hasn’t told me how to use it properly. I know that developing software takes time but documenting it is should be part of the package. As examples of good practice I suggest you look at the work of Alex Eames of Raspi.tv and his documentation for Raspio-duino
and Ben Nuttall’s gpiozero
I got a Mega Treasure Chest via Kickstarter. I was disappointed with the early versions of the software and gave up on it over the summer. Now that an improved version of the software is available and the nights are drawing in I’ve been giving it another try. Search as I might I still cannot find any useful documentation for ‘flotilla-python’ . There are a few examples, using some of the simplest commands, for the least complicated inputs and outputs but not enough details.
While we wait for the ‘official documentation’ I thought that I would post a few examples of what I have found out and hope that others will join in and add to the published body of knowledge. Unless teachers, who have little time, can easily access this information they will not be able to use Flotilla effectively in secondary schools. Its great physical kit, now working much better, so let’s pool what we have worked out so far.
My first contribution uses Touch, Rainbow, Dial and Number. Before you start using flotilla-python you must remember to turn off the flotilla service for Rockpool with the command ‘sudo service flotilla stop’ in terminal.
The script changes colours on the Rainbow, displays values on Number, inputs values from Dial and carries out a few simple calculations.
rainbow.set_pixel(pixel, r ,g, b).update()
pixel ( range: 0 to 4)
r, g, b (range: 0 to 255) colour mixing values
.update() this displays the changes immediately rather than with rainbow.update() later.
n is an integer (range: 0 to 9999)
number.update() displays the changed value (often forgotten)
This reads the value from Dial (range: 0 to 1023) but returns a string. It must be converted to a number before you can carry out calculations or pass it on to Number. Use int(dial.data) to convert to integer and float(dial.data) for floating point.
#Touch Rainbow Dial Number
# Tony Goodhew 18 Oct 2016
client = flotilla.Client(
touch = client.first(flotilla.Touch)
dial = client.first(flotilla.Dial)
rainbow = client.first(flotilla.Rainbow)
number = client.first(flotilla.Number)
print("Touch the buttons and turn the dial\n")
print(" Use CTRL-C to stop")
dial_val = int(dial.data) #Read dial and change string to integer
dial_val = float(dial.data) # Changed to FP: range 0 to 1023
percentage = int(dial_val * 1000.0 / 1023.0 / 10.0)
print("\nStopped with CTRL-C")
In an editor, like idle3, if you type a module name and full stop then press tab you get a list of possible commands. For example, “dial. “ gives the following list:
channel, channel_index, clamp, client, data, is_a, name, position, send, set_data, stop.
What do they do? Which are possibly dangerous?
I would like to take control of the LEDS on Touch to show which one was last pressed. Can anyone help?