diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index 068beffad..0395feafd 100644 --- a/src/driver/lcd4l.cpp +++ b/src/driver/lcd4l.cpp @@ -293,7 +293,7 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) std::string fgcolor = hexStr(t.infobar_Text_red) + hexStr(t.infobar_Text_green) + hexStr(t.infobar_Text_blue) - + hexStr(t.infobar_Text_alpha); + + hexStrA2A(t.infobar_Text_alpha); if (m_fgcolor.compare(fgcolor)) { @@ -306,7 +306,7 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) std::string bgcolor = hexStr(t.infobar_red) + hexStr(t.infobar_green) + hexStr(t.infobar_blue) - + hexStr(t.infobar_alpha); + + hexStrA2A(t.infobar_alpha); if (m_bgcolor.compare(bgcolor)) { @@ -1030,3 +1030,18 @@ std::string CLCD4l::hexStr(unsigned char data) snprintf(hexstr, sizeof hexstr, "%02x", (int)data * 255 / 100); return std::string(hexstr); } + +std::string CLCD4l::hexStrA2A(unsigned char data) +{ + char hexstr[3]; + int a = 100 - data; + int ret = a * 0xFF / 100; + + if(data == 0) + ret = 0xFF; + else if(data >= 100) + ret = 0x00; + + snprintf(hexstr, sizeof hexstr, "%02x", ret); + return std::string(hexstr); +} diff --git a/src/driver/lcd4l.h b/src/driver/lcd4l.h index 76a1c6dc3..696b0f40c 100644 --- a/src/driver/lcd4l.h +++ b/src/driver/lcd4l.h @@ -68,6 +68,7 @@ class CLCD4l bool CompareParseID(uint64_t &i_ParseID); std::string hexStr(unsigned char data); + std::string hexStrA2A(unsigned char data); void strReplace(std::string &orig, const std::string &fstr, const std::string &rstr); bool WriteFile(const char *file, std::string content = "", bool convert = false);