ADD: Setting and support for user defined contrast: oledframedcmd,display,user,contrast,precharge,comdetect

ADD: oledframedcmd,display,user,contrast,precharge,comdetect (contrast, precharge and comdetect are integers)
CHG: setting for low contrast modified, low was invisible!
This commit is contained in:
uwekaditz
2022-04-18 21:26:35 +02:00
parent cc062ac17f
commit 6596e1b76c
4 changed files with 30 additions and 2 deletions
+4
View File
@@ -12,6 +12,7 @@
* ``low`` will dim the display to low.
* ``med`` will dim the display to medium.
* ``high`` will set the brightness to maximum.
* ``user`` will set the contrast, precharge and comdetect to user defined values.
","
OLED displays will age quite fast, so it is not adviced to run them continously at max brightness.
@@ -21,6 +22,9 @@
The display controller itself does support more brightness levels, but these are chosen to give noticable change in brightness levels and also to help in choosing the best values for the 2 brightness control registers.
As there are 2 brightness control registers, there is some overlap in their range, but some combinations may lead to issues like coil whining noise or sometimes not even working displays as not all of these displays are wired to support both controls to be used.
For the parameter of the user setting refer to the data sheet of the display.
An example for very low brightness with an user setting is ``<oledframedcmd,display,user,100,0,64>``.
"
"
``oledframedcmd,<line>,<text>``
+24
View File
@@ -14,6 +14,9 @@
// Added to the main repository with some optimizations and some limitations.
// Al long as the device is not selected, no RAM is waisted.
//
// @uwekaditz: 2022-04-18
// ADD: Setting and support for user defined contrast: oledframedcmd,display,user,contrast,precharge,comdetect (contrast, precharge and comdetect are integers)
// CHG: setting for low contrast modified, low was invisible!
// @uwekaditz: 2022-04-16
// MSG: code reduced by 530 bytes to fit the build size for 'esp8266, normal_ESP8266_1M' (equal code put into functions)
// @uwekaditz: 2022-04-15
@@ -1120,6 +1123,27 @@ boolean Plugin_036(uint8_t function, struct EventStruct *event, String& string)
# endif // ifdef P036_SEND_EVENTS
P036_SetDisplayOn(1); // Save the fact that the display is now ON
}
if ((para1 == F("user")) &&
(event->Par2 >= 0) &&
(event->Par3 >= 0) &&
(event->Par4 >= 0)) {
String contrast = parseString(string, 4);
String precharge = parseString(string, 5);
String comdetect = parseString(string, 5);
success = true;
P036_data->display->setContrast(contrast.toInt(),precharge.toInt(),comdetect.toInt());
# ifdef P036_SEND_EVENTS
if (sendEvents) {
P036_SendEvent(event, P036_EVENT_CONTRAST, 3);
if (!P036_DisplayIsOn) {
P036_SendEvent(event, P036_EVENT_DISPLAY, 1);
}
}
# endif // ifdef P036_SEND_EVENTS
P036_SetDisplayOn(1); // Save the fact that the display is now ON
}
} else if ((subcommand == F("frame")) &&
(event->Par2 >= 0) &&
(event->Par2 <= P036_data->MaxFramesToDisplay + 1)) {
+1 -1
View File
@@ -230,7 +230,7 @@ void P036_data_struct::setContrast(uint8_t OLED_contrast) {
display->displayOff();
return;
case P36_CONTRAST_LOW:
contrast = 10; precharge = 5; comdetect = 0;
contrast = P36_CONTRAST_LOW; precharge = 5; comdetect = 64;
break;
case P36_CONTRAST_MED:
contrast = P36_CONTRAST_MED; precharge = 0x1F; comdetect = 64;
+1 -1
View File
@@ -43,7 +43,7 @@
# define P036_IndicatorHeight 8
# define P36_CONTRAST_OFF 0x01
# define P36_CONTRAST_LOW 0x40
# define P36_CONTRAST_LOW 0x70
# define P36_CONTRAST_MED 0xCF
# define P36_CONTRAST_HIGH 0xFF