make driver selectable for graphlcd

Origin commit data
------------------
Branch: ni/coolstream
Commit: cd00832423
Author: TangoCash <eric@loxat.de>
Date: 2019-12-29 (Sun, 29 Dec 2019)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
TangoCash
2019-12-29 23:46:52 +01:00
committed by vanhofen
parent 9ddd0300f1
commit 0a7ee97e08
10 changed files with 69 additions and 1 deletions

View File

@@ -562,7 +562,11 @@ void nGLCD::Run(void)
break;
int warmUp = 10;
lcd = GLCD::CreateDriver(GLCD::Config.driverConfigs[0].id, &GLCD::Config.driverConfigs[0]);
if ((g_settings.glcd_selected_config < 0) || (g_settings.glcd_selected_config > GetConfigSize() - 1))
g_settings.glcd_selected_config = 0;
lcd = GLCD::CreateDriver(GLCD::Config.driverConfigs[g_settings.glcd_selected_config].id, &GLCD::Config.driverConfigs[g_settings.glcd_selected_config]);
if (!lcd) {
#ifdef GLCD_DEBUG
fprintf(stderr, "CreateDriver failed.\n");
@@ -959,3 +963,14 @@ int nGLCD::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t /* data */)
return messages_return::unhandled;
}
int nGLCD::GetConfigSize()
{
return (int) GLCD::Config.driverConfigs.size();
}
std::string nGLCD::GetConfigName(int driver)
{
if ((driver < 0) || (driver > GetConfigSize() - 1))
driver = 0;
return GLCD::Config.driverConfigs[driver].name;
}

View File

@@ -130,6 +130,8 @@ class nGLCD
static void Exit();
static void Blit();
static void SetBrightness(unsigned int b);
int GetConfigSize();
std::string GetConfigName(int);
void UpdateBrightness();
int handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data);
};