Flotilla Documentation query


#1

Within the python API documentation for the dock itself there is a comment at the end “if you want to connect 2 identical modules then refer to advanced use”. I cannot find this advanced use bit. Help please


#2

This code has a good example at one- flexible- way of dealing with multiple modules, although it doesn’t distinguish between them:

It iterates through all available modules, checks to see what they are, and acts accordingly.

You could use this pattern to assign several modules in a first-come-first-served order to be used later, like so:

dial1 = None
dial2 = None

for module in dock.available.values():
    if module.is_a(flotilla.Dial):
        if dial1 is None:
            dial1 = module
        elif dial2 is None:
            dial2 = module

Which will set dial1 and dial2 to the first two dials that it finds.

Alternative you can identify modules by their channel. Here’s a good example of how to do that: https://github.com/pimoroni/flotilla-python/blob/5cb8d0dba257869eab9ffdd18189d0b9dbf95115/examples/mini-kit.py

Flotilla can wait until a Touch is plugged into channel one, and a Rainbow in channel two:

try:
    dock = flotilla.Client(
       requires={
            'one': flotilla.Touch,
            'two': flotilla.Rainbow
        })
except KeyboardInterrupt:
    sys.exit(1)

Then your code can just assume they are present:

touch = dock.first(flotilla.Touch)
rainbow = dock.first(flotilla.Rainbow)

#3

Thanks…I was specifically interested if you could, for example connect 2 touch modules and access them indepedently


#4

You can indeed! We’ll have to up our documentation game for this kind of usage. But in the meantime, I’m happy to help.


#5

I am using a pi zero with motephat and mote strips to give some illumination to an Anet A8 3D printer. Yes its probably overkill. But I have a spare flotilla dock so I thought if I connected touch boards I could select different lighting effects! If I could connect 2 I could have more options. So if there was some code for that it would be great. Talking about the flotilla dock is it OK to connect it to the micro usb port on the pi zero with one of the blue flotilla micro usb cables? Also can I use one of those blue cables to connect a mote strip to the mote phat board?


#6

The blue Flotilla cables are only tested up to something like 300mA and designed for i2c signals, they would probably drop too much voltage to be stable as a way of connecting things directly to the Pi Zero, and may not do the USB signal any favours either.

The Mote cables will fare a little better. You wont harm anything but trying- I’ve had things working like this- but don’t expect it to work/be stable.