From 3cf356e1dcc0f7c90c8fddbacfdd60cd9fbc14ba Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Wed, 23 Feb 2022 22:50:47 +0100 Subject: [PATCH] [P126] Rename command-prefix from 74hc to 74hc595, and update documentation --- docs/source/Plugin/P126.rst | 2 +- docs/source/Plugin/P126_commands.repl | 24 +++++++++++----------- src/_P126_74HC595.ino | 21 ++++++++++--------- src/src/PluginStructs/P126_data_struct.cpp | 18 ++++++++-------- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/docs/source/Plugin/P126.rst b/docs/source/Plugin/P126.rst index 46a80d83c..58cd6fe55 100644 --- a/docs/source/Plugin/P126.rst +++ b/docs/source/Plugin/P126.rst @@ -30,7 +30,7 @@ When connecting many shift regiters daisy-chained, it is important to ensure tha The output pins can be used to control f.e. relays. The logic is built so that on crash or reboot of the ESP, the last used state can be restored from RTC memory (enabled by default), so the state of the outputs is kept. This is limited to max. 16 shift registers, as that is the size of the memory reserved per task in RTC memory. This memory only survives a warm boot, *not* a reset or power-cycle! -The register outputs are **not** updated on start of the plugin, only when changing a pin state, or using the ``74hcUpdate`` command, the shift registers are updated. +The register outputs are **not** updated on start of the plugin, only when changing a pin state, or using the ``74hc595Update`` command, the shift registers are updated. Configuration ------------- diff --git a/docs/source/Plugin/P126_commands.repl b/docs/source/Plugin/P126_commands.repl index 024d91efa..20b9828e2 100644 --- a/docs/source/Plugin/P126_commands.repl +++ b/docs/source/Plugin/P126_commands.repl @@ -3,56 +3,56 @@ :widths: 20, 30 " - | ``74hcSet,,<0|1>`` + | ``74hc595Set,,<0|1>`` "," | Set ```` to the state provided. Pin numbers start at 1 and continue up to no. of chips * 8. The shift registers are updated immediately " " - | ``74hcSetNoUpdate,,<0|1>`` + | ``74hc595SetNoUpdate,,<0|1>`` "," - | Set ```` to the state provided. Pin numbers start at 1 and continue up to no. of chips * 8. The shift registers are **not** updated. See ``74hcUpdate`` command. + | Set ```` to the state provided. Pin numbers start at 1 and continue up to no. of chips * 8. The shift registers are **not** updated. See ``74hc595Update`` command. " " - | ``74hcUpdate`` + | ``74hc595Update`` "," | Update the current buffered state to the shift registers. " " - | ``74hcSetAll,[chip:][width:]...`` + | ``74hc595SetAll,[chip:][width:]...`` "," | Set the addressed chip(s) with the value provided. Values should be max. 32 bit. Chip starts at 1 by default, and width is 4 by default. Shift registers are updated immediately. | To select a single chip with 8 bits of data, use a ``width`` of 1, use 2 for updating 2 adjacent chips with a 16 bit value, etc. " " - | ``74hcSetAllNoUpdate,[chip:][width:]...`` + | ``74hc595SetAllNoUpdate,[chip:][width:]...`` "," - | See ``74hcSetAll`` command, but without immediate update to the shift registers. See ``74hcUpdate`` command to set the output to the shift registers. + | See ``74hc595SetAll`` command, but without immediate update to the shift registers. See ``74hc595Update`` command to set the output to the shift registers. " " - | ``74hcSetAllLow`` + | ``74hc595SetAllLow`` "," | Switch all shift register outputs to off (low). Immediately updates the shioft registers. " " - | ``74hcSetAllHigh`` + | ``74hc595SetAllHigh`` "," | Switch all shift register outputs to on (high). Immediately updates the shioft registers. " " - | ``74hcSetChipCount,`` + | ``74hc595SetChipCount,`` "," | Change the number of chips configured. Will adjust the configuration immediately, but not store the setting, use the ``save`` command for storing the setting. | When adding chips, the outputs will all be set to low/off. " " - | ``74hcSetOffset,`` + | ``74hc595SetOffset,`` "," | Change the ``Offset for display`` configuration setting. Does not save the setting, use the ``save`` command for storing the setting. " " - | ``74hcSetHexBin,<0|1>`` + | ``74hc595SetHexBin,<0|1>`` "," | Change the **Values display (Off=hex/On=Bin)** setting to on (1) or off (0). Does not save the setting, use the ``save`` command for storing the setting. " diff --git a/src/_P126_74HC595.ino b/src/_P126_74HC595.ino index 9330314a1..f1c1e5e97 100644 --- a/src/_P126_74HC595.ino +++ b/src/_P126_74HC595.ino @@ -7,6 +7,7 @@ // ####################################################################################################### /** Changelog: + * 2022-02-23 tonhuisman: Renamce commands using prefix 74hc595 to distinguish from plugin P129 74hc165 using similar commands. * 2022-01-22 tonhuisman: ShiftRegister74HC595_NonTemplate library: Add setSize method, cleanup constructor * Setting: Restore register-buffer state from RTC values after warm boot (or crash...) * NB:!!! Only restores up to 4 * VARS_PER_TASK (16) chip values, starting at the configured Offset for display !!! @@ -30,16 +31,16 @@ */ /** Commands: - * 74hcSet,,<0|1> : Set a single pin on or off, and update. - * 74hcSetNoUpdate,,<0|1> : Set a single pin on or off. Use 74hcUpdate to set outputs. - * 74hcUpdate : Update all pin states to the registers. - * 74hcSetAll,[chip:][width:]... : Set a range of chips with values, default 32 bit values (width 4). - * 74hcSetAllNoUpdate,[chip:][width:] : Ditto, without immediate update. Use 74hcUpdate to set outputs. - * 74hcSetAllLow : Set all register outputs to 0/low. - * 74hcSetAllHigh : Set all register outputs to 1/high. - * 74hcSetOffset, : Set the chip offset for display. Will reflect in the device configuration, but not saved. - * 74hcSetChipCount, : Set the number of chips to use, without restarting the plugin. Range 1..P126_MAX_CHIP_COUNT. - * 74hcSetHexBin,<0|1> : Turn off/on the Hex or Bin Values display, reflected in device configuration, but not saved. + * 74hc595Set,,<0|1> : Set a single pin on or off, and update. + * 74hc595SetNoUpdate,,<0|1> : Set a single pin on or off. Use 74hcUpdate to set outputs. + * 74hc595Update : Update all pin states to the registers. + * 74hc595SetAll,[chip:][width:]... : Set a range of chips with values, default 32 bit values (width 4). + * 74hc595SetAllNoUpdate,[chip:][width:] : Ditto, without immediate update. Use 74hcUpdate to set outputs. + * 74hc595SetAllLow : Set all register outputs to 0/low. + * 74hc595SetAllHigh : Set all register outputs to 1/high. + * 74hc595SetOffset, : Set the chip offset for display. Will reflect in the device configuration, but not saved. + * 74hc595SetChipCount, : Set the number of chips to use, without restarting the plugin. Range 1..P126_MAX_CHIP_COUNT. + * 74hc595SetHexBin,<0|1> : Turn off/on the Hex or Bin Values display, reflected in device configuration, but not saved. */ # define PLUGIN_126 diff --git a/src/src/PluginStructs/P126_data_struct.cpp b/src/src/PluginStructs/P126_data_struct.cpp index 4f037502d..36e9687d2 100644 --- a/src/src/PluginStructs/P126_data_struct.cpp +++ b/src/src/PluginStructs/P126_data_struct.cpp @@ -119,10 +119,10 @@ bool P126_data_struct::plugin_write(struct EventStruct *event, bool success = false; String command = parseString(string, 1); - if (command.startsWith(F("74hc"))) { + if (command.startsWith(F("74hc595"))) { const bool hc_update = command.indexOf(F("noupdate")) == -1; - if (command.equals(F("74hcset")) || command.equals(F("74hcsetnoupdate"))) { + if (command.equals(F("74hc595set")) || command.equals(F("74hc595setnoupdate"))) { const uint8_t pin = event->Par1; const uint16_t value = event->Par2; @@ -141,10 +141,10 @@ bool P126_data_struct::plugin_write(struct EventStruct *event, } # endif // ifdef P126_DEBUG_LOG } - } else if (command.equals(F("74hcupdate"))) { + } else if (command.equals(F("74hc595update"))) { shift->updateRegisters(); success = true; - } else if (command.equals(F("74hcsetall")) || command.equals(F("74hcsetallnoupdate"))) { + } else if (command.equals(F("74hc595setall")) || command.equals(F("74hc595setallnoupdate"))) { success = true; std::vector value; value.resize(_chipCount, 0); // Initialize vector to 0's @@ -246,13 +246,13 @@ bool P126_data_struct::plugin_write(struct EventStruct *event, if (success) { shift->setAll(&value[0], hc_update); } - } else if (command.equals(F("74hcsetalllow"))) { + } else if (command.equals(F("74hc595setalllow"))) { shift->setAllLow(); success = true; - } else if (command.equals(F("74hcsetallhigh"))) { + } else if (command.equals(F("74hc595setallhigh"))) { shift->setAllHigh(); success = true; - } else if (command.equals(F("74hcsetoffset"))) { + } else if (command.equals(F("74hc595setoffset"))) { if ((event->Par1 >= 0) && (event->Par1 <= P126_MAX_SHOW_OFFSET)) { uint8_t previousOffset = P126_CONFIG_SHOW_OFFSET; P126_CONFIG_SHOW_OFFSET = event->Par1; @@ -279,7 +279,7 @@ bool P126_data_struct::plugin_write(struct EventStruct *event, } success = true; } - } else if (command.equals(F("74hcsetchipcount"))) { + } else if (command.equals(F("74hc595setchipcount"))) { if ((event->Par1 >= 1) && (event->Par1 <= P126_MAX_CHIP_COUNT)) { P126_CONFIG_CHIP_COUNT = event->Par1; _chipCount = event->Par1; @@ -287,7 +287,7 @@ bool P126_data_struct::plugin_write(struct EventStruct *event, success = true; } # ifdef P126_SHOW_VALUES - } else if (command.equals(F("74hcsethexbin"))) { + } else if (command.equals(F("74hc595sethexbin"))) { if ((event->Par1 == 0) || (event->Par1 == 1)) { uint32_t lSettings = P126_CONFIG_FLAGS; bitWrite(lSettings, P126_FLAGS_VALUES_DISPLAY, event->Par1 == 1);