PIIO Extend functionality

First you should read the Steelsquid Kiss OS extend functionality.

Below i explain the class PIIO in a Steelsquid Kiss OS module.
Everything else you can read in Steelsquid Kiss OS extend functionality.

It is useful to read PIIO Simple Example, examples of how to use different functions...
And also the Board overview...

Enable the PIIO boar

And for any of this to work you must enable the PIIO board in Steelsquid Kiss OS
To enable the board just execute this in the command line.
steelsquid piio-on
Or you can do it from the synchronization program by pressing e and then the number in front of kiss_piio.

Useful methods

In the module steelsquid_piio you have alot if methods to handle IO stuff.
Mostly wrapper functions for steelsquid_pi (hard coded addresses and pins) for the PIIO board.

On the PIIO board the pins has the number 1,2,3... You can use that numbering or the normal Raspberrt Pi GPIO numbering.
The numbering on the PCB looks like: 1_14, 2_15, 3_18...   Before the underscore is the PIIO board pin nr and after is the Raspberry Pi GPIO

The PIIO class in a Module

To extend the functionality use a  module, you can create a new or use kiss_expand.py.
Use the synchronization program to create a new and you will get a copy of kiss_expand.py.
Press N and then the name of the new module...
For more info how the modules works and the synchronization program see Steelsquid Kiss OS extend functionality.

In you module create a class like this: class PIIO(object):
Inside that class all the PIIO functionality should be. The following methods you can use.
  • on_voltage_change(voltage)
    Will fire when in voltage to the PIIO board change.

  • on_low_bat(voltage)
    Will execute when voltage is to low.
    You must configure this with voltage_warning and voltage_poweroff.
    Command line: set-parameter voltage_warning <voltage>
    set-parameter voltage_poweroff <voltage>
    voltage_warning is set than the on_low_bat will execute when in voltage in below that.
    If voltage_poweroff is set that the system will shutdown when voltage is below that.

  • on_button(button_nr)
    Will execute when button 1 to 6 is clicked on the PIIO board

  • on_button_info()
    Will execute when info button clicked on the PIIO board

  • on_switch(dip_nr, status)
    Will execute when switch 1 to 6 is is changed on the PIIO board

  • on_movement(x, y, z)
    will execute if Geeetech MPU-6050 is connected and the device is moved.

  • on_rotation(x, y)
    will execute if Geeetech MPU-6050 is connected and the device is tilted.