Dingtian: add inverted outputs and support shared PL/RCK pin#24364
Dingtian: add inverted outputs and support shared PL/RCK pin#24364baetzst wants to merge 2 commits intoarendst:developmentfrom
Conversation
|
I don't like these kinds of compile time options that make overall firmware management a nightmare. This should be rather a parameter or a template option. I know nothing about MODBUS so I can't help |
|
This is not about Modbus. It is about adapting an already existing driver, xdrv_90_esp32_dingtian_relay.ino, to support the board mentioned above. |
|
Still, the fact beeing ModBus or not. Make the feature non compile dependent would be more nice. |
|
At tasmota\my_user_config.h there is already: I would suggest to add the
there too and add it to the PR. In my opion adding new pin functions as runtime-config for the existing driver is a kind of overkill. |
|
@meMorizE If the point is to avoid a build time setup, an existing approach for having options able to set at run time, without this taking up any code space, is to reserve a Option_A number. These are set on an unused gpio, and there are already 8 such numbers in use, up to a max of 32. Also, there are already two There are already cases where such numbers are reused for other setups, unlikely to be combined. These When it comes to supporting inverted pins on gpio multiplexer devices, a much more robust approach is now being used for PCF8574 and others. This is based on an extra template to assign standard component numbers (like for native gpios) to the multiplexed gpios. Of course, this is an approach for full flexibility, configured pin by pin, like maybe only inverting 2 of 4 outputs, etc. Docs already describes this here https://tasmota.github.io/docs/PCF8574/#mode-2 (but same for other multiplexers. Not trying to say what "should" be done, merely adding some info for context. And to be clear, I don't know much about this specific case, hence some of the above may not even be a reasonable approach. |
…input inversion) support to Dingtian driver
|
@sfromis
Would it make sense to remove the compile-time options entirely? Inputs could always be treated as switches. This might simplify the configuration and reduce the need for different build options — what do you think? |
| // #define HX711_CAL_PRECISION 1 // When HX711 calibration is to course, raise this value | ||
|
|
||
| //#define USE_DINGTIAN_RELAY // Add support for the Dingian board using 74'595 et 74'165 shift registers | ||
| // #define DINGTIAN_INPUTS_INVERTED // Invert input states (Hi => OFF, Low => ON) |
There was a problem hiding this comment.
The removal of this defines breaks legacy support (and current installation).
The "usual way" to handle this is adding a one time test in your new code for setting the correct SetOption based on this define.
This one time test should also set the other SetOption to it's default value before you made this change (as otherwise the legacy functionality would also be broken).
There was a problem hiding this comment.
@arendst How should I implement the one-time migration check? What's the recommended way to detect "first boot after flashing" so the SetOption migration from the legacy DINGTIAN_INPUTS_INVERTED define only runs once?
There was a problem hiding this comment.
It's tricky and related to version number. It needs to be in the settings.ino file at the end.
I'll do it now based on your PR. Pls do not change anything anymore. Working on it.
Description:
Add support for the esp32_relay_x8_modbus (303E32DC812) board by
allowing inverted relay outputs and shared PL/RCK control pins in the
ESP32 Dingtian driver.
GPIO Mapping
This fixes incorrect relay behavior caused by the board-specific GPIO
mapping.
Related issue (if applicable): n/a
Checklist:
NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass