Skip to content

Commit

Permalink
Removed the need for SPI for TM1637 to work
Browse files Browse the repository at this point in the history
  • Loading branch information
ajithvasudevan committed Feb 22, 2021
1 parent c5f79aa commit 75699fe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 1 addition & 3 deletions tasmota/support_tasmota.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1678,9 +1678,7 @@ void GpioInit(void)
ValidSpiPinUsed(GPIO_ST7789_DC) || // ST7789 CS may be omitted so chk DC too
ValidSpiPinUsed(GPIO_ST7789_CS) ||
(ValidSpiPinUsed(GPIO_SSD1331_CS) && ValidSpiPinUsed(GPIO_SSD1331_DC)) ||
ValidSpiPinUsed(GPIO_SDCARD_CS) ||
(ValidSpiPinUsed(GPIO_TM1637CLK) && ValidSpiPinUsed(GPIO_TM1637DIO)) ||
(ValidSpiPinUsed(GPIO_TM1638CLK) && ValidSpiPinUsed(GPIO_TM1638DIO) && ValidSpiPinUsed(GPIO_TM1638STB))
ValidSpiPinUsed(GPIO_SDCARD_CS)
);
// If SPI_CS and/or SPI_DC is used they must be valid
TasmotaGlobal.spi_enabled = (valid_cs) ? SPI_MOSI_MISO : SPI_NONE;
Expand Down
5 changes: 4 additions & 1 deletion tasmota/tasmota.ino
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ struct {
bool module_changed; // Indicate module changed since last restart
bool wifi_stay_asleep; // Allow sleep only incase of ESP32 BLE
bool no_autoexec; // Disable autoexec
bool tm1637_enabled; // TM1637 driver enabled

StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits)
uint8_t spi_enabled; // SPI configured
Expand Down Expand Up @@ -227,7 +228,9 @@ void setup(void) {
TasmotaGlobal.tele_period = 9999;
TasmotaGlobal.active_device = 1;
TasmotaGlobal.global_state.data = 0xF; // Init global state (wifi_down, mqtt_down) to solve possible network issues

#if defined(USE_DISPLAY) && defined(USE_DISPLAY_TM1637)
TasmotaGlobal.tm1637_enabled = true;
#endif
RtcRebootLoad();
if (!RtcRebootValid()) {
RtcReboot.fast_reboot_count = 0;
Expand Down
2 changes: 1 addition & 1 deletion tasmota/xdrv_13_display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,7 @@ bool Xdrv13(uint8_t function)
{
bool result = false;

if ((TasmotaGlobal.i2c_enabled || TasmotaGlobal.spi_enabled || TasmotaGlobal.soft_spi_enabled) && XdspPresent()) {
if ((TasmotaGlobal.i2c_enabled || TasmotaGlobal.spi_enabled || TasmotaGlobal.soft_spi_enabled || TasmotaGlobal.tm1637_enabled) && XdspPresent()) {
switch (function) {
case FUNC_PRE_INIT:
DisplayInitDriver();
Expand Down
15 changes: 14 additions & 1 deletion tasmota/xdsp_interface.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#if defined(USE_I2C) || defined(USE_SPI)
#if defined(USE_I2C) || defined(USE_SPI) || defined(USE_DISPLAY_TM1637)
#ifdef USE_DISPLAY

#ifdef XFUNC_PTR_IN_ROM
Expand All @@ -26,6 +26,8 @@ bool (* const xdsp_func_ptr[])(uint8_t) PROGMEM = { // Display Function Pointe
bool (* const xdsp_func_ptr[])(uint8_t) = { // Display Function Pointers
#endif

#if defined(USE_I2C) || defined(USE_SPI)

#ifdef XDSP_01
&Xdsp01,
#endif
Expand Down Expand Up @@ -82,10 +84,18 @@ bool (* const xdsp_func_ptr[])(uint8_t) = { // Display Function Pointers
&Xdsp14,
#endif

#endif // #if defined(USE_I2C) || defined(USE_SPI)

#ifdef USE_DISPLAY_TM1637

#ifdef XDSP_15
&Xdsp15,
#endif

#endif // USE_DISPLAY_TM1637

#if defined(USE_I2C) || defined(USE_SPI)

#ifdef XDSP_16
&Xdsp16,
#endif
Expand Down Expand Up @@ -153,6 +163,9 @@ bool (* const xdsp_func_ptr[])(uint8_t) = { // Display Function Pointers
#ifdef XDSP_32
&Xdsp32
#endif

#endif // #if defined(USE_I2C) || defined(USE_SPI)

};

const uint8_t xdsp_present = sizeof(xdsp_func_ptr) / sizeof(xdsp_func_ptr[0]); // Number of drivers found
Expand Down

0 comments on commit 75699fe

Please sign in to comment.