HT16K33 Class: Difference between revisions

Jump to navigation Jump to search
no edit summary
(Creation)
 
No edit summary
Line 9: Line 9:
...<br />
...<br />
[b01110'''111'''] = 0x77<br />
[b01110'''111'''] = 0x77<br />
== HT16K33 Instance ==
The '''''HT16K33 Class''''' allows the creation and management of a device of type '''''HT16K33''''' which allows to control a chip '''''HT16K33''''' from Holtek.<br />
'''In normal operation this Class is not called directly'''. This class is invoked when reading the configuration and creating the devices defined in the devices configuration file. Each device with de the '''''devicetype''''' property set to '''HT16K33''' in the device configuration file will be create with this Module Class.
owever, as part of a development, it may be necessary to perform tests to have to manually create these device objects.
Remember, after reading the configuration and generating the elements everything is stored in the interface object. Classes for generating devices are no exception. These Classes for creating device objects are part of the interface modules.
<syntaxhighlight lang="python" inline>HT16K33(devicename, deviceaddr, debug_level)</syntaxhighlight>
* devicename : device name, this is this name will be use in the configiration to identify the device. This name need to be unique
* deviceaddr : device address on I2C bus. Hexadecimal format.
* debug_devel : Debug Level Value (Integer)
We need to call the Module '''HT16K33''' to create our device. This done with the getModule(modulename) interface methode<br />
If you want to know what module is loaded in the interface you can call the listLoadedModules().<br />
To create a new device named '''LEDPACK2''' (which is not defined in the configuration file but exist on the I2C bus [ connected ] ) with the following parameters
* devicename : '''LEDPACK2'''
* deviceaddr : '''0x71'''
* debug_level : '''0'''
<syntaxhighlight lang="python">
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from FGInterface import FGInterface as FGINT
>>> FGINT1 = FGINT('radiopanel.cfg', 0)
>>> FGINT1.listLoadedModules()
{'HT16K33': <module 'FGIntHT16K33' from '/opt/fgint/FGInt/FGIntHT16K33.py'>, 'MCP23017': <module 'FGIntMCP23017' from '/opt/fgint/FGInt/FGIntMCP23017.py'>, 'Switch': <module 'FGIntSwitch' from '/opt/fgint/FGInt/FGIntSwitch.py'>, 'SegDisplay': <module 'FGIntSegDisplay' from '/opt/fgint/FGInt/FGIntSegDisplay.py'>}
>>> MODULE_HT16K33 = FGINT1.getModule('HT16K33')
>>> LEDPACK2 = MODULE_HT16K33('LEDPACK2', '0x71', 0)
>>> print(LEDPACK2)
<FGIntHT16K33.HT16K33 object at xxxxx>
>>>
</syntaxhighlight>
'''LEDPACK2''' is now an instance of the '''HT16K33 class''' witch will drive the device named '''LEDPACK2''' at the address '''0x71''' on the I2C bus
== HT16K33 Methods ==
=== Method Template
<syntaxhighlight lang="python">
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from FGInterface import FGInterface as FGINT
</syntaxhighlight>
534

edits

Navigation menu