From 633489a91e562019e6f61f86950f58e06cc584fb Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 22 Mar 2021 12:34:52 +0100 Subject: [PATCH] Add commands ``DisplayType`` and ``DisplayInvert`` Add commands ``DisplayType`` to select sub-modules where implemented and ``DisplayInvert`` to select inverted display where implemented --- CHANGELOG.md | 1 + RELEASENOTES.md | 4 + tasmota/settings.h | 10 +- tasmota/xdrv_13_display.ino | 413 +++++++++++++++++------------------- tasmota/xdsp_04_ili9341.ino | 12 +- 5 files changed, 206 insertions(+), 234 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d840a1395..dbc59b21b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ## [9.3.1.2] ### Added - Commands ``MqttKeepAlive 1..100`` to set Mqtt Keep Alive timer (default 30) and ``MqttTimeout 1..100`` to set Mqtt Socket Timeout (default 4) (#5341) +- Commands ``DisplayType`` to select sub-modules where implemented and ``DisplayInvert`` to select inverted display where implemented - Support for TM1638 seven segment display by Ajith Vasudevan (#11031) ### Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 19e7f50c2..b94f603c8 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -82,16 +82,20 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota ### Added - Commands ``MqttKeepAlive 1..100`` to set Mqtt Keep Alive timer (default 30) and ``MqttTimeout 1..100`` to set Mqtt Socket Timeout (default 4) [#5341](https://github.com/arendst/Tasmota/issues/5341) - Command ``Sensor80 1 <0..7>`` to control MFRC522 RFID antenna gain from 18dB (0) to 48dB (7) [#11073](https://github.com/arendst/Tasmota/issues/11073) +- Commands ``DisplayType`` to select sub-modules where implemented and ``DisplayInvert`` to select inverted display where implemented - Support for SML VBUS [#11125](https://github.com/arendst/Tasmota/issues/11125) - Support for NEC and OPTOMA LCD/DLP Projector serial power control by Jan BubĂ­k [#11145](https://github.com/arendst/Tasmota/issues/11145) - Support for XPT2046 touch screen digitizer on ILI9341 display by nonix [#11159](https://github.com/arendst/Tasmota/issues/11159) - Support for zigbee lumi.sensor_wleak [#11200](https://github.com/arendst/Tasmota/issues/11200) - Support for CSE7761 energy monitor as used in ESP32 based Sonoff Dual R3 Pow [#10793](https://github.com/arendst/Tasmota/issues/10793) - Support for TM1638 seven segment display by Ajith Vasudevan [#11031](https://github.com/arendst/Tasmota/issues/11031) +- Support for MPU6886 on primary or secondary I2C bus - Allow MCP230xx pinmode from output to input [#11104](https://github.com/arendst/Tasmota/issues/11104) - Berry improvements [#11163](https://github.com/arendst/Tasmota/issues/11163) - Extent compile time SetOptions support [#11204](https://github.com/arendst/Tasmota/issues/11204) - ESP32 Extent BLE [#11212](https://github.com/arendst/Tasmota/issues/11212) +- ESP32 support for WS2812 hardware driver via RMT or I2S +- ESP32 support for secondary I2C controller ### Changed - TasmotaSerial library from v3.2.0 to v3.3.0 diff --git a/tasmota/settings.h b/tasmota/settings.h index 05ab83922..804f47835 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -149,7 +149,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t mqtt_state_retain : 1; // bit 7 (v9.3.0.1) - CMND_STATERETAIN uint32_t mqtt_info_retain : 1; // bit 8 (v9.3.0.1) - CMND_INFORETAIN uint32_t wiegand_hex_output : 1; // bit 9 (v9.3.1.1) - SetOption123 - (Wiegand) switch tag number output to hex format (1) - uint32_t wiegand_keypad_to_tag : 1; // bit 10 (v9.3.1.1) - SetOption124 - (Wiegand) send key pad stroke as single char (0) or one tag (ending char #) (1) + uint32_t wiegand_keypad_to_tag : 1; // bit 10 (v9.3.1.1) - SetOption124 - (Wiegand) send key pad stroke as single char (0) or one tag (ending char #) (1) uint32_t zigbee_hide_bridge_topic : 1; // bit 11 (v9.3.1.1) - SetOption125 - (Zigbee) Hide bridge topic from zigbee topic (use with SetOption89) (1) uint32_t spare12 : 1; // bit 12 uint32_t spare13 : 1; // bit 13 @@ -330,12 +330,12 @@ typedef struct { typedef union { uint8_t data; struct { - uint8_t ilimode : 3; - uint8_t Invert : 1; - uint8_t spare2 : 1; - uint8_t spare3 : 1; + uint8_t type : 3; + uint8_t invert : 1; uint8_t spare4 : 1; uint8_t spare5 : 1; + uint8_t spare6 : 1; + uint8_t spare7 : 1; }; } DisplayOptions; diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index a8f50d735..e87e34100 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -54,22 +54,24 @@ const uint8_t DISPLAY_LOG_ROWS = 32; // Number of lines in display log #define D_CMND_DISP_DIMMER "Dimmer" #define D_CMND_DISP_MODE "Mode" #define D_CMND_DISP_MODEL "Model" +#define D_CMND_DISP_TYPE "Type" #define D_CMND_DISP_REFRESH "Refresh" #define D_CMND_DISP_ROWS "Rows" #define D_CMND_DISP_SIZE "Size" #define D_CMND_DISP_FONT "Font" #define D_CMND_DISP_ROTATE "Rotate" -#define D_CMND_DISP_TEXT "Text" +#define D_CMND_DISP_INVERT "Invert" #define D_CMND_DISP_WIDTH "Width" #define D_CMND_DISP_HEIGHT "Height" #define D_CMND_DISP_BLINKRATE "Blinkrate" #define D_CMND_DISP_BATCH "Batch" +#define D_CMND_DISP_TEXT "Text" + #define D_CMND_DISP_CLEAR "Clear" #define D_CMND_DISP_NUMBER "Number" #define D_CMND_DISP_FLOAT "Float" -#define D_CMND_DISP_NUMBERNC "NumberNC" // NC - "No Clear" -#define D_CMND_DISP_FLOATNC "FloatNC" // NC - "No Clear" -#define D_CMND_DISP_BRIGHTNESS "Brightness" +#define D_CMND_DISP_NUMBERNC "NumberNC" // NC - "No Clear" +#define D_CMND_DISP_FLOATNC "FloatNC" // NC - "No Clear" #define D_CMND_DISP_RAW "Raw" #define D_CMND_DISP_LEVEL "Level" #define D_CMND_DISP_SEVENSEG_TEXT "SevensegText" @@ -78,9 +80,6 @@ const uint8_t DISPLAY_LOG_ROWS = 32; // Number of lines in display log #define D_CMND_DISP_CLOCK "Clock" #define D_CMND_DISP_TEXTNC "TextNC" // NC - "No Clear" #define D_CMND_DISP_SCROLLTEXT "ScrollText" -#define D_CMND_DISP_ILIMODE "ILIMode" -#define D_CMND_DISP_ILIINVERT "Invert" - enum XdspFunctions { FUNC_DISPLAY_INIT_DRIVER, FUNC_DISPLAY_INIT, FUNC_DISPLAY_EVERY_50_MSECOND, FUNC_DISPLAY_EVERY_SECOND, FUNC_DISPLAY_MODEL, FUNC_DISPLAY_MODE, FUNC_DISPLAY_POWER, @@ -101,29 +100,27 @@ enum XdspFunctions { FUNC_DISPLAY_INIT_DRIVER, FUNC_DISPLAY_INIT, FUNC_DISPLAY_E enum DisplayInitModes { DISPLAY_INIT_MODE, DISPLAY_INIT_PARTIAL, DISPLAY_INIT_FULL }; const char kDisplayCommands[] PROGMEM = D_PRFX_DISPLAY "|" // Prefix - "|" D_CMND_DISP_MODEL "|" D_CMND_DISP_WIDTH "|" D_CMND_DISP_HEIGHT "|" D_CMND_DISP_MODE "|" D_CMND_DISP_REFRESH "|" - D_CMND_DISP_DIMMER "|" D_CMND_DISP_COLS "|" D_CMND_DISP_ROWS "|" D_CMND_DISP_SIZE "|" D_CMND_DISP_FONT "|" - D_CMND_DISP_ROTATE "|" D_CMND_DISP_TEXT "|" D_CMND_DISP_ADDRESS "|" D_CMND_DISP_BLINKRATE "|" + "|" D_CMND_DISP_MODEL "|" D_CMND_DISP_TYPE "|" D_CMND_DISP_WIDTH "|" D_CMND_DISP_HEIGHT "|" D_CMND_DISP_MODE "|" + D_CMND_DISP_INVERT "|" D_CMND_DISP_REFRESH "|" D_CMND_DISP_DIMMER "|" D_CMND_DISP_COLS "|" D_CMND_DISP_ROWS "|" + D_CMND_DISP_SIZE "|" D_CMND_DISP_FONT "|" D_CMND_DISP_ROTATE "|" D_CMND_DISP_TEXT "|" D_CMND_DISP_ADDRESS "|" D_CMND_DISP_BLINKRATE "|" #ifdef USE_UFILESYS D_CMND_DISP_BATCH "|" #endif D_CMND_DISP_CLEAR "|" D_CMND_DISP_NUMBER "|" D_CMND_DISP_FLOAT "|" D_CMND_DISP_NUMBERNC "|" D_CMND_DISP_FLOATNC "|" D_CMND_DISP_RAW "|" D_CMND_DISP_LEVEL "|" D_CMND_DISP_SEVENSEG_TEXT "|" D_CMND_DISP_SEVENSEG_TEXTNC "|" - D_CMND_DISP_SCROLLDELAY "|" D_CMND_DISP_CLOCK "|" D_CMND_DISP_TEXTNC "|" - D_CMND_DISP_SCROLLTEXT "|" D_CMND_DISP_ILIMODE "|" D_CMND_DISP_ILIINVERT + D_CMND_DISP_SCROLLDELAY "|" D_CMND_DISP_CLOCK "|" D_CMND_DISP_TEXTNC "|" D_CMND_DISP_SCROLLTEXT ; void (* const DisplayCommand[])(void) PROGMEM = { - &CmndDisplay, &CmndDisplayModel, &CmndDisplayWidth, &CmndDisplayHeight, &CmndDisplayMode, &CmndDisplayRefresh, - &CmndDisplayDimmer, &CmndDisplayColumns, &CmndDisplayRows, &CmndDisplaySize, &CmndDisplayFont, - &CmndDisplayRotate, &CmndDisplayText, &CmndDisplayAddress, &CmndDisplayBlinkrate, + &CmndDisplay, &CmndDisplayModel, &CmndDisplayType, &CmndDisplayWidth, &CmndDisplayHeight, &CmndDisplayMode, + &CmndDisplayInvert, &CmndDisplayRefresh, &CmndDisplayDimmer, &CmndDisplayColumns, &CmndDisplayRows, + &CmndDisplaySize, &CmndDisplayFont, &CmndDisplayRotate, &CmndDisplayText, &CmndDisplayAddress, &CmndDisplayBlinkrate, #ifdef USE_UFILESYS &CmndDisplayBatch, #endif &CmndDisplayClear, &CmndDisplayNumber, &CmndDisplayFloat, &CmndDisplayNumberNC, &CmndDisplayFloatNC, &CmndDisplayRaw, &CmndDisplayLevel, &CmndDisplaySevensegText, &CmndDisplaySevensegTextNC, - &CmndDisplayScrollDelay, &CmndDisplayClock, &CmndDisplayTextNC, - &CmndDisplayScrollText, &CmndDisplayILIMOde , &CmndDisplayILIInvert + &CmndDisplayScrollDelay, &CmndDisplayClock, &CmndDisplayTextNC, &CmndDisplayScrollText }; char *dsp_str; @@ -1637,18 +1634,16 @@ void DisplaySetPower(void) * Commands \*********************************************************************************************/ -void CmndDisplay(void) -{ - Response_P(PSTR("{\"" D_PRFX_DISPLAY "\":{\"" D_CMND_DISP_MODEL "\":%d,\"" D_CMND_DISP_WIDTH "\":%d,\"" D_CMND_DISP_HEIGHT "\":%d,\"" +void CmndDisplay(void) { + Response_P(PSTR("{\"" D_PRFX_DISPLAY "\":{\"" D_CMND_DISP_MODEL "\":%d,\"" D_CMND_DISP_TYPE "\":%d,\"" D_CMND_DISP_WIDTH "\":%d,\"" D_CMND_DISP_HEIGHT "\":%d,\"" D_CMND_DISP_MODE "\":%d,\"" D_CMND_DISP_DIMMER "\":%d,\"" D_CMND_DISP_SIZE "\":%d,\"" D_CMND_DISP_FONT "\":%d,\"" - D_CMND_DISP_ROTATE "\":%d,\"" D_CMND_DISP_REFRESH "\":%d,\"" D_CMND_DISP_COLS "\":[%d,%d],\"" D_CMND_DISP_ROWS "\":%d}}"), - Settings.display_model, Settings.display_width, Settings.display_height, + D_CMND_DISP_ROTATE "\":%d,\"" D_CMND_DISP_INVERT "\":%d,\"" D_CMND_DISP_REFRESH "\":%d,\"" D_CMND_DISP_COLS "\":[%d,%d],\"" D_CMND_DISP_ROWS "\":%d}}"), + Settings.display_model, Settings.display_options.type, Settings.display_width, Settings.display_height, Settings.display_mode, changeUIntScale(Settings.display_dimmer, 0, 15, 0, 100), Settings.display_size, Settings.display_font, - Settings.display_rotate, Settings.display_refresh, Settings.display_cols[0], Settings.display_cols[1], Settings.display_rows); + Settings.display_rotate, Settings.display_options.invert, Settings.display_refresh, Settings.display_cols[0], Settings.display_cols[1], Settings.display_rows); } -void CmndDisplayModel(void) -{ +void CmndDisplayModel(void) { if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < DISPLAY_MAX_DRIVERS)) { uint32_t last_display_model = Settings.display_model; Settings.display_model = XdrvMailbox.payload; @@ -1661,8 +1656,15 @@ void CmndDisplayModel(void) ResponseCmndNumber(Settings.display_model); } -void CmndDisplayWidth(void) -{ +void CmndDisplayType(void) { + if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 7)) { + Settings.display_options.type = XdrvMailbox.payload; + TasmotaGlobal.restart_flag = 2; + } + ResponseCmndNumber(Settings.display_options.type); +} + +void CmndDisplayWidth(void) { if (XdrvMailbox.payload > 0) { if (XdrvMailbox.payload != Settings.display_width) { Settings.display_width = XdrvMailbox.payload; @@ -1672,8 +1674,7 @@ void CmndDisplayWidth(void) ResponseCmndNumber(Settings.display_width); } -void CmndDisplayHeight(void) -{ +void CmndDisplayHeight(void) { if (XdrvMailbox.payload > 0) { if (XdrvMailbox.payload != Settings.display_height) { Settings.display_height = XdrvMailbox.payload; @@ -1683,8 +1684,7 @@ void CmndDisplayHeight(void) ResponseCmndNumber(Settings.display_height); } -void CmndDisplayMode(void) -{ +void CmndDisplayMode(void) { #ifdef USE_DISPLAY_MODES1TO5 /* Matrix / 7-segment LCD / Oled TFT * 1 = Text up and time Time @@ -1732,138 +1732,7 @@ void CmndDisplayDimmer(void) { ResponseCmndNumber(changeUIntScale(Settings.display_dimmer, 0, 15, 0, 100)); } -void CmndDisplayBlinkrate(void) -{ - if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 3)) { - - if (!renderer) - XdspCall(FUNC_DISPLAY_BLINKRATE); - } - ResponseCmndNumber(XdrvMailbox.payload); -} - - -#ifdef USE_UFILESYS -void CmndDisplayBatch(void) { - if (XdrvMailbox.data_len > 0) { - if (!Settings.display_mode) { - Display_Text_From_File(XdrvMailbox.data); - } - ResponseCmndChar(XdrvMailbox.data); - } -} -#endif - - -void CmndDisplayClear(void) -{ - if (!renderer) - XdspCall(FUNC_DISPLAY_CLEAR); - ResponseCmndChar(XdrvMailbox.data); -} - -void CmndDisplayNumber(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_NUMBER); - } - ResponseCmndChar(XdrvMailbox.data); -} - -void CmndDisplayFloat(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_FLOAT); - } - ResponseCmndChar(XdrvMailbox.data); -} - -void CmndDisplayNumberNC(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_NUMBERNC); - } - ResponseCmndChar(XdrvMailbox.data); -} - -void CmndDisplayFloatNC(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_FLOATNC); - } - ResponseCmndChar(XdrvMailbox.data); -} - -void CmndDisplayRaw(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_RAW); - } - ResponseCmndChar(XdrvMailbox.data); -} - -void CmndDisplayLevel(void) -{ - bool result = false; - if (!renderer) { - result = XdspCall(FUNC_DISPLAY_LEVEL); - } - if(result) ResponseCmndNumber(XdrvMailbox.payload); -} - -void CmndDisplaySevensegText(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_SEVENSEG_TEXT); - } - ResponseCmndChar(XdrvMailbox.data); -} - -void CmndDisplayTextNC(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_SEVENSEG_TEXTNC); - } - ResponseCmndChar(XdrvMailbox.data); -} - -void CmndDisplaySevensegTextNC(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_SEVENSEG_TEXTNC); - } - ResponseCmndChar(XdrvMailbox.data); -} - -void CmndDisplayScrollDelay(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_SCROLLDELAY); - } - ResponseCmndNumber(XdrvMailbox.payload); -} - -void CmndDisplayClock(void) -{ - if (!renderer) { - XdspCall(FUNC_DISPLAY_CLOCK); - } - ResponseCmndNumber(XdrvMailbox.payload); -} - - -void CmndDisplayScrollText(void) -{ - bool result = false; - if (!renderer) { - result = XdspCall(FUNC_DISPLAY_SCROLLTEXT); - } - if(result) ResponseCmndChar(XdrvMailbox.data); -} - - -void CmndDisplaySize(void) -{ +void CmndDisplaySize(void) { if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 4)) { Settings.display_size = XdrvMailbox.payload; if (renderer) renderer->setTextSize(Settings.display_size); @@ -1872,8 +1741,7 @@ void CmndDisplaySize(void) ResponseCmndNumber(Settings.display_size); } -void CmndDisplayFont(void) -{ +void CmndDisplayFont(void) { if ((XdrvMailbox.payload >=0) && (XdrvMailbox.payload <= 4)) { Settings.display_font = XdrvMailbox.payload; if (renderer) renderer->setTextFont(Settings.display_font); @@ -1882,27 +1750,7 @@ void CmndDisplayFont(void) ResponseCmndNumber(Settings.display_font); } - -void CmndDisplayILIMOde(void) -{ - if ((XdrvMailbox.payload >= 1) && (XdrvMailbox.payload <= 7)) { - Settings.display_options.ilimode = XdrvMailbox.payload; - TasmotaGlobal.restart_flag = 2; - } - ResponseCmndNumber(Settings.display_options.ilimode); -} - -void CmndDisplayILIInvert(void) -{ - if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) { - Settings.display_options.Invert = XdrvMailbox.payload; - if (renderer) renderer->invertDisplay(Settings.display_options.Invert); - } - ResponseCmndNumber(Settings.display_options.Invert); -} - -void CmndDisplayRotate(void) -{ +void CmndDisplayRotate(void) { if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 4)) { if ((Settings.display_rotate) != XdrvMailbox.payload) { /* @@ -1926,8 +1774,77 @@ void CmndDisplayRotate(void) ResponseCmndNumber(Settings.display_rotate); } -void CmndDisplayText(void) -{ +void CmndDisplayInvert(void) { + if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) { + Settings.display_options.invert = XdrvMailbox.payload; + if (renderer) renderer->invertDisplay(Settings.display_options.invert); + } + ResponseCmndNumber(Settings.display_options.invert); +} + +void CmndDisplayRefresh(void) { + if ((XdrvMailbox.payload >= 1) && (XdrvMailbox.payload <= 7)) { + Settings.display_refresh = XdrvMailbox.payload; + } + ResponseCmndNumber(Settings.display_refresh); +} + +void CmndDisplayColumns(void) { + if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 2)) { + if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= DISPLAY_MAX_COLS)) { + Settings.display_cols[XdrvMailbox.index -1] = XdrvMailbox.payload; +#ifdef USE_DISPLAY_MODES1TO5 + if (1 == XdrvMailbox.index) { + DisplayLogBufferInit(); + DisplayReAllocScreenBuffer(); + } +#endif // USE_DISPLAY_MODES1TO5 + } + ResponseCmndIdxNumber(Settings.display_cols[XdrvMailbox.index -1]); + } +} + +void CmndDisplayRows(void) { + if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= DISPLAY_MAX_ROWS)) { + Settings.display_rows = XdrvMailbox.payload; +#ifdef USE_DISPLAY_MODES1TO5 + DisplayLogBufferInit(); + DisplayReAllocScreenBuffer(); +#endif // USE_DISPLAY_MODES1TO5 + } + ResponseCmndNumber(Settings.display_rows); +} + +void CmndDisplayAddress(void) { + if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 8)) { + if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 255)) { + Settings.display_address[XdrvMailbox.index -1] = XdrvMailbox.payload; + } + ResponseCmndIdxNumber(Settings.display_address[XdrvMailbox.index -1]); + } +} + +void CmndDisplayBlinkrate(void) { + if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 3)) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_BLINKRATE); + } + } + ResponseCmndNumber(XdrvMailbox.payload); +} + +#ifdef USE_UFILESYS +void CmndDisplayBatch(void) { + if (XdrvMailbox.data_len > 0) { + if (!Settings.display_mode) { + Display_Text_From_File(XdrvMailbox.data); + } + ResponseCmndChar(XdrvMailbox.data); + } +} +#endif + +void CmndDisplayText(void) { if (disp_device && XdrvMailbox.data_len > 0) { #ifndef USE_DISPLAY_MODES1TO5 DisplayText(); @@ -1944,50 +1861,100 @@ void CmndDisplayText(void) } } -void CmndDisplayAddress(void) -{ - if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 8)) { - if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 255)) { - Settings.display_address[XdrvMailbox.index -1] = XdrvMailbox.payload; - } - ResponseCmndIdxNumber(Settings.display_address[XdrvMailbox.index -1]); - } +/*********************************************************************************************\ + * Currently 7-segement specific - should have been handled by (extended) DisplayText command +\*********************************************************************************************/ + +void CmndDisplayClear(void) { + if (!renderer) + XdspCall(FUNC_DISPLAY_CLEAR); + ResponseCmndChar(XdrvMailbox.data); } -void CmndDisplayRefresh(void) -{ - if ((XdrvMailbox.payload >= 1) && (XdrvMailbox.payload <= 7)) { - Settings.display_refresh = XdrvMailbox.payload; +void CmndDisplayNumber(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_NUMBER); } - ResponseCmndNumber(Settings.display_refresh); + ResponseCmndChar(XdrvMailbox.data); } -void CmndDisplayColumns(void) -{ - if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 2)) { - if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= DISPLAY_MAX_COLS)) { - Settings.display_cols[XdrvMailbox.index -1] = XdrvMailbox.payload; -#ifdef USE_DISPLAY_MODES1TO5 - if (1 == XdrvMailbox.index) { - DisplayLogBufferInit(); - DisplayReAllocScreenBuffer(); - } -#endif // USE_DISPLAY_MODES1TO5 - } - ResponseCmndIdxNumber(Settings.display_cols[XdrvMailbox.index -1]); +void CmndDisplayFloat(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_FLOAT); } + ResponseCmndChar(XdrvMailbox.data); } -void CmndDisplayRows(void) -{ - if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= DISPLAY_MAX_ROWS)) { - Settings.display_rows = XdrvMailbox.payload; -#ifdef USE_DISPLAY_MODES1TO5 - DisplayLogBufferInit(); - DisplayReAllocScreenBuffer(); -#endif // USE_DISPLAY_MODES1TO5 +void CmndDisplayNumberNC(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_NUMBERNC); } - ResponseCmndNumber(Settings.display_rows); + ResponseCmndChar(XdrvMailbox.data); +} + +void CmndDisplayFloatNC(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_FLOATNC); + } + ResponseCmndChar(XdrvMailbox.data); +} + +void CmndDisplayRaw(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_RAW); + } + ResponseCmndChar(XdrvMailbox.data); +} + +void CmndDisplayLevel(void) { + bool result = false; + if (!renderer) { + result = XdspCall(FUNC_DISPLAY_LEVEL); + } + if(result) ResponseCmndNumber(XdrvMailbox.payload); +} + +void CmndDisplaySevensegText(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_SEVENSEG_TEXT); + } + ResponseCmndChar(XdrvMailbox.data); +} + +void CmndDisplayTextNC(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_SEVENSEG_TEXTNC); + } + ResponseCmndChar(XdrvMailbox.data); +} + +void CmndDisplaySevensegTextNC(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_SEVENSEG_TEXTNC); + } + ResponseCmndChar(XdrvMailbox.data); +} + +void CmndDisplayScrollDelay(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_SCROLLDELAY); + } + ResponseCmndNumber(XdrvMailbox.payload); +} + +void CmndDisplayClock(void) { + if (!renderer) { + XdspCall(FUNC_DISPLAY_CLOCK); + } + ResponseCmndNumber(XdrvMailbox.payload); +} + +void CmndDisplayScrollText(void) { + bool result = false; + if (!renderer) { + result = XdspCall(FUNC_DISPLAY_SCROLLTEXT); + } + if(result) ResponseCmndChar(XdrvMailbox.data); } /*********************************************************************************************\ diff --git a/tasmota/xdsp_04_ili9341.ino b/tasmota/xdsp_04_ili9341.ino index 737b9376f..60b2dd646 100644 --- a/tasmota/xdsp_04_ili9341.ino +++ b/tasmota/xdsp_04_ili9341.ino @@ -42,7 +42,7 @@ uint8_t ili9342_ctouch_counter = 0; bool tft_init_done = false; -//Settings.display_options.ilimode = ILIMODE_9341; +//Settings.display_options.type = ILIMODE_9341; /*********************************************************************************************/ @@ -65,8 +65,8 @@ void ILI9341_InitDriver() // disable screen buffer buffer = NULL; - if (!Settings.display_options.ilimode || (Settings.display_options.ilimode >= ILIMODE_MAX)) { - Settings.display_options.ilimode = ILIMODE_9341; + if (!Settings.display_options.type || (Settings.display_options.type >= ILIMODE_MAX)) { + Settings.display_options.type = ILIMODE_9341; } // default colors @@ -77,11 +77,11 @@ void ILI9341_InitDriver() if (TasmotaGlobal.soft_spi_enabled) { // Init renderer, may use hardware spi, however we use SSPI defintion because SD card uses SPI definition (2 spi busses) if (PinUsed(GPIO_SSPI_MOSI) && PinUsed(GPIO_SSPI_MISO) && PinUsed(GPIO_SSPI_SCLK)) { - ili9341_2 = new ILI9341_2(Pin(GPIO_ILI9341_CS), Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_MISO), Pin(GPIO_SSPI_SCLK), Pin(GPIO_OLED_RESET), Pin(GPIO_ILI9341_DC), Pin(GPIO_BACKLIGHT), 2, Settings.display_options.ilimode & 3); + ili9341_2 = new ILI9341_2(Pin(GPIO_ILI9341_CS), Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_MISO), Pin(GPIO_SSPI_SCLK), Pin(GPIO_OLED_RESET), Pin(GPIO_ILI9341_DC), Pin(GPIO_BACKLIGHT), 2, Settings.display_options.type & 3); } } else if (TasmotaGlobal.spi_enabled) { if (PinUsed(GPIO_ILI9341_DC)) { - ili9341_2 = new ILI9341_2(Pin(GPIO_ILI9341_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_CLK), Pin(GPIO_OLED_RESET), Pin(GPIO_ILI9341_DC), Pin(GPIO_BACKLIGHT), 1, Settings.display_options.ilimode & 3); + ili9341_2 = new ILI9341_2(Pin(GPIO_ILI9341_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_CLK), Pin(GPIO_OLED_RESET), Pin(GPIO_ILI9341_DC), Pin(GPIO_BACKLIGHT), 1, Settings.display_options.type & 3); } } @@ -101,7 +101,7 @@ void ILI9341_InitDriver() renderer->setTextFont(2); renderer->setTextSize(1); renderer->setTextColor(ILI9341_WHITE, ILI9341_BLACK); - renderer->DrawStringAt(50, (Settings.display_height/2)-12, (Settings.display_options.ilimode & 3)==ILIMODE_9341?"ILI9341 TFT!":"ILI9342 TFT!", ILI9341_WHITE, 0); + renderer->DrawStringAt(50, (Settings.display_height/2)-12, (Settings.display_options.type & 3)==ILIMODE_9341?"ILI9341 TFT!":"ILI9342 TFT!", ILI9341_WHITE, 0); delay(1000); #endif // SHOW_SPLASH