[P126] Add 74HC595 Shiftregisters plugin#3917
Conversation
lib/ShiftRegister74HC595_NonTemplate/src/ShiftRegister74HC595_NonTemplate.cpp
Outdated
Show resolved
Hide resolved
lib/ShiftRegister74HC595_NonTemplate/src/ShiftRegister74HC595_NonTemplate.h
Outdated
Show resolved
Hide resolved
…mprove 74hcSetAll for setting multiple output pins
|
I am already preparing my environment for tests. I would like to use this shiftregister to control relays that should survive their status (if the shiftregister & plugin works as I assume) over ESP node unexpected reboot when GPIO pins are reset to 0. |
|
I'm not sure it can work that way, as the current state can't be read from the shiftregisters, it is serial-out only, AFAICS. |
|
I don't need to read the status, for me it's enough to write the register so 74HC595 should be fine. But I need the shift register output to keep the written status until it's updated with another data (complete 8 bits) . I suppose the outputs are not changing when the serial data are filling the register. And the must is that the outputs are still keeping the last status even though the ESP node is warm rebooted by any reason. |
|
Well, then that should be covered, as nothing is written to the registers at startup of the plugin, only when using the available commands: (last updated: 2022-02-27) So you can set up separate pins using Be careful though to not use GPIO pins that change state during startup of the ESP, as that might trigger outputting an unexpected state. See: https://espeasy.readthedocs.io/en/latest/Reference/GPIO.html |
|
@tonhuisman @TD-er isn't it more elegant to add setSize(uint8_t nb) method and not resize _digitalValues everytime ? |
Not sure what you are hinting at here. That vector is sized at initialization, and when setting/clearing all bits, AFAICS. |
|
Thanks for the great news. :-)
Yes that's what I was thinking of as I am already using most of GPIOs and on ESP8266 it's a problem. It will be necessary to decide what to regret (or find a way for sharing some GPIOs). |
|
OK, so the very first quick test - 74hcSetAllHigh command worked OK but after reboot the all outputs are set to low... |
|
Ah, the check looks for 1..8, but I didn't subtract 1 from the pin number provided before setting that pin. Will fix. Would you expect to set pins |
|
It does not matter for me, I don't know what's better - perhaps starting from 1 would be better. The major issue for me - it's the reset outputs to low during reboot. I need to analyze if that's due to used GPIOs or what's the reason. |
Looking at the page I shared earlier, I'd try to avoid D8 and D3, as they are not |
|
Thanks for the comment, I'll give it a try. I am already using OK pins for another purpose so that's why I am trying those with exclamation mark first. :-) I understand I'll probably have to change that. |
I spoke too soon, earlier, the registers where actually reset to off, at startup, sorry 😊, but that should now be fixed. The internal buffer is reset, but the state is now not sent out to the registers until a command to change them is used. The State_A..State_D variables are used to represent the |
The current state should be reflected in the
I'll investigate how to restore the values after a warm reboot. |
|
After issuing the commands The State_A variable is unexpectedly not displaying the current value, so I'll have a look into that. You are showing the Edit: Number of chips is still set to 1. |
FYI when I set the Interval >0, the periodical crashes encountered:
|
…feature/p126-74hc595-shiftregisters
|
Is it necessary to make a change in my Custom.h after recent changes in source codes? I can't compile with Vagrant anymore: default: Indexing .pio/build/custom_IR_ESP8266_4M1M/libFrameworkArduino.a |
|
The inclusion of the separate |
|
Thanks for the feedback. The question is if I am still able to compile with PR#3917 when I disable P126 in Custom.h ? |
Well, I expect you got this error when compiling another branch of ESPEasy, that doesn't have this plugin available. |
|
Yeah I am always compiling the main branch in first step as there's a script that (re)builds the Vagrant environment completely from scratch. In second step (to compile with a PR not yet merged) I am conencting to already running Vagrant virtual machine and starting a compilation there (with PR parameter). |
…feature/p126-74hc595-shiftregisters
…feature/p126-74hc595-shiftregisters
…feature/p126-74hc595-shiftregisters
|
@ghtester I have changed the commands for this plugin to now be 'prefixed' with |
|
@tonhuisman maybe shiftin and shiftout instead of 74hc... |
Very good suggestion, I will change both plugins, P126 to |
|
Well, just another idea (when there's another change pending yet) - there are existing commands GPIO and PCFGPIO, maybe it would be nice to keep GPIO in the new commands (related to shift I/O pins) as well. What do you think? |
Well, there are a few reasons I'm less fond of that idea. GPIO stands for General Purpose Input Output, and that's not what these are, they are either output or input, so IMHO that wouldn't actually match the 'Input Output' part. And having commands like |
|
@tonhuisman Asked for change cmd name because there are available also others shift registers than 595 and 165 you can use here. Maybe should mention that earlier but it still waiting to merge. |
Yes, that is the main reason I agree with your proposed command rename 😃, and the second reason the commands being better readable. |
|
OK, I understand, you are right. I also prefer a short command names. Hopefully the command name changes will be final. ;-) |
It is nicely in line with many other plugins command handling now, shouldn't need to change again. The only change I'm now thinking of is the name of the plugin, currently it's |





On a request from this forum thread
Plugin to control from 1 to
16255 74HC595 (and compatible) shift-registers, connected in a daisy-chain, as supported by these chips.(More daisy-chained chips can easily be supported, but the state can't be displayed on the Devices page)Includes an 'un-templated' (to avoid code duplication) version of the Simsso (Timo Denk)
ShiftRegister74HC595library, as that is tried and proven technology.Available in
TEST_Ebuilds.TODO:
Removed from TODO list:
I removed this feature from the TODO list, as further investigation has revealed that most of the 7-segment displays driven by 74HC595 (and compatible) chips, are actually driven in a matrix, requiring continuous updating of the data sent to the shift registers, and while an ESP is perfectly capable of doing that as a single task, it will put too much strain on the ESP for ESPEasy to function as intended and desired, resulting in possibly dropped WiFi connection, and slow response on any other task it has to perform, while the regular tasks & rules processing probably will distort the display.
NB: This plugin can still be used to control a static, 1:1 connected, 74HC595 -> single 7-segment display, as in that case the 8 outputs are then each directly connected to a segment and the decimal point.
If 7-segment displays are desired, please have a look at the TM1637/MAX7219, 4, 6 or 8 digit, 7-segment displays, as supported by P073 - Display - 7-segment display.