From 287b3b97f11270bd91f35752ec561a5beb3f22a0 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 1 Jan 2020 15:13:58 +0100 Subject: [PATCH] Fix some display issues - Fix LCD line and column positioning (#7387) - Fix Display handling of hexadecimal escape characters (#7387) --- RELEASENOTES.md | 2 ++ tasmota/CHANGELOG.md | 2 ++ tasmota/xdrv_13_display.ino | 19 +++++++++++++------ tasmota/xdsp_01_lcd.ino | 4 ++++ tools/decode-status.py | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 30f05d21e..c5bba2957 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -58,6 +58,8 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Fix Sonoff Bridge, Sc, L1, iFan03 and CSE7766 serial interface to forced speed, config and disable logging - Fix commands ``Display`` and ``Counter`` from overruling command processing (#7322) - Fix ``White`` added to light status (#7142) +- Fix LCD line and column positioning (#7387) +- Fix Display handling of hexadecimal escape characters (#7387) - Add command ``SetOption79 0/1`` to enable reset of counters at teleperiod time by Andre Thomas (#7355) - Add SerialConfig to ``Status 1`` - Add WifiPower to ``Status 5`` diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 99aca3e2c..15a381d40 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -3,6 +3,8 @@ ### 8.1.0.2 20191230 - Add support for ``AdcParam`` parameters to control ADC0 Current Transformer Apparent Power formula by Jodi Dillon (#7100) +- Fix LCD line and column positioning (#7387) +- Fix Display handling of hexadecimal escape characters (#7387) ### 8.1.0.1 20191225 diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index 6dc29b6f4..117725024 100644 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -328,7 +328,8 @@ uint8_t index=0; #define ESCAPE_CHAR '~' // decode text escapes, 1 hexbyte assumed -void decode_te(char *line) { +uint32_t decode_te(char *line) { + uint32_t skip = 0; char sbuf[3],*cp; while (*line) { if (*line==ESCAPE_CHAR) { @@ -336,11 +337,12 @@ void decode_te(char *line) { if (*cp!=0 && *cp==ESCAPE_CHAR) { // escape escape, discard one memmove(cp,cp+1,strlen(cp)); + skip++; } else { // escape HH if (strlen(cp)<2) { // illegal lenght, ignore - return; + return skip; } // take 2 hex chars sbuf[0]=*(cp); @@ -349,10 +351,12 @@ void decode_te(char *line) { *line=strtol(sbuf,0,16); // must shift string 2 bytes shift zero also memmove(cp,cp+2,strlen(cp)-1); + skip += 2; } } line++; } + return skip; } /*-------------------------------------------------------------------------------------------*/ @@ -829,10 +833,13 @@ void DisplayText(void) } exit: // now draw buffer - decode_te(linebuf); + dp -= decode_te(linebuf); if ((uint32_t)dp - (uint32_t)linebuf) { - if (!fill) *dp = 0; - else linebuf[abs(fill)] = 0; + if (!fill) { + *dp = 0; + } else { + linebuf[abs(fill)] = 0; + } if (fill<0) { // right align alignright(linebuf); @@ -1276,7 +1283,7 @@ void DisplaySetPower(void) { disp_power = bitRead(XdrvMailbox.index, disp_device -1); -AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DSP: Power %d"), disp_power); +//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DSP: Power %d"), disp_power); if (Settings.display_model) { if (!renderer) { diff --git a/tasmota/xdsp_01_lcd.ino b/tasmota/xdsp_01_lcd.ino index 3fb17b9d4..4a700488a 100644 --- a/tasmota/xdsp_01_lcd.ino +++ b/tasmota/xdsp_01_lcd.ino @@ -85,6 +85,10 @@ void LcdInitDriver(void) void LcdDrawStringAt(void) { + if (dsp_flag) { // Supply Line and Column starting with Line 1 and Column 1 + dsp_x--; + dsp_y--; + } lcd->setCursor(dsp_x, dsp_y); lcd->print(dsp_str); } diff --git a/tools/decode-status.py b/tools/decode-status.py index e807b60fb..01319d9e4 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -3,7 +3,7 @@ """ decode-status.py - decode status for Tasmota - Copyright (C) 2019 Theo Arends + Copyright (C) 2020 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