CVFD::ShowText: only scroll if necessary

This commit is contained in:
Stefan Seyfried
2014-01-19 17:47:38 +01:00
parent eca8f5459b
commit 581f1bcbf3

View File

@@ -703,13 +703,17 @@ void CVFD::ShowIcon(fp_icon icon, bool show)
void CVFD::ShowText(const char * str) void CVFD::ShowText(const char * str)
{ {
char flags[2] = { FP_FLAG_ALIGN_LEFT, 0 }; char flags[2] = { FP_FLAG_ALIGN_LEFT, 0 };
if (! str) {
printf("CVFD::ShowText: str is NULL!\n");
return;
}
if (g_settings.lcd_scroll) if (g_settings.lcd_scroll && (strlen(str) > g_info.hw_caps->display_xres))
flags[0] |= FP_FLAG_SCROLL_ON | FP_FLAG_SCROLL_SIO | FP_FLAG_SCROLL_DELAY; flags[0] |= FP_FLAG_SCROLL_ON | FP_FLAG_SCROLL_SIO | FP_FLAG_SCROLL_DELAY;
std::string txt = std::string(flags) + str; std::string txt = std::string(flags) + str;
txt = trim(txt); txt = trim(txt);
printf("CVFD::ShowText: [%s]\n", txt.c_str() + 1); printf("CVFD::ShowText: [0x%02x][%s]\n", flags[0], txt.c_str() + 1);
size_t len = txt.length(); size_t len = txt.length();
if (txt == text || len > 255) if (txt == text || len > 255)