diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index a913005dd..068beffad 100644 --- a/src/driver/lcd4l.cpp +++ b/src/driver/lcd4l.cpp @@ -290,11 +290,10 @@ 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); + std::string fgcolor = hexStr(t.infobar_Text_red) + + hexStr(t.infobar_Text_green) + + hexStr(t.infobar_Text_blue) + + hexStr(t.infobar_Text_alpha); if (m_fgcolor.compare(fgcolor)) { @@ -304,10 +303,10 @@ 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); + std::string bgcolor = hexStr(t.infobar_red) + + hexStr(t.infobar_green) + + hexStr(t.infobar_blue) + + hexStr(t.infobar_alpha); if (m_bgcolor.compare(bgcolor)) { @@ -1025,11 +1024,9 @@ void CLCD4l::strReplace(std::string &orig, const std::string &fstr, const std::s } } -std::string CLCD4l::hexStr(unsigned char* data) +std::string CLCD4l::hexStr(unsigned char data) { - std::stringstream ss; - ss << std::hex; - for(int i=0; i<1; ++i) - ss << std::setw(2) << std::setfill('0') << (int)data[i]; - return ss.str(); + char hexstr[3]; + snprintf(hexstr, sizeof hexstr, "%02x", (int)data * 255 / 100); + return std::string(hexstr); } diff --git a/src/driver/lcd4l.h b/src/driver/lcd4l.h index 364933be7..76a1c6dc3 100644 --- a/src/driver/lcd4l.h +++ b/src/driver/lcd4l.h @@ -67,7 +67,7 @@ class CLCD4l uint64_t GetParseID(); bool CompareParseID(uint64_t &i_ParseID); - std::string hexStr(unsigned char* data); + std::string hexStr(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);