From 5f8b1731552507eaade0c8e72c05baf18514322b Mon Sep 17 00:00:00 2001 From: penfold42 Date: Thu, 26 Jul 2018 11:06:21 +1000 Subject: [PATCH] LCD type is now an enum --- src/ScreenLCD.cpp | 2 +- src/ScreenLCD.h | 3 ++- src/main.cpp | 2 +- src/options.cpp | 8 +++++--- src/options.h | 12 ++++++++++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/ScreenLCD.cpp b/src/ScreenLCD.cpp index bde0a30..b389c6e 100644 --- a/src/ScreenLCD.cpp +++ b/src/ScreenLCD.cpp @@ -23,7 +23,7 @@ #include "debug.h" #include "ssd_logo.h" -void ScreenLCD::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, int LCDType) +void ScreenLCD::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, LCD_MODEL LCDType) { bpp = 1; diff --git a/src/ScreenLCD.h b/src/ScreenLCD.h index dc68275..b81d114 100644 --- a/src/ScreenLCD.h +++ b/src/ScreenLCD.h @@ -21,6 +21,7 @@ #include "ScreenBase.h" #include "SSD1306.h" +#include "options.h" class ScreenLCD : public ScreenBase { @@ -32,7 +33,7 @@ public: { } - void Open(u32 width, u32 height, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, int LCDType); + void Open(u32 width, u32 height, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, LCD_MODEL LCDType); void ClearArea(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour); void Clear(RGBA colour); diff --git a/src/main.cpp b/src/main.cpp index ad9bcd8..4747440 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -365,7 +365,7 @@ void InitialiseLCD() int i2cLcdOnContrast = options.I2CLcdOnContrast(); int i2cLcdDimContrast = options.I2CLcdDimContrast(); int i2cLcdDimTime = options.I2CLcdDimTime(); - int i2cLcdModel = options.I2CLcdModel(); + LCD_MODEL i2cLcdModel = options.I2CLcdModel(); if (i2cLcdModel) { diff --git a/src/options.cpp b/src/options.cpp index 5fa487e..62550b2 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -145,7 +145,7 @@ Options::Options(void) , i2cScan(0) , i2cLcdFlip(0) , i2cLcdOnContrast(127) - , i2cLcdModel(0) + , i2cLcdModel(LCD_UNKNOWN) , scrollHighlightRate(0.125f) , keyboardBrowseLCDScreen(0) { @@ -241,9 +241,11 @@ void Options::Process(char* buffer) { strncpy(LCDName, pValue, 255); if (strcasecmp(pValue, "ssd1306_128x64") == 0) - i2cLcdModel = 1306; + i2cLcdModel = LCD_1306_128x64; + else if (strcasecmp(pValue, "ssd1306_128x32") == 0) + i2cLcdModel = LCD_1306_128x32; else if (strcasecmp(pValue, "sh1106_128x64") == 0) - i2cLcdModel = 1106; + i2cLcdModel = LCD_1106_128x64; } else if ((strcasecmp(pOption, "ROM") == 0) || (strcasecmp(pOption, "ROM1") == 0)) diff --git a/src/options.h b/src/options.h index 22a8931..f408b36 100644 --- a/src/options.h +++ b/src/options.h @@ -19,6 +19,13 @@ #ifndef OPTIONS_H #define OPTIONS_H +typedef enum { + LCD_UNKNOWN, + LCD_1306_128x64, + LCD_1306_128x32, + LCD_1106_128x64, +} LCD_MODEL; + class TextParser { public: @@ -77,7 +84,7 @@ public: inline unsigned int I2CLcdOnContrast() const { return i2cLcdOnContrast; } inline unsigned int I2CLcdDimContrast() const { return i2cLcdDimContrast; } inline unsigned int I2CLcdDimTime() const { return i2cLcdDimTime; } - inline unsigned int I2CLcdModel() const { return i2cLcdModel; } + inline LCD_MODEL I2CLcdModel() const { return i2cLcdModel; } inline const char* GetLcdLogoName() const { return LcdLogoName; } @@ -123,7 +130,8 @@ private: unsigned int i2cLcdOnContrast; unsigned int i2cLcdDimContrast; unsigned int i2cLcdDimTime; - unsigned int i2cLcdModel; +// unsigned int i2cLcdModel; + LCD_MODEL i2cLcdModel = LCD_UNKNOWN; float scrollHighlightRate;