From 14bd1b624448ff0255bedfdce824b78de4263ff9 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Fri, 17 Jan 2014 14:23:02 +0400 Subject: [PATCH] driver/vfd.cpp: add support to switch scroll on/off Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/eba370d876269164570498141a186d3a65682b8f Author: [CST] Focus Date: 2014-01-17 (Fri, 17 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/vfd.cpp | 33 +++++++++++++++------------------ src/driver/vfd.h | 2 +- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/driver/vfd.cpp b/src/driver/vfd.cpp index da15d7467..6cfabe673 100644 --- a/src/driver/vfd.cpp +++ b/src/driver/vfd.cpp @@ -41,6 +41,9 @@ #include #include +#include +#include + #include extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ @@ -697,29 +700,23 @@ void CVFD::ShowIcon(fp_icon icon, bool show) perror(show ? "IOC_FP_SET_ICON" : "IOC_FP_CLEAR_ICON"); } -void CVFD::ShowText(const char *str) +void CVFD::ShowText(const char * str) { - int len = strlen(str); - int i = 0, ret; + char flags[2] = { FP_FLAG_ALIGN_LEFT, 0 }; -printf("CVFD::ShowText: [%s]\n", str); - if (len > 0) - { - for (i = len; i > 0; i--) { - if (str[i - 1] != ' ') - break; - } - } + if (g_settings.lcd_scroll) + flags[0] |= FP_FLAG_SCROLL_ON | FP_FLAG_SCROLL_SIO | FP_FLAG_SCROLL_DELAY; - if (((int)strlen(text) == i && !strncmp(str, text, i)) || len > 255) + std::string txt = std::string(flags) + str; + txt = trim(txt); + printf("CVFD::ShowText: [%s]\n", txt.c_str() + 1); + + size_t len = txt.length(); + if (txt == text || len > 255) return; - strncpy(text, str, i); - text[i] = '\0'; - -//printf("****************************** CVFD::ShowText: %s\n", str); - //FIXME !! - ret = ioctl(fd, IOC_FP_SET_TEXT, len ? str : NULL); + text = txt; + int ret = ioctl(fd, IOC_FP_SET_TEXT, len > 1 ? txt.c_str() : NULL); if(ret < 0) perror("IOC_FP_SET_TEXT"); } diff --git a/src/driver/vfd.h b/src/driver/vfd.h index d4192eb83..8adaf13b5 100644 --- a/src/driver/vfd.h +++ b/src/driver/vfd.h @@ -90,7 +90,7 @@ class CVFD unsigned int switch_name_time_cnt; int fd; int brightness; - char text[256]; + std::string text; void count_down();