From 2b1b106125fef5a0996502cc33fc3036044734b6 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Mon, 24 Dec 2018 23:43:45 +0100 Subject: [PATCH] l4l: fix colors Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/79ea922445128866c071250c206903ef2be79e66 Author: TangoCash Date: 2018-12-24 (Mon, 24 Dec 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/lcd4l.cpp | 27 ++++++++++++--------------- src/driver/lcd4l.h | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) 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);