From f09a45c8efecee76ff9d640e716cfd08a3d69a66 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 16 Jun 2020 23:48:50 +0200 Subject: [PATCH] nglcd: add toggle power function Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/863dee245d74fd4da7373ee15ec03aca86cccb2a Author: vanhofen Date: 2020-06-16 (Tue, 16 Jun 2020) Origin message was: ------------------ - nglcd: add toggle power function --- src/driver/nglcd.cpp | 13 +++++++++++++ src/driver/nglcd.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/driver/nglcd.cpp b/src/driver/nglcd.cpp index a83114819..207241083 100644 --- a/src/driver/nglcd.cpp +++ b/src/driver/nglcd.cpp @@ -77,6 +77,7 @@ nGLCD::nGLCD() { percent_bar = 0; percent_space = 0; percent_logo = 0; + power_state = 1; Scale = 0; bitmap = NULL; blitFlag = true; @@ -941,6 +942,18 @@ void nGLCD::SetBrightness(unsigned int b) nglcd->SetBrightness(b); } +void nGLCD::TogglePower() +{ + if (nglcd) + { + nglcd->power_state = 1 - nglcd->power_state; + if (nglcd->power_state) + nglcd->Resume(); + else + nglcd->Suspend(); + } +} + void nGLCD::Blit() { if (nglcd) diff --git a/src/driver/nglcd.h b/src/driver/nglcd.h index 7c910e096..d9c40ace0 100644 --- a/src/driver/nglcd.h +++ b/src/driver/nglcd.h @@ -60,6 +60,7 @@ class nGLCD int percent_bar; int percent_logo; int percent_space; + int power_state; GLCD::cBitmap * bitmap; std::string Channel; std::string Epg; @@ -138,6 +139,7 @@ class nGLCD static void Exit(); static void Blit(); static void SetBrightness(unsigned int b); + static void TogglePower(); int GetConfigSize(); std::string GetConfigName(int); void UpdateBrightness();