Hardware plugin writing HOWTO
Every hardware output plugin is a shared library that exports a LedHardwarePlugin descriptor structure and thus provide various functions for libniftyled to call. For a detailed description of the structure, check the doxygen documentation and niftyled sourcecode
- niftyled calls the plugin_init() function. The plugin should...
- ...allocate and set the privdata pointer that will be passed to subsequent function calls
- ...initialize everything except for hardware resources
- niftyled calls the hw_init() function where the hardware should be initialized so it is ready to use.
- This can be called multiple times. In combination with hw_deinit() it should reset the hardware.
- The hardware should recover from any recoverable previous error.
- niftyled calls the send() function passing it a LedChain, and the range of valid brighntess-values by defining the length of the chain and an offset (usually 0 to send all values at once). The plugin can store or process the data here. If the hardware can "store" data without changing it's lighting output, this should be done.
- niftyled calls the show() function. The hardware should reflect ("latch") the brightness values received in send() as quickly as possible. If the hardware can't store data without showing it, it's sent to the hardware here.
- niftyled calls hw_deinit() to free resources of the hardware. This can be called multiple times.
- niftyled calls plugin_deinit() where all resources should be freed.