Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P012] Add support for ST7032 (LCD 2x16) #4884

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/_P012_LCD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// #######################################################################################################

/** Changelog:
* 2023-12-26 tonhuisman: Clear the splash from the display after 5 seconds if not already overwritten
* 2023-11-21 tonhuisman: Add support for contrast for ST7032 based displays
* 2023-11-18 tonhuisman: Trying to include support for Midas displays MD21605B6W-FTPLWI3 ST7032 (16x2 at I2C 0x3E)
* 2023-03-07 tonhuisman: Parse text to display without trimming off leading and trailing spaces
Expand Down Expand Up @@ -228,6 +229,15 @@ boolean Plugin_012(uint8_t function, struct EventStruct *event, String& string)
char deviceTemplate[P12_Nlines][P12_Nchars];
LoadCustomTaskSettings(event->TaskIndex, reinterpret_cast<uint8_t *>(&deviceTemplate), sizeof(deviceTemplate));

if (P012_data->firstLineState == 0) {
// Most common route
} else if (P012_data->firstLineState == 2) {
P012_data->firstLineState = 1;
Scheduler.schedule_task_device_timer(event->TaskIndex, millis() + 5000);
} else if (P012_data->firstLineState == 1) {
P012_data->lcdWrite(F(" "), 0, 0); // Wipe 'ESP Easy' splash text, will reset firstLineState
}

for (uint8_t x = 0; x < P012_data->Plugin_012_rows; x++)
{
String tmpString = deviceTemplate[x];
Expand Down Expand Up @@ -265,7 +275,8 @@ boolean Plugin_012(uint8_t function, struct EventStruct *event, String& string)
}
else if (equals(arg1, F("clear"))) {
P012_data->lcd->clear();
success = true;
P012_data->firstLineState = 0;
success = true;
}
else if (equals(arg1, F("contrast")) &&
(P012_DisplaySize_e::LCD_2x16_ST7032 == static_cast<P012_DisplaySize_e>(P012_SIZE)) &&
Expand Down
3 changes: 1 addition & 2 deletions src/src/PluginStructs/P012_data_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ void P012_data_struct::lcdWrite(const String& text, uint8_t col, uint8_t row) {
}
}

if (row == 0) { firstLineState = 0; } // Reset firstLineState
tonhuisman marked this conversation as resolved.
Show resolved Hide resolved
lcd->setCursor(col, row);

if ((Plugin_012_mode == 1) || (Plugin_012_mode == 2)) {
lcd->setCursor(col, row);

for (uint8_t i = 0; i < Plugin_012_cols - col; i++) {
if (text[i]) {
lcd->print(text[i]);
Expand Down
3 changes: 2 additions & 1 deletion src/src/PluginStructs/P012_data_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct P012_data_struct : public PluginTaskData_base {
P012_DisplaySize_e lcd_size,
uint8_t mode,
uint8_t timer);
P012_data_struct() = delete;
P012_data_struct() = delete;
virtual ~P012_data_struct();

void init();
Expand All @@ -47,6 +47,7 @@ struct P012_data_struct : public PluginTaskData_base {
int Plugin_012_rows = 2;
int Plugin_012_mode = 1;
uint8_t displayTimer = 0;
uint8_t firstLineState = 2;
};

#endif // ifdef USES_P012
Expand Down