From 7014e64fed7de0050cb098a052fa9fe914700f60 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sun, 3 Jan 2021 08:08:03 +0100 Subject: [PATCH 1/4] st7789 support for LANBON_L8 --- .../Arduino_ST7789-gemu-1.0/Arduino_ST7789.cpp | 7 +++++-- tasmota/xdsp_12_ST7789.ino | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/lib_display/Arduino_ST7789-gemu-1.0/Arduino_ST7789.cpp b/lib/lib_display/Arduino_ST7789-gemu-1.0/Arduino_ST7789.cpp index 74837242b..47312c50a 100644 --- a/lib/lib_display/Arduino_ST7789-gemu-1.0/Arduino_ST7789.cpp +++ b/lib/lib_display/Arduino_ST7789-gemu-1.0/Arduino_ST7789.cpp @@ -96,8 +96,11 @@ Arduino_ST7789::Arduino_ST7789(int8_t dc, int8_t rst, int8_t cs, int8_t bp) void Arduino_ST7789::DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font) { setRotation(rot); - //invertDisplay(false); - invertDisplay(true); + if (_width==320 || _height==320) { + invertDisplay(false); + } else { + invertDisplay(true); + } //setTextWrap(false); // Allow text to run off edges //cp437(true); setTextFont(font&3); diff --git a/tasmota/xdsp_12_ST7789.ino b/tasmota/xdsp_12_ST7789.ino index cdb9ad167..80cf4d6e5 100644 --- a/tasmota/xdsp_12_ST7789.ino +++ b/tasmota/xdsp_12_ST7789.ino @@ -45,6 +45,10 @@ // currently fixed #define BACKPLANE_PIN 2 + #ifdef USE_LANBON_L8 + #undef BACKPLANE_PIN + #define BACKPLANE_PIN 5 + #endif // USE_LANBON_L8 extern uint8_t *buffer; extern uint8_t color_type; @@ -126,6 +130,12 @@ void ST7789_InitDriver(void) { // start digitizer with fixed adress and pins for esp32 #define SDA_2 23 #define SCL_2 32 + #ifdef USE_LANBON_L8 + #undef SDA_2 + #undef SCL_2 + #define SDA_2 4 + #define SCL_2 0 + #endif // USE_LANBON_L8 Wire1.begin(SDA_2, SCL_2, 400000); Touch_Init(Wire1); #endif // USE_FT5206 From 0d2d2d01f5a23b7a98fa4deb37ca2e7e9af73c94 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sun, 3 Jan 2021 08:08:28 +0100 Subject: [PATCH 2/4] fix var name clash --- tasmota/xdrv_10_scripter.ino | 96 +++++++++--------------------------- 1 file changed, 22 insertions(+), 74 deletions(-) diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 44c4e2b21..0c79e8f65 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -1,7 +1,7 @@ /* xdrv_10_scripter.ino - script support for Tasmota - Copyright (C) 2021 Gerhard Mutz and Theo Arends + Copyright (C) 2020 Gerhard Mutz and Theo Arends This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -209,51 +209,17 @@ void alt_eeprom_readBytes(uint32_t adr, uint32_t len, uint8_t *buf) { -#if defined(LITTLEFS_SCRIPT_SIZE) || (USE_SCRIPT_FATFS==-1) +#if USE_SCRIPT_FATFS==-1 #ifdef ESP32 #include "FS.h" -#ifdef LITTLEFS_SCRIPT_SIZE -#include "SPIFFS.h" -#else #include "FFat.h" -//#include -#endif #else #include #endif FS *fsp; #endif // LITTLEFS_SCRIPT_SIZE - -#ifdef LITTLEFS_SCRIPT_SIZE -void SaveFile(const char *name, const uint8_t *buf, uint32_t len) { - File file = fsp->open(name, "w"); - if (!file) return; - file.write(buf, len); - file.close(); -} - - -uint8_t fs_mounted=0; - -void LoadFile(const char *name, uint8_t *buf, uint32_t len) { - if (!fs_mounted) { -#ifdef ESP32 - if (!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)) { -#else - if (!fsp->begin()) { -#endif - //Serial.println("SPIFFS Mount Failed"); - return; - } - fs_mounted=1; - } - File file = fsp->open(name, "r"); - if (!file) return; - file.read(buf, len); - file.close(); -} -#endif // LITTLEFS_SCRIPT_SIZE +//extern FS *ufsp; // offsets epoch readings by 1.1.2019 00:00:00 to fit into float with second resolution #define EPOCH_OFFSET 1546300800 @@ -266,7 +232,10 @@ enum {SCRIPT_LOGLEVEL=1,SCRIPT_TELEPERIOD,SCRIPT_EVENT_HANDLED}; #if USE_SCRIPT_FATFS>=0 #include #include +#include + #ifdef ESP32 +#include "FFat.h" FS *fsp; #else SDClass *fsp; @@ -996,6 +965,10 @@ char *script; } } +// init file system +//#ifndef USE_UFILESYS +#if 1 + #ifdef USE_SCRIPT_FATFS if (!glob_script_mem.script_sd_found) { @@ -1024,6 +997,10 @@ char *script; } #endif +#else + fsp = ufsp; +#endif + #if SCRIPT_DEBUG>0 ClaimSerial(); SetSerialBaudrate(9600); @@ -1757,6 +1734,7 @@ char *isvar(char *lp, uint8_t *vtype, struct T_INDEX *tind, float *fp, char *sp, fvar = Get_MFilter(index); } } else { + if (ja) continue; fvar = glob_script_mem.fvars[index]; } if (nres) fvar = -fvar; @@ -5319,11 +5297,6 @@ void SaveScript(void) { } #endif // USE_SCRIPT_FATFS -#ifdef LITTLEFS_SCRIPT_SIZE - if (glob_script_mem.flags&1) { - SaveFile("/script.txt", (uint8_t*)glob_script_mem.script_ram, LITTLEFS_SCRIPT_SIZE); - } -#endif // LITTLEFS_SCRIPT_SIZE } void ScriptSaveSettings(void) { @@ -5848,8 +5821,8 @@ void Script_Handle_Hue(String *path) { String x_str = tok_x.getStr(); String y_str = tok_y.getStr(); uint8_t rr,gg,bb; - XyToRgb(x, y, &rr, &gg, &bb); - RgbToHsb(rr, gg, bb, &hue, &sat, nullptr); + LightStateClass::XyToRgb(x, y, &rr, &gg, &bb); + LightStateClass::RgbToHsb(rr, gg, bb, &hue, &sat, nullptr); if (resp) { response += ","; } response += FPSTR(sHUE_LIGHT_RESPONSE_JSON); response.replace("{id", String(device)); @@ -7679,7 +7652,8 @@ bool Xdrv10(uint8_t function) char *sprt; switch (function) { - case FUNC_PRE_INIT: + //case FUNC_PRE_INIT: + case FUNC_INIT: // set defaults to rules memory //bitWrite(Settings.rule_enabled,0,0); glob_script_mem.script_ram = Settings.rules[0]; @@ -7771,8 +7745,6 @@ bool Xdrv10(uint8_t function) #else // flash file system #ifdef ESP32 - //fsp = &SPIFFS; - //if (SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)) { fsp = &FFat; if (FFat.begin(true)) { #else @@ -7782,6 +7754,7 @@ bool Xdrv10(uint8_t function) #endif // ESP #endif // USE_SCRIPT_FATFS>=0 + Script_AddLog_P(LOG_LEVEL_INFO,PSTR("FATFS mount OK!")); //fsp->dateTimeCallback(dateTime); @@ -7810,31 +7783,6 @@ bool Xdrv10(uint8_t function) #endif // USE_SCRIPT_FATFS -#ifdef LITTLEFS_SCRIPT_SIZE - -#ifdef ESP32 - // spiffs on esp32 - fsp = &SPIFFS; - //esp32_part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,ESP_PARTITION_SUBTYPE_DATA_SPIFFS,NULL); - //Serial.printf("address %d - %d - %s\n",esp32_part->address,esp32_part->size, esp32_part->label); -#else - // lfs on esp8266 - fsp = &LittleFS; -#endif //ESP32 - char *script; - script = (char*)calloc(LITTLEFS_SCRIPT_SIZE + 4, 1); - if (!script) break; - LoadFile("/script.txt", (uint8_t*)script, LITTLEFS_SCRIPT_SIZE); - - glob_script_mem.script_ram = script; - glob_script_mem.script_size = LITTLEFS_SCRIPT_SIZE; - script[LITTLEFS_SCRIPT_SIZE-1] = 0; - // use rules storage for permanent vars - glob_script_mem.script_pram = (uint8_t*)Settings.rules[0]; - glob_script_mem.script_pram_size = MAX_SCRIPT_SIZE; - glob_script_mem.flags = 1; -#endif // LITTLEFS_SCRIPT_SIZE - // a valid script MUST start with >D if (glob_script_mem.script_ram[0]!='>' && glob_script_mem.script_ram[1]!='D') { // clr all @@ -7852,8 +7800,8 @@ bool Xdrv10(uint8_t function) } if (bitRead(Settings.rule_enabled, 0)) Init_Scripter(); - break; - case FUNC_INIT: + // break; + //case FUNC_INIT: if (bitRead(Settings.rule_enabled, 0)) { Run_Scripter(">B\n", 3, 0); fast_script = Run_Scripter(">F", -2, 0); From 9d4129501b41d676d604349498309826572c8e8c Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sun, 3 Jan 2021 08:13:16 +0100 Subject: [PATCH 3/4] Update xdrv_10_scripter.ino --- tasmota/xdrv_10_scripter.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 0c79e8f65..f8cb6baf6 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -1,7 +1,7 @@ /* xdrv_10_scripter.ino - script support for Tasmota - Copyright (C) 2020 Gerhard Mutz and Theo Arends + Copyright (C) 2021 Gerhard Mutz and Theo Arends This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 2bc4c9ff036f615d0d16551b5554c593711e695b Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sun, 3 Jan 2021 08:17:24 +0100 Subject: [PATCH 4/4] Update xdrv_10_scripter.ino --- tasmota/xdrv_10_scripter.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index f8cb6baf6..fdcb7e0ba 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -5821,8 +5821,8 @@ void Script_Handle_Hue(String *path) { String x_str = tok_x.getStr(); String y_str = tok_y.getStr(); uint8_t rr,gg,bb; - LightStateClass::XyToRgb(x, y, &rr, &gg, &bb); - LightStateClass::RgbToHsb(rr, gg, bb, &hue, &sat, nullptr); + XyToRgb(x, y, &rr, &gg, &bb); + RgbToHsb(rr, gg, bb, &hue, &sat, nullptr); if (resp) { response += ","; } response += FPSTR(sHUE_LIGHT_RESPONSE_JSON); response.replace("{id", String(device));