|
@@ -116,6 +116,9 @@ bool HSA_LCD_Shield::__gpioConfig(void) {
|
|
|
// Setup LCD-Backlight
|
|
|
pinMode(this->__lcdBacklight,OUTPUT);
|
|
|
|
|
|
+ // Setup initial LCD-Brightness
|
|
|
+ this->__lcdBrightess = 255;
|
|
|
+
|
|
|
// Initialize I²C as Master
|
|
|
Wire.begin();
|
|
|
|
|
@@ -279,11 +282,55 @@ bool HSA_LCD_Shield::begin(byte address) {
|
|
|
|
|
|
bool HSA_LCD_Shield::lcdBacklight(bool value) {
|
|
|
|
|
|
+ // check, whether LCD is configured
|
|
|
+ if(this->__lcd == false) return false;
|
|
|
+
|
|
|
+ // Turning on/off LCD-Backlight, depending of LCD-Version
|
|
|
+ if(this->__version > LCD_VERSION_5) {
|
|
|
+
|
|
|
+ // Turning on/off LCD-Backlight
|
|
|
+ if(value) analogWrite(this->__lcdBacklight,this->__lcdBrightess);
|
|
|
+ else analogWrite(this->__lcdBacklight,value);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ else {
|
|
|
+
|
|
|
+ // Turning on/off LCD-Backlight
|
|
|
+ digitalWrite(this->__lcdBacklight,value);
|
|
|
+
|
|
|
+ }
|
|
|
+ // Exit function
|
|
|
+ return true;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+bool HSA_LCD_Shield::lcdBacklight(bool value, char brightness) {
|
|
|
+
|
|
|
// check, whether LCD is configured
|
|
|
if(this->__lcd == false) return false;
|
|
|
|
|
|
- // Turning on/off LCD-Backlight
|
|
|
- digitalWrite(this->__lcdBacklight,value);
|
|
|
+ // Turning on/off LCD-Backlight, depending of LCD-Version
|
|
|
+ if(this->__version > LCD_VERSION_5) {
|
|
|
+
|
|
|
+ // check, whether brightness value is between 0 and 100
|
|
|
+ if(brightness < 0 || brightness > 100) return false;
|
|
|
+
|
|
|
+ // store new brightness value
|
|
|
+ this->__lcdBrightess = map(brightness,0,100,0,255);
|
|
|
+
|
|
|
+ // Turning on/off LCD-Backlight
|
|
|
+ if(value) analogWrite(this->__lcdBacklight,this->__lcdBrightess);
|
|
|
+ else analogWrite(this->__lcdBacklight,value);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ else {
|
|
|
+
|
|
|
+ // Turning on/off LCD-Backlight
|
|
|
+ digitalWrite(this->__lcdBacklight,value);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// Exit function
|
|
|
return true;
|