I'm currently trying to update a plugin to the latest espeasy mega branch. My plugin (P198_Venta) uses 6 input pins and 3 output pins.
Last year, I was simply using the following code (stripped down to a minimal example) in PLUGIN_INIT:
Code: Select all
pinMode(cfg.pwr_led, INPUT); // PWR LED pinMode(cfg.pwr_btn, OUTPUT); // Power Button attachInterrupt(digitalPinToInterrupt(cfg.pwr_led), Plugin_198_ISR, CHANGE); setPinState(PLUGIN_ID_198, cfg.pwr_btn, PIN_MODE_OUTPUT, 0); // Power Button
Code: Select all
digitalWrite(pin, state); setPinState(PLUGIN_ID_198, pin, PIN_MODE_OUTPUT, state); SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_198, pin, log, 0));
However, now the above code does not compile any more, so I looked at the P001_Switch plugin again. These code parts appear to be much more complicated now with createKey, globalMapPortStatus, assigning all fields of a portStatusStruct and calling savePortStatus.
So, my questions are:
- Is there any documentation about how to correctly setup input/output pins and how to correctly read input pins and set output pins?
- If not, which parts of the P001_Switch are really required for espeasy to function properly, and which parts of PLUGIN_INIT and PLUGIN_WRITE can be removed. As I have 9 pins to set up, doing everything the switch plugin does in PLUGIN_INIT for one single pin would result in several hundreds of lines of code...
Unfortunately, the git log of the commit that removed setPinState (fda673ce9db2638a551a2c75c533c3dd47e22e73 on Nov 19, 2018) does not give any indication about possible replacements for setPinState...