[P023] Disable Content-display in web-UI for limited builds (code size reductions)

This commit is contained in:
Ton Huisman
2024-08-17 14:34:20 +02:00
parent 43b0b90cdb
commit b81c2232fa
3 changed files with 37 additions and 23 deletions
+12 -17
View File
@@ -7,6 +7,7 @@
// #######################################################################################################
/** Changelog:
* 2024-08-17 tonhuisman: Disable preview of on-display content for LIMIT_BUILD_SIZE builds.
* 2023-10-16 tonhuisman: Bugfix: Template parsing stopped after initial display since previous updates :-(
* 2023-03-18 tonhuisman: Show current on-display content on Devices page (75% size, omits trailing empty lines)
* Manually set content via command: oled,x,y,<content> is included in the Devices page content
@@ -39,17 +40,13 @@ boolean Plugin_023(uint8_t function, struct EventStruct *event, String& string)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_023;
Device[deviceCount].Type = DEVICE_TYPE_I2C;
Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_NONE;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = false;
Device[deviceCount].ValueCount = 0;
Device[deviceCount].SendDataOption = false;
Device[deviceCount].TimerOption = true;
Device[deviceCount].TimerOptional = true;
Device[++deviceCount].Number = PLUGIN_ID_023;
Device[deviceCount].Type = DEVICE_TYPE_I2C;
Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_NONE;
Device[deviceCount].Ports = 0;
Device[deviceCount].ValueCount = 0;
Device[deviceCount].TimerOption = true;
Device[deviceCount].TimerOptional = true;
break;
}
@@ -242,24 +239,22 @@ boolean Plugin_023(uint8_t function, struct EventStruct *event, String& string)
break;
}
# if P023_FEATURE_DISPLAY_PREVIEW
case PLUGIN_WEBFORM_SHOW_VALUES:
{
P023_data_struct *P023_data =
static_cast<P023_data_struct *>(getPluginTaskData(event->TaskIndex));
if (nullptr != P023_data) {
success = P023_data->web_show_values();
}
success = nullptr != P023_data && P023_data->web_show_values();
break;
}
# endif // if P023_FEATURE_DISPLAY_PREVIEW
case PLUGIN_WRITE:
{
P023_data_struct *P023_data = static_cast<P023_data_struct *>(getPluginTaskData(event->TaskIndex));
if (nullptr != P023_data) {
success = P023_data->plugin_write(event, string);
}
success = nullptr != P023_data && P023_data->plugin_write(event, string);
break;
}
}
+10 -2
View File
@@ -267,7 +267,9 @@ bool P023_data_struct::plugin_read(struct EventStruct *event) {
const String newString = parseTemplate(tmp, 16);
sendStrXY(newString.c_str(), x, 0);
#if P023_FEATURE_DISPLAY_PREVIEW
currentLines[x] = newString;
#endif // if P023_FEATURE_DISPLAY_PREVIEW
}
}
return true;
@@ -275,8 +277,8 @@ bool P023_data_struct::plugin_read(struct EventStruct *event) {
bool P023_data_struct::plugin_write(struct EventStruct *event,
String & string) {
bool success = false;
String cmd = parseString(string, 1); // Changes to lowercase
bool success = false;
const String cmd = parseString(string, 1); // Changes to lowercase
if (equals(cmd, F("oledcmd"))) {
const String param = parseString(string, 2);
@@ -299,11 +301,15 @@ bool P023_data_struct::plugin_write(struct EventStruct *event,
String text = parseStringToEndKeepCase(string, 4);
text = parseTemplate(text, 16);
sendStrXY(text.c_str(), event->Par1 - 1, event->Par2 - 1);
#if P023_FEATURE_DISPLAY_PREVIEW
setCurrentText(text, event->Par1 - 1, event->Par2 - 1);
#endif // if P023_FEATURE_DISPLAY_PREVIEW
}
return success;
}
#if P023_FEATURE_DISPLAY_PREVIEW
/**
* Update the buffer that is used for PLUGIN_WEB_SHOW_VALUES function
*/
@@ -348,6 +354,8 @@ bool P023_data_struct::web_show_values() {
return result;
}
#endif // if P023_FEATURE_DISPLAY_PREVIEW
void P023_data_struct::displayOn() {
sendCommand(0xaf); // display on
}
+15 -4
View File
@@ -9,6 +9,13 @@
# define P23_Nlines 8 // The number of different lines which can be displayed
# define P23_Nchars 64
# ifndef P023_FEATURE_DISPLAY_PREVIEW
# ifndef LIMIT_BUILD_SIZE
# define P023_FEATURE_DISPLAY_PREVIEW 1
# else // ifndef LIMIT_BUILD_SIZE
# define P023_FEATURE_DISPLAY_PREVIEW 0
# endif // ifndef LIMIT_BUILD_SIZE
# endif // ifndef P023_FEATURE_DISPLAY_PREVIEW
struct P023_data_struct : public PluginTaskData_base {
enum {
@@ -45,11 +52,13 @@ struct P023_data_struct : public PluginTaskData_base {
bool plugin_write(struct EventStruct *event,
String & string);
bool web_show_values();
# if P023_FEATURE_DISPLAY_PREVIEW
bool web_show_values();
void setCurrentText(const String& string,
int X,
int Y);
void setCurrentText(const String& string,
int X,
int Y);
# endif // if P023_FEATURE_DISPLAY_PREVIEW
void displayOn();
@@ -93,7 +102,9 @@ struct P023_data_struct : public PluginTaskData_base {
private:
String strings[P23_Nlines]{};
# if P023_FEATURE_DISPLAY_PREVIEW
String currentLines[P23_Nlines]{};
# endif // if P023_FEATURE_DISPLAY_PREVIEW
};
#endif // ifdef USES_P023