From 35d8abb63951aa351d525a86cc4f2f55f94fc83a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 1 Apr 2012 14:46:14 +0200 Subject: [PATCH] spark: only update LED display once per second The LED driver seems to be pretty slow, so dont hammer it with display requests. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/779aa5b947054ba11eea9503b26f52ab9f594a24 Author: Stefan Seyfried Date: 2012-04-01 (Sun, 01 Apr 2012) ------------------ This commit was generated by Migit --- src/driver/spark_led.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/driver/spark_led.cpp b/src/driver/spark_led.cpp index d66aea71b..1599d350b 100644 --- a/src/driver/spark_led.cpp +++ b/src/driver/spark_led.cpp @@ -43,6 +43,7 @@ static bool power = true; static bool muted = false; static bool showclock = true; static time_t last_display = 0; +static char display_text[64] = { 0 }; static inline int dev_open() { @@ -153,7 +154,12 @@ void CLCD::showTime(bool force) } time_t now = time(NULL); - if (power && (force || (showclock && (now - last_display) > 4))) + if (display_text[0]) + { + display(display_text); + display_text[0] = '\0'; + } + else if (power && (force || (showclock && (now - last_display) > 4))) { char timestr[5]; struct tm *t; @@ -214,7 +220,8 @@ void CLCD::showMenuText(const int, const char *text, const int, const bool) { if (mode != MODE_MENU_UTF8) return; - display(text); + strncpy(display_text, text, sizeof(display_text) - 1); + display_text[sizeof(display_text) - 1] = '\0'; } void CLCD::showAudioTrack(const std::string &, const std::string & title, const std::string &)