I2Cwrapper v0.5.0
Generic framework for Arduino I2C target devices
All Classes Files Functions Variables Enumerations Enumerator Macros Modules Pages
template_I2C_firmware.h File Reference

Template for a user firmware module for the I2Cwrapper firmware.ino. "xxx" represents the name of your module, e.g. "PinI2C". More...

Detailed Description

Template for a user firmware module for the I2Cwrapper firmware.ino. "xxx" represents the name of your module, e.g. "PinI2C".

Use this file as a template for your own optional extension module of the I2Cwrapper firmware. You will usually want to bundle it with a matching controller library (see template_I2C.h|cpp). Don't forget to copy it (I use symlinks) into the firmware folder and activate it in the firmware_modules.h configuration file before compiling the firmware.

Currently, your code can be injected between the respective "#if MF_STAGE == ...." compiler directives (leave those untouched) at the following stages into the firmware framework:

(1) includes (2) declarations (3) setup() function (4) loop() function (5) processMessage() function ("command interpreter") (6) reset event (7) (end of) receiveEvent() (8) (end of) requestEvent() (9) Change of I2C state machine's state

Many modules use only a small subset of these stages. (1), (2), (5) are probably always necessary for normal (non feature) modules.

See below for instructions on what code to place where. See existing modules for illustration. PinI2C and ServoI2C are good and simple starting points, ESP32sensorsI2C for using interrupts, AccelStepperI2C for code injection into the main loop().

You can use the log() macro for debug output. It will produce no code with DEBUG unset, and be extended into "Serial.print()" with DEBUG set.

Author

Copyright (c) 2022 juh

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.