I had the same problem with the mega-version. If you go back to R148 and the Arduino IDE, it compiles without errors._P208_PCD8544:171: error: incompatible types in assignment of 'int' to 'unsigned int [12]'
PCD8544 - Nokia 5110/3310 LCD - beta plugin
Moderators: grovkillen, Stuntteam, TD-er
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
please remove that line - is no any more for espeasy important. Below my configuration - right now compiled and tested with IDE 1.8.3 and ESPEasy 2.0.0 dev10
my config is for Hardware SPI and work with 4pin (SPI + C/D on GPIO2, CE on GND, RESET on VCC) or 5pin (SPI, CD on GPIO2, CE on GPIO15, RESET on VCC). 5Pin connection is important when other SPI device is connected eg. SDCARD or termocouple sensor MAX6675.
BR. Adam
PS.
To disable WRAP text please add line:
after line
this will disable wrap text (true 14 characters inline for Nokia display) in Adafruit_GFX library
my config is for Hardware SPI and work with 4pin (SPI + C/D on GPIO2, CE on GND, RESET on VCC) or 5pin (SPI, CD on GPIO2, CE on GPIO15, RESET on VCC). 5Pin connection is important when other SPI device is connected eg. SDCARD or termocouple sensor MAX6675.
Code: Select all
//#######################################################################################################
//################################## Plugin 208: NOKIA lcd2 ###############################################
//#######################################################################################################
#define PLUGIN_208
#define PLUGIN_ID_208 208
#define PLUGIN_NAME_208 "Display - LCD PCD8544"
#define PLUGIN_VALUENAME1_208 "Backlight"
#define PLUGIN_VALUENAME2_208 "Contrast"
#define PLUGIN_VALUENAME3_208 "Rotation"
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
Adafruit_PCD8544 *lcd2;
byte lines = 6;
boolean Plugin_208(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_208 ;
Device[deviceCount].Type = DEVICE_TYPE_I2C;
Device[deviceCount].VType = SENSOR_TYPE_SWITCH;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = false;
Device[deviceCount].ValueCount = 3;
Device[deviceCount].SendDataOption = false;
Device[deviceCount].TimerOption = false;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_208);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_208));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_208));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_208));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
byte choice1 = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
byte choice2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
byte choice3 = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
byte choice4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
char deviceTemplate[lines][32];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
char tmpString[128];
for (byte varNr = 0; varNr < lines; varNr++)
{
string += F("<TR><TD>Line ");
string += varNr + 1;
string += F(":<TD><input type='text' size='80' maxlength='80' name='Plugin_208_template");
string += varNr + 1;
string += F("' value='");
string += deviceTemplate[varNr];
string += F("'>");
}
sprintf_P(tmpString, PSTR("<TR><TD>Display Contrast(50-100):<TD><input type='text' name='plugin_208_contrast' value='%u'>"), choice2);
string += tmpString;
string += F("<TR><TD>Backlight pin:<TD>");
addPinSelect(false, string, "taskdevicepin3", Settings.TaskDevicePin3[event->TaskIndex]);
int optionValues3[4];
optionValues3[0] = 0;
optionValues3[1] = 1;
optionValues3[2] = 2;
optionValues3[3] = 3;
String options3[4];
options3[0] = F("0");
options3[1] = F("90");
options3[2] = F("180");
options3[3] = F("270");
string += F("<TR><TD>Display Rotation:<TD><select name='plugin_208_rotation'>");
for (byte x = 0; x < 4; x++)
{
string += F("<option value='");
string += optionValues3[x];
string += "'";
if (choice1 == optionValues3[x])
string += F(" selected");
string += ">";
string += options3[x];
string += F("</option>");
}
string += F("</select>");
int optionValues4[2];
optionValues4[0] = 0;
optionValues4[1] = 1;
String options4[2];
options4[0] = F("ON");
options4[1] = F("OFF");
string += F("<TR><TD>Backlight:<TD><select name='plugin_208_backlight'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues4[x];
string += "'";
if (choice4 == optionValues4[x])
string += F(" selected");
string += ">";
string += options4[x];
string += F("</option>");
}
string += F("</select>");
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
int plugin1 = WebServer.arg("plugin_208_rotation").toInt();
int plugin2 = WebServer.arg("plugin_208_contrast").toInt();
int plugin3 = Settings.TaskDevicePin3[event->TaskIndex];
int plugin4 = WebServer.arg("plugin_208_backlight").toInt();
String options1[4];
options1[0] = F("0");
options1[1] = F("90");
options1[2] = F("180");
options1[3] = F("270");
UserVar[event->BaseVarIndex+2]=options1[plugin1].toInt();
UserVar[event->BaseVarIndex+1]=plugin2;
UserVar[event->BaseVarIndex]=!plugin4;
String log = F("PCD8544: ");
if (plugin2>100) plugin2=100;
if (plugin2<50) plugin2=50;
if (plugin1!=Settings.TaskDevicePluginConfig[event->TaskIndex][3]){
log += String(F("rotation changed to: ")) + plugin1;
addLog(LOG_LEVEL_INFO, log);
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = plugin1;
}
if (plugin4!=Settings.TaskDevicePluginConfig[event->TaskIndex][3]){
log += String(F("backlight is now ")) + plugin4?"off":"on";
addLog(LOG_LEVEL_INFO, log);
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin4;
}
if (plugin2!=Settings.TaskDevicePluginConfig[event->TaskIndex][3]){
log += String(F("contrast is changed to: ")) + plugin2;
addLog(LOG_LEVEL_INFO, log);
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2;
}
char deviceTemplate[lines][32];
for (byte varNr = 0; varNr < lines; varNr++)
{
char argc[25];
String arg = F("Plugin_208_template");
arg += varNr + 1;
arg.toCharArray(argc, 25);
String tmpString = WebServer.arg(argc);
strncpy(deviceTemplate[varNr], tmpString.c_str(), sizeof(deviceTemplate[varNr]));
}
// Settings.TaskDeviceID[event->TaskIndex] = 1; // temp fix, needs a dummy value
SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
success = true;
break;
}
case PLUGIN_INIT:
{
if (!lcd2)
{
// pin 14 - Serial clock out (SCLK)
// pin 13 - Serial data out (DIN)
// pin 12 - Data/Command select (D/C)
// pin 5 - LCD chip select (CS)
// pin 4 - LCD reset (RST)
//lcd2 = new Adafruit_PCD8544(14, 13, 12, 5, 4);
lcd2 = new Adafruit_PCD8544(15, 2, 16); // CS(CEN) GPIO15 , D/C (need to be connected) GPIO2 , RESET GPIO16
}
// Setup lcd2 display
byte plugin1 = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
byte plugin2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
byte plugin4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
UserVar[event->BaseVarIndex+2]=plugin1;
UserVar[event->BaseVarIndex+1]=plugin2;
UserVar[event->BaseVarIndex]=!plugin4;
if (plugin1==0 || plugin1==2)
{
lines=6;
}
else{
lines=10;
}
lcd2->begin(); // initialize the lcd2
lcd2->setContrast(plugin2);
lcd2->setRotation(plugin1);
lcd2->clearDisplay();
char deviceTemplate[lines][32];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
displayText(deviceTemplate);
lcd2->display();
if (Settings.TaskDevicePin3[event->TaskIndex] != -1){
pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT);
digitalWrite(Settings.TaskDevicePin3[event->TaskIndex],Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
success = true;
break;
}
case PLUGIN_READ:
{
char deviceTemplate[lines][32];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
displayText(deviceTemplate);
success = false;
break;
}
case PLUGIN_WRITE:
{
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("PCD8544")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
lcd2->setCursor(event->Par2 - 1, event->Par1 - 1);
lcd2->println(tmpString.c_str());
}
if (tmpString.equalsIgnoreCase(F("PCD8544CMD")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
if (tmpString.equalsIgnoreCase(F("Clear")))
lcd2->clearDisplay();
}
break;
}
}
return success;
}
boolean displayText(char deviceTemplate[][32]){
String log = F("PCD8544: ");
String string = F("");
lcd2->clearDisplay();
lcd2->setTextSize(1);
lcd2->setTextColor(BLACK);
lcd2->setCursor(0,0);
for (byte x = 0; x < lines; x++)
{
String tmpString = deviceTemplate[x];
if (tmpString.length())
{
String newString = parseTemplate(tmpString, 32);
lcd2->setCursor(0,x*8);
lcd2->print(newString);
string+=newString+"\\";
}
}
log += String(F("displayed text: \"")) + String(string) + String(F("\""));
addLog(LOG_LEVEL_INFO, log);
lcd2->display();
return true;
}
PS.
To disable WRAP text please add line:
Code: Select all
boolean setTextWrap = false;
Code: Select all
lcd2 = new Adafruit_PCD8544(15, 2, 16); // CS(CEN) GPIO15 , D/C (need to be connected) GPIO2 , RESET GPIO16
Domoticz Beta release on OrangePI PC and BananaPI,
2x RFLink (last version),
ESPEasy, ESPEasy32 (different configurations),
MySensors (different configurations),
2x MiLight RGBW (over RFLink)
and others things
2x RFLink (last version),
ESPEasy, ESPEasy32 (different configurations),
MySensors (different configurations),
2x MiLight RGBW (over RFLink)
and others things
-
- New user
- Posts: 1
- Joined: 07 Feb 2018, 00:02
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Is it possible to use commands to print text on the screen?adampr1 wrote: ↑12 Jun 2017, 16:15 please remove that line - is no any more for espeasy important. Below my configuration - right now compiled and tested with IDE 1.8.3 and ESPEasy 2.0.0 dev10
my config is for Hardware SPI and work with 4pin (SPI + C/D on GPIO2, CE on GND, RESET on VCC) or 5pin (SPI, CD on GPIO2, CE on GPIO15, RESET on VCC). 5Pin connection is important when other SPI device is connected eg. SDCARD or termocouple sensor MAX6675.
BR. AdamCode: Select all
//####################################################################################################### //################################## Plugin 208: NOKIA lcd2 ############################################### //####################################################################################################### #define PLUGIN_208 #define PLUGIN_ID_208 208 #define PLUGIN_NAME_208 "Display - LCD PCD8544" #define PLUGIN_VALUENAME1_208 "Backlight" #define PLUGIN_VALUENAME2_208 "Contrast" #define PLUGIN_VALUENAME3_208 "Rotation" #include <SPI.h> #include <Adafruit_GFX.h> #include <Adafruit_PCD8544.h> Adafruit_PCD8544 *lcd2; byte lines = 6; boolean Plugin_208(byte function, struct EventStruct *event, String& string) { boolean success = false; switch (function) { case PLUGIN_DEVICE_ADD: { Device[++deviceCount].Number = PLUGIN_ID_208 ; Device[deviceCount].Type = DEVICE_TYPE_I2C; Device[deviceCount].VType = SENSOR_TYPE_SWITCH; Device[deviceCount].Ports = 0; Device[deviceCount].PullUpOption = false; Device[deviceCount].InverseLogicOption = false; Device[deviceCount].FormulaOption = false; Device[deviceCount].ValueCount = 3; Device[deviceCount].SendDataOption = false; Device[deviceCount].TimerOption = false; break; } case PLUGIN_GET_DEVICENAME: { string = F(PLUGIN_NAME_208); break; } case PLUGIN_GET_DEVICEVALUENAMES: { strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_208)); strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_208)); strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_208)); break; } case PLUGIN_WEBFORM_LOAD: { byte choice1 = Settings.TaskDevicePluginConfig[event->TaskIndex][3]; byte choice2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1]; byte choice3 = Settings.TaskDevicePluginConfig[event->TaskIndex][2]; byte choice4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0]; char deviceTemplate[lines][32]; LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); char tmpString[128]; for (byte varNr = 0; varNr < lines; varNr++) { string += F("<TR><TD>Line "); string += varNr + 1; string += F(":<TD><input type='text' size='80' maxlength='80' name='Plugin_208_template"); string += varNr + 1; string += F("' value='"); string += deviceTemplate[varNr]; string += F("'>"); } sprintf_P(tmpString, PSTR("<TR><TD>Display Contrast(50-100):<TD><input type='text' name='plugin_208_contrast' value='%u'>"), choice2); string += tmpString; string += F("<TR><TD>Backlight pin:<TD>"); addPinSelect(false, string, "taskdevicepin3", Settings.TaskDevicePin3[event->TaskIndex]); int optionValues3[4]; optionValues3[0] = 0; optionValues3[1] = 1; optionValues3[2] = 2; optionValues3[3] = 3; String options3[4]; options3[0] = F("0"); options3[1] = F("90"); options3[2] = F("180"); options3[3] = F("270"); string += F("<TR><TD>Display Rotation:<TD><select name='plugin_208_rotation'>"); for (byte x = 0; x < 4; x++) { string += F("<option value='"); string += optionValues3[x]; string += "'"; if (choice1 == optionValues3[x]) string += F(" selected"); string += ">"; string += options3[x]; string += F("</option>"); } string += F("</select>"); int optionValues4[2]; optionValues4[0] = 0; optionValues4[1] = 1; String options4[2]; options4[0] = F("ON"); options4[1] = F("OFF"); string += F("<TR><TD>Backlight:<TD><select name='plugin_208_backlight'>"); for (byte x = 0; x < 2; x++) { string += F("<option value='"); string += optionValues4[x]; string += "'"; if (choice4 == optionValues4[x]) string += F(" selected"); string += ">"; string += options4[x]; string += F("</option>"); } string += F("</select>"); success = true; break; } case PLUGIN_WEBFORM_SAVE: { int plugin1 = WebServer.arg("plugin_208_rotation").toInt(); int plugin2 = WebServer.arg("plugin_208_contrast").toInt(); int plugin3 = Settings.TaskDevicePin3[event->TaskIndex]; int plugin4 = WebServer.arg("plugin_208_backlight").toInt(); String options1[4]; options1[0] = F("0"); options1[1] = F("90"); options1[2] = F("180"); options1[3] = F("270"); UserVar[event->BaseVarIndex+2]=options1[plugin1].toInt(); UserVar[event->BaseVarIndex+1]=plugin2; UserVar[event->BaseVarIndex]=!plugin4; String log = F("PCD8544: "); if (plugin2>100) plugin2=100; if (plugin2<50) plugin2=50; if (plugin1!=Settings.TaskDevicePluginConfig[event->TaskIndex][3]){ log += String(F("rotation changed to: ")) + plugin1; addLog(LOG_LEVEL_INFO, log); Settings.TaskDevicePluginConfig[event->TaskIndex][3] = plugin1; } if (plugin4!=Settings.TaskDevicePluginConfig[event->TaskIndex][3]){ log += String(F("backlight is now ")) + plugin4?"off":"on"; addLog(LOG_LEVEL_INFO, log); Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin4; } if (plugin2!=Settings.TaskDevicePluginConfig[event->TaskIndex][3]){ log += String(F("contrast is changed to: ")) + plugin2; addLog(LOG_LEVEL_INFO, log); Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2; } char deviceTemplate[lines][32]; for (byte varNr = 0; varNr < lines; varNr++) { char argc[25]; String arg = F("Plugin_208_template"); arg += varNr + 1; arg.toCharArray(argc, 25); String tmpString = WebServer.arg(argc); strncpy(deviceTemplate[varNr], tmpString.c_str(), sizeof(deviceTemplate[varNr])); } // Settings.TaskDeviceID[event->TaskIndex] = 1; // temp fix, needs a dummy value SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); success = true; break; } case PLUGIN_INIT: { if (!lcd2) { // pin 14 - Serial clock out (SCLK) // pin 13 - Serial data out (DIN) // pin 12 - Data/Command select (D/C) // pin 5 - LCD chip select (CS) // pin 4 - LCD reset (RST) //lcd2 = new Adafruit_PCD8544(14, 13, 12, 5, 4); lcd2 = new Adafruit_PCD8544(15, 2, 16); // CS(CEN) GPIO15 , D/C (need to be connected) GPIO2 , RESET GPIO16 } // Setup lcd2 display byte plugin1 = Settings.TaskDevicePluginConfig[event->TaskIndex][3]; byte plugin2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1]; byte plugin4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0]; UserVar[event->BaseVarIndex+2]=plugin1; UserVar[event->BaseVarIndex+1]=plugin2; UserVar[event->BaseVarIndex]=!plugin4; if (plugin1==0 || plugin1==2) { lines=6; } else{ lines=10; } lcd2->begin(); // initialize the lcd2 lcd2->setContrast(plugin2); lcd2->setRotation(plugin1); lcd2->clearDisplay(); char deviceTemplate[lines][32]; LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); displayText(deviceTemplate); lcd2->display(); if (Settings.TaskDevicePin3[event->TaskIndex] != -1){ pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT); digitalWrite(Settings.TaskDevicePin3[event->TaskIndex],Settings.TaskDevicePluginConfig[event->TaskIndex][0]); setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);} success = true; break; } case PLUGIN_READ: { char deviceTemplate[lines][32]; LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); displayText(deviceTemplate); success = false; break; } case PLUGIN_WRITE: { String tmpString = string; int argIndex = tmpString.indexOf(','); if (argIndex) tmpString = tmpString.substring(0, argIndex); if (tmpString.equalsIgnoreCase(F("PCD8544"))) { success = true; argIndex = string.lastIndexOf(','); tmpString = string.substring(argIndex + 1); lcd2->setCursor(event->Par2 - 1, event->Par1 - 1); lcd2->println(tmpString.c_str()); } if (tmpString.equalsIgnoreCase(F("PCD8544CMD"))) { success = true; argIndex = string.lastIndexOf(','); tmpString = string.substring(argIndex + 1); if (tmpString.equalsIgnoreCase(F("Clear"))) lcd2->clearDisplay(); } break; } } return success; } boolean displayText(char deviceTemplate[][32]){ String log = F("PCD8544: "); String string = F(""); lcd2->clearDisplay(); lcd2->setTextSize(1); lcd2->setTextColor(BLACK); lcd2->setCursor(0,0); for (byte x = 0; x < lines; x++) { String tmpString = deviceTemplate[x]; if (tmpString.length()) { String newString = parseTemplate(tmpString, 32); lcd2->setCursor(0,x*8); lcd2->print(newString); string+=newString+"\\"; } } log += String(F("displayed text: \"")) + String(string) + String(F("\"")); addLog(LOG_LEVEL_INFO, log); lcd2->display(); return true; }
PS.
To disable WRAP text please add line:after lineCode: Select all
boolean setTextWrap = false;
this will disable wrap text (true 14 characters inline for Nokia display) in Adafruit_GFX libraryCode: Select all
lcd2 = new Adafruit_PCD8544(15, 2, 16); // CS(CEN) GPIO15 , D/C (need to be connected) GPIO2 , RESET GPIO16
lcd.1,1,{msg} works on normal LCD's
or lcdcmd,clear
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
After long time new (adapted) version of PCD8544 lcd display plugin. After changes in ESPEASY (permit strings for html), previous display plugin not compiles with latest ESPEASY. Now refreshed version - no compile errors and display working again
please test and any suggestion are welcome.
BR.
Adam
Code: Select all
//#######################################################################################################
//################################## Plugin 208: NOKIA lcd2 ###############################################
//#######################################################################################################
#define PLUGIN_208
#define PLUGIN_ID_208 208
#define PLUGIN_NAME_208 "Display - LCD PCD8544"
#define PLUGIN_VALUENAME1_208 "Backlight"
#define PLUGIN_VALUENAME2_208 "Contrast"
#define PLUGIN_VALUENAME3_208 "Rotation"
//#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
Adafruit_PCD8544 *lcd2;
byte lines = 6;
boolean Plugin_208(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_208 ;
Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = false;
Device[deviceCount].ValueCount = 3;
Device[deviceCount].SendDataOption = false;
Device[deviceCount].TimerOption = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_208);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_208));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_208));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_208));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
addFormNumericBox(F("Display Contrast(50-100):"), F("plugin_208_contrast"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
addFormPinSelect(F("Backlight PIN"), F("taskdevicepin3"), Settings.TaskDevicePin3[event->TaskIndex]);
byte choice3 = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
int optionValues3[4] = { 0, 1, 2, 3 };
String options3[4] = { F("0"), F("90"), F("180"), F("270") };
addFormSelector(F("Display Rotation"), F("plugin_208_rotation"), 4, options3, optionValues3, choice3);
byte choice4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options4[2] = { F("ON"), F("OFF") };
int optionValues4[2] = { 0, 1 };
addFormSelector(F("Backlight"), F("plugin_208_backlight"), 2, options4, optionValues4, choice4);
char deviceTemplate [lines][48];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
for (byte varNr = 0; varNr < lines; varNr++)
{
addFormTextBox(String(F("Line ")) + (varNr + 1), String(F("Plugin_208_template")) + (varNr + 1), deviceTemplate[varNr], 80);
}
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_208_backlight"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_208_contrast"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_208_rotation"));
char deviceTemplate[lines][48];
for (byte varNr = 0; varNr < lines; varNr++)
{
char argc[25];
String arg = F("Plugin_208_template");
arg += varNr + 1;
arg.toCharArray(argc, 25);
String tmpString = WebServer.arg(argc);
strncpy(deviceTemplate[varNr], tmpString.c_str(), sizeof(deviceTemplate[varNr]));
}
// Settings.TaskDeviceID[event->TaskIndex] = 1; // temp fix, needs a dummy value
SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
success = true;
break;
}
case PLUGIN_INIT:
{
if (!lcd2)
{
// pin 14 - Serial clock out (SCLK)
// pin 13 - Serial data out (DIN)
// pin 12 - Data/Command select (D/C)
// pin 5 - LCD chip select (CS)
// pin 4 - LCD reset (RST)
//lcd2 = new Adafruit_PCD8544(14, 13, 12, 5, 4);
#if defined(ESP8266)
lcd2 = new Adafruit_PCD8544(15, 2, -1); // D/C (need to be connected) GPIO2 , CS(CEN) GPIO15 , RESET not connected
#endif
#if defined(ESP32)
lcd2 = new Adafruit_PCD8544(16, 17, -1); // D/C (need to be connected) GPIO16 , CS(CEN) GPIO17 , RESET not connected
#endif
boolean setTextWrap = false;
}
// Setup lcd2 display
byte plugin1 = Settings.TaskDevicePluginConfig[event->TaskIndex][2]; // rotation
byte plugin2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1]; // contrast
byte plugin4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0]; // backlight_onoff
UserVar[event->BaseVarIndex+2]=plugin1;
UserVar[event->BaseVarIndex+1]=plugin2;
UserVar[event->BaseVarIndex]=!plugin4;
if (plugin1==0 || plugin1==2)
{
lines=6;
}
else{
lines=10;
}
lcd2->begin(); // initialize the lcd2
lcd2->setContrast(plugin2);
lcd2->setRotation(plugin1);
lcd2->clearDisplay();
char deviceTemplate[lines][48];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
displayText(deviceTemplate);
lcd2->display();
if (Settings.TaskDevicePin3[event->TaskIndex] != -1){
pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT);
digitalWrite(Settings.TaskDevicePin3[event->TaskIndex],Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
success = true;
break;
}
case PLUGIN_READ:
{
char deviceTemplate[lines][48];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
displayText(deviceTemplate);
success = false;
break;
}
case PLUGIN_WRITE:
{
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("PCD8544")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
lcd2->setCursor(event->Par2 - 1, event->Par1 - 1);
lcd2->println(tmpString.c_str());
}
if (tmpString.equalsIgnoreCase(F("PCD8544CMD")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
if (tmpString.equalsIgnoreCase(F("Clear")))
lcd2->clearDisplay();
}
break;
}
}
return success;
}
boolean displayText(char deviceTemplate[][48]){
String log = F("PCD8544: ");
String string = F("");
lcd2->clearDisplay();
lcd2->setTextSize(1);
lcd2->setTextColor(BLACK);
lcd2->setCursor(0,0);
for (byte x = 0; x < lines; x++)
{
String tmpString = deviceTemplate[x];
if (tmpString.length())
{
String newString = parseTemplate(tmpString, 48);
lcd2->setCursor(0,x*8);
lcd2->print(newString);
string+=newString+"\\";
}
}
log += String(F("displayed text: \"")) + String(string) + String(F("\""));
addLog(LOG_LEVEL_INFO, log);
lcd2->display();
return true;
}
BR.
Adam
Domoticz Beta release on OrangePI PC and BananaPI,
2x RFLink (last version),
ESPEasy, ESPEasy32 (different configurations),
MySensors (different configurations),
2x MiLight RGBW (over RFLink)
and others things
2x RFLink (last version),
ESPEasy, ESPEasy32 (different configurations),
MySensors (different configurations),
2x MiLight RGBW (over RFLink)
and others things
-
- Normal user
- Posts: 10
- Joined: 11 Sep 2016, 16:43
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Hi, i am trying to compile using PlatformIO, and i get the below messages
D:/ESPEasy-mega-20180904/src/_P208_PCD8544.ino: In function 'boolean Plugin_208(byte, EventStruct*, String&)':
D:/ESPEasy-mega-20180904/src/_P208_PCD8544.ino:126:20: warning: unused variable 'setTextWrap' [-Wunused-variable]
boolean setTextWrap = false;
^
D:/ESPEasy-mega-20180904/src/_P208_PCD8544.ino:148:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
^
D:/ESPEasy-mega-20180904/src/_P208_PCD8544.ino:162:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
^
any ideas ?
thanks
D:/ESPEasy-mega-20180904/src/_P208_PCD8544.ino: In function 'boolean Plugin_208(byte, EventStruct*, String&)':
D:/ESPEasy-mega-20180904/src/_P208_PCD8544.ino:126:20: warning: unused variable 'setTextWrap' [-Wunused-variable]
boolean setTextWrap = false;
^
D:/ESPEasy-mega-20180904/src/_P208_PCD8544.ino:148:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
^
D:/ESPEasy-mega-20180904/src/_P208_PCD8544.ino:162:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
^
any ideas ?
thanks
-
- Normal user
- Posts: 10
- Joined: 11 Sep 2016, 16:43
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
ok now it compiles successfully however the plugin does not appear in the devices list to pick
here is the code i used
here is the code i used
Code: Select all
#ifdef USES_P208
//#######################################################################################################
//################################## Plugin 208: NOKIA lcd2 ###############################################
//#######################################################################################################
#define PLUGIN_208
#define PLUGIN_ID_208 208
#define PLUGIN_NAME_208 "Display - LCD PCD8544 [TESTING]"
#define PLUGIN_VALUENAME1_208 "Backlight"
#define PLUGIN_VALUENAME2_208 "Contrast"
#define PLUGIN_VALUENAME3_208 "Rotation"
//#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
Adafruit_PCD8544 *lcd2;
byte lines = 6;
boolean Plugin_208(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_208 ;
Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = false;
Device[deviceCount].ValueCount = 3;
Device[deviceCount].SendDataOption = false;
Device[deviceCount].TimerOption = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_208);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_208));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_208));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_208));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
addFormNumericBox(F("Display Contrast(50-100):"), F("plugin_208_contrast"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
addFormPinSelect(F("Backlight PIN"), F("taskdevicepin3"), Settings.TaskDevicePin3[event->TaskIndex]);
byte choice3 = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
int optionValues3[4] = { 0, 1, 2, 3 };
String options3[4] = { F("0"), F("90"), F("180"), F("270") };
addFormSelector(F("Display Rotation"), F("plugin_208_rotation"), 4, options3, optionValues3, choice3);
byte choice4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options4[2] = { F("ON"), F("OFF") };
int optionValues4[2] = { 0, 1 };
addFormSelector(F("Backlight"), F("plugin_208_backlight"), 2, options4, optionValues4, choice4);
char deviceTemplate [lines][48];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
for (byte varNr = 0; varNr < lines; varNr++)
{
addFormTextBox(String(F("Line ")) + (varNr + 1), String(F("Plugin_208_template")) + (varNr + 1), deviceTemplate[varNr], 80);
}
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_208_backlight"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_208_contrast"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_208_rotation"));
char deviceTemplate[lines][48];
for (byte varNr = 0; varNr < lines; varNr++)
{
char argc[25];
String arg = F("Plugin_208_template");
arg += varNr + 1;
arg.toCharArray(argc, 25);
String tmpString = WebServer.arg(argc);
strncpy(deviceTemplate[varNr], tmpString.c_str(), sizeof(deviceTemplate[varNr]));
}
// Settings.TaskDeviceID[event->TaskIndex] = 1; // temp fix, needs a dummy value
SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
success = true;
break;
}
case PLUGIN_INIT:
{
if (!lcd2)
{
// pin 14 - Serial clock out (SCLK)
// pin 13 - Serial data out (DIN)
// pin 12 - Data/Command select (D/C)
// pin 5 - LCD chip select (CS)
// pin 4 - LCD reset (RST)
//lcd2 = new Adafruit_PCD8544(14, 13, 12, 5, 4);
#if defined(ESP8266)
lcd2 = new Adafruit_PCD8544(15, 2, -1); // D/C (need to be connected) GPIO2 , CS(CEN) GPIO15 , RESET not connected
#endif
#if defined(ESP32)
lcd2 = new Adafruit_PCD8544(16, 17, -1); // D/C (need to be connected) GPIO16 , CS(CEN) GPIO17 , RESET not connected
#endif
boolean setTextWrap = false;
}
// Setup lcd2 display
byte plugin1 = Settings.TaskDevicePluginConfig[event->TaskIndex][2]; // rotation
byte plugin2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1]; // contrast
byte plugin4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0]; // backlight_onoff
UserVar[event->BaseVarIndex+2]=plugin1;
UserVar[event->BaseVarIndex+1]=plugin2;
UserVar[event->BaseVarIndex]=!plugin4;
if (plugin1==0 || plugin1==2)
{
lines=6;
}
else{
lines=10;
}
lcd2->begin(); // initialize the lcd2
lcd2->setContrast(plugin2);
lcd2->setRotation(plugin1);
lcd2->clearDisplay();
char deviceTemplate[lines][48];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
displayText(deviceTemplate);
lcd2->display();
if (Settings.TaskDevicePin3[event->TaskIndex] != -1){
pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT);
digitalWrite(Settings.TaskDevicePin3[event->TaskIndex],Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
success = true;
break;
}
case PLUGIN_READ:
{
char deviceTemplate[lines][48];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
displayText(deviceTemplate);
success = false;
break;
}
case PLUGIN_WRITE:
{
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("PCD8544")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
lcd2->setCursor(event->Par2 - 1, event->Par1 - 1);
lcd2->println(tmpString.c_str());
}
if (tmpString.equalsIgnoreCase(F("PCD8544CMD")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
if (tmpString.equalsIgnoreCase(F("Clear")))
lcd2->clearDisplay();
}
break;
}
}
return success;
}
boolean displayText(char deviceTemplate[][48]){
String log = F("PCD8544: ");
String string = F("");
lcd2->clearDisplay();
lcd2->setTextSize(1);
lcd2->setTextColor(BLACK);
lcd2->setCursor(0,0);
for (byte x = 0; x < lines; x++)
{
String tmpString = deviceTemplate[x];
if (tmpString.length())
{
String newString = parseTemplate(tmpString, 48);
lcd2->setCursor(0,x*8);
lcd2->print(newString);
string+=newString+"\\";
}
}
log += String(F("displayed text: \"")) + String(string) + String(F("\""));
addLog(LOG_LEVEL_INFO, log);
lcd2->display();
return true;
}
#endif // USES_P208
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
You also have to define "USES_P208"
Add it to the appropriate line with "build_flags" in the platformio.ini file.
You add a define using the -D flag.
So for example in the [common] section:
build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
-D NDEBUG
-lstdc++ -lsupc++
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
-DVTABLES_IN_FLASH
-DUSES_P208
(See last part)
Add it to the appropriate line with "build_flags" in the platformio.ini file.
You add a define using the -D flag.
So for example in the [common] section:
build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
-D NDEBUG
-lstdc++ -lsupc++
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
-DVTABLES_IN_FLASH
-DUSES_P208
(See last part)
-
- Normal user
- Posts: 10
- Joined: 11 Sep 2016, 16:43
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
thanks for your response, i have tried that too, i think it is the same as adding the plugin to define_plugin_sets.h file under PLUGIN_SET_EXPERIMENTAL section and compile the dev build only, in both cases it does not show up in the list of plugins, i think it has something to do with the web form linesTD-er wrote: ↑05 Sep 2018, 22:03 You also have to define "USES_P208"
Add it to the appropriate line with "build_flags" in the platformio.ini file.
You add a define using the -D flag.
So for example in the [common] section:
build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
-D NDEBUG
-lstdc++ -lsupc++
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
-DVTABLES_IN_FLASH
-DUSES_P208
(See last part)
-
- Normal user
- Posts: 13
- Joined: 22 Sep 2018, 19:09
- Location: Poland
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
thanks for this post, i've succesfully add this plugin to espeasy, to do that You have to define this plugin into define_plugin_sets.h file - add a line " #define USES_P208 // nokia_lcd" in a version you choose - maybe "developer" one is the best option
without that, plugin won't be added to complied flash file.
after that all works a a charm.
PS. sorry for my english, that was my first attempt to compile firmware on my own by the way
without that, plugin won't be added to complied flash file.
after that all works a a charm.
PS. sorry for my english, that was my first attempt to compile firmware on my own by the way
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
is there someone on this forum who has a working Bin file for me that supports the nokia 5110?
i have been trying to get this working with the source code and atom and arduino ide butt only get errors compiling.
tried the latest version and the 147 rc8 butt no luck just errors.
don't unther stand why they aren't supported yet with the latest versions.
thanks for responding.
i have been trying to get this working with the source code and atom and arduino ide butt only get errors compiling.
tried the latest version and the 147 rc8 butt no luck just errors.
don't unther stand why they aren't supported yet with the latest versions.
thanks for responding.
-
- Normal user
- Posts: 125
- Joined: 28 Feb 2018, 07:40
- Location: Melbourne, Australia
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
It would be really great if people could do this as it helps others at least experience what has been do so far. For beginners it is often difficult to compile.
This plugin will be a great addition to the project. Thanks to all those who have contributed.
Friends with kangaroos and some time koala rescuer.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
+1 for someone with precompiled firmware with added support for Nokia LCD.
-
- Normal user
- Posts: 13
- Joined: 22 Sep 2018, 19:09
- Location: Poland
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
compiled firmware in an attachment. (unpack & change extension of course...)
1st gpio - 2 (d4)
wiring as in this topic.
and of course I'm not responsible for blah blah blah
1st gpio - 2 (d4)
wiring as in this topic.
and of course I'm not responsible for blah blah blah
- Attachments
-
- firmware.rar
- (496.1 KiB) Downloaded 673 times
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Thank You!
I have different pinouts, but i change that and LCD works.
I have different pinouts, but i change that and LCD works.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
That is a nice display, nice price as well?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
2,5€ in Poland.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Cool, we should consider it for the main repository then.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
-
- Normal user
- Posts: 13
- Joined: 22 Sep 2018, 19:09
- Location: Poland
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
the problem with this display is that it require much more gpios than i2c displays.
cieszę się, że mogłem pomóc
pozdrawiam.
cieszę się, że mogłem pomóc
pozdrawiam.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Hi all, I am very pleased that other ESPeasy enthusiasts also use the Nokia display. In many applications using the hardware SPI allows you to use the I2C and OneWire interface. And we still have Tx and Rx which can also be used - if we don't need a serial login I would be very grateful if you manage to include PCD8544 in the repository. I also have positive tests of NOKIA display with ESP32.
On the following photo - ESP07 (updated to 4MB) , BME280, Si7021, AM2305, 0,91" OLED Display, Nokia display and ... still RX and TX free.
Bestr regards ... i pozdrowienia dla kolegów z Polski
Adam
On the following photo - ESP07 (updated to 4MB) , BME280, Si7021, AM2305, 0,91" OLED Display, Nokia display and ... still RX and TX free.
Bestr regards ... i pozdrowienia dla kolegów z Polski
Adam
- Attachments
-
- IMG_20181022_093450_resized_20181022_093526854.jpg (174.45 KiB) Viewed 84563 times
Domoticz Beta release on OrangePI PC and BananaPI,
2x RFLink (last version),
ESPEasy, ESPEasy32 (different configurations),
MySensors (different configurations),
2x MiLight RGBW (over RFLink)
and others things
2x RFLink (last version),
ESPEasy, ESPEasy32 (different configurations),
MySensors (different configurations),
2x MiLight RGBW (over RFLink)
and others things
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Hi!
How to, the easiest way to add a PCD8544 plugin, to my Wemos D1 mini. I use this bin file ->ESP_Easy_mega-20181220_dev_ESP8266_4096. A small warning, I'm not a programmer
How to, the easiest way to add a PCD8544 plugin, to my Wemos D1 mini. I use this bin file ->ESP_Easy_mega-20181220_dev_ESP8266_4096. A small warning, I'm not a programmer
Armageddon was yesterday, today we have a serious problem.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
I'm interested too.
I don't know why not include this small and cheap display to official release
I don't know why not include this small and cheap display to official release
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
We're planning on adding a generic display plugin so at this time we're not accepting new display plugins. But I will make sure we support this display (I got a couple of them myself).
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Now i'm tray and work
Just upload file from post #23 (firmware.rar - change extension from .jpg to . bin !!!)
Connect: Wemos D1 mini > 5110 LCD:
// D5 > Serial clock out (SCLK)
// D7 > Serial data out (DIN)
// D8 > Data/Command select (D/C)
// D4 > LCD chip select (CS)
// GND > LCD reset (RST)
// GND > GND
// 3.3V> VCC
// GND > Light (if you need)
SET: 1st gpio - 2 (d4)
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Hello to fellow users.
I have this board
https://www.ebay.co.uk/itm/NodeMCU-V3-2 ... SwI7Fb3x~a
I flash it with firmware.bin from post
I have this NOKIA 5110 module
https://grobotronics.com/graphic-lcd-84 ... -5110.html
Module is capable to work with 3V & 5V controller (test it with my board from Andruino IDE)
Could anyone give any info about wiring?
I have read in detail all posts but something is missing I think.
Thanks in advance.
PS. I see CARMIN has similar devices. Could give wiring diagram? Thanks
I have this board
https://www.ebay.co.uk/itm/NodeMCU-V3-2 ... SwI7Fb3x~a
I flash it with firmware.bin from post
I have this NOKIA 5110 module
https://grobotronics.com/graphic-lcd-84 ... -5110.html
Module is capable to work with 3V & 5V controller (test it with my board from Andruino IDE)
Could anyone give any info about wiring?
I have read in detail all posts but something is missing I think.
Thanks in advance.
PS. I see CARMIN has similar devices. Could give wiring diagram? Thanks
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Did you try with my pinout - i think it's same
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Nope I have tried and it didn't work.
But I am waiting a new Mini D1 just to check it out.
It is possible that D4 (GPIO2) maybe it is reserved in my board?
If so it need recompile plugin?
My opinion that NOKIA 5110 display is a MUST for stable tree.
Thanks for your answers.
But I am waiting a new Mini D1 just to check it out.
It is possible that D4 (GPIO2) maybe it is reserved in my board?
If so it need recompile plugin?
My opinion that NOKIA 5110 display is a MUST for stable tree.
Thanks for your answers.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
I think that following question is probably stupid, but I have to ask.
I am uploading firmware.bin with latest EASYESP Flash tool.
Is it OK or I have to use a specific version?
Is there any chance bootloader of ESP8266 to be different from older boards and
won't work my Nokia 5110.
Is there any special "treatment" on line fields of plugin?
Thanks again for your answers
I am uploading firmware.bin with latest EASYESP Flash tool.
Is it OK or I have to use a specific version?
Is there any chance bootloader of ESP8266 to be different from older boards and
won't work my Nokia 5110.
Is there any special "treatment" on line fields of plugin?
Thanks again for your answers
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
My nick is Cramin not Carmin.
Look at pinout:
Look at pinout:
And look at my image and pin layout, its changed. But when you properly connect it its working fine. PIN1 > VCC > in my LCD VCC is PIN6adampr1 wrote: ↑23 Nov 2016, 13:50 Please check if you display have equal pin sequence :
PIN1 > Vcc,
PIN2 > GND,
PIN3 > SCE,
PIN4 > RST,
PIN5 > D/C,
PIN6 > DIN,
PIN7 > SCLK,
PIN8 > LED
IMPORTANT - in ESPEasy configuration it shows as I2C device with suggest that PIN 4 and 5 are used by PCD8544 plugin but they are NOT (I'll correct it next week - sorry no time). Followed code use only GPIO2,13,14,15
PIN's connection for display are hardcoded. Don't change them.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
My apologies. It is the daemon of the keyboard! I am in Greece.
Yes I checked & double checked wiring and pin out.
Your display is same with mine (mine its just blue PCB).
ESP8266 it is not the same.
Yes I have remap wiring according to diagram but no it does not working with my ESP8266 board.
I have also checked and enabled init SPI on Hardware tab.
Still no luck.
But when I implement the following project
https://simple-circuit.com/esp8266-node ... -5110-lcd/
everything works fine!
Attention this project uses 5GPIO wiring! Not 4 as I understand uses plugin.
So where is the mystery? Is it possible some library causes overlap pin configuration?
My goal is to have just an ESPEasy with Nokia module only to display values.
Nothing more.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
FIXED UP!
You have to connect RST from Nokia 5110 to RST of ESP8266 Board.
Do not check enable init SPI on Hardware Tab.
First GPIO2 (D4)
Don't check GPIO LED & Inversed LED on Hardware Tab
Working wiring is following
Vcc -> 3.3V
GND -> GND
CE -> D4
RST -> RST of ESP8266 lolin
D/C -> D8
DIN -> D7
CLK -> D5
B/L -> any pin of your choice (specific board is 3.3/5V compatible and you can use direct connection of BL to
esp pin but it is recommended to use a 330Ω resistor-BE Careful not fried up your board)
My board is this and my Nokia5110 LCD is this
You have to connect RST from Nokia 5110 to RST of ESP8266 Board.
Do not check enable init SPI on Hardware Tab.
First GPIO2 (D4)
Don't check GPIO LED & Inversed LED on Hardware Tab
Working wiring is following
Vcc -> 3.3V
GND -> GND
CE -> D4
RST -> RST of ESP8266 lolin
D/C -> D8
DIN -> D7
CLK -> D5
B/L -> any pin of your choice (specific board is 3.3/5V compatible and you can use direct connection of BL to
esp pin but it is recommended to use a 330Ω resistor-BE Careful not fried up your board)
My board is this and my Nokia5110 LCD is this
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
OK now I have a probably logical question!
Why NOKIA5110 plugin is not at least in development firmware of ESPeasy?
I mean if it is alpha/beta or anything else it should be at least on testing or development firmware.
Right?
Why NOKIA5110 plugin is not at least in development firmware of ESPeasy?
I mean if it is alpha/beta or anything else it should be at least on testing or development firmware.
Right?
- Andrew Mamohin
- Normal user
- Posts: 95
- Joined: 12 Jun 2020, 08:30
- Location: Belarus, Gomel
- Contact:
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
I have two such displays. I would like to use them in ESPeasy. Maybe someone will give me a fresh build, including a plugin for NOKIA5110?
Andy.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Well, it's a bit hard (for me at least) to create a build, for a couple of reasons. a) It is an older plugin, and uses no longer supported functions and objects, b) it uses a not yet supported library, c) it is using the SPI interface, and that isn't much used with ESPEasy, d) I don't have such display, and it will take a couple of weeks to get one here, so while I may eventually get it working, it'll have to await testing until I receive a display.Andrew Mamohin wrote: ↑30 Jul 2020, 18:36 I have two such displays. I would like to use them in ESPeasy. Maybe someone will give me a fresh build, including a plugin for NOKIA5110?
/Ton (PayPal.me)
- Andrew Mamohin
- Normal user
- Posts: 95
- Joined: 12 Jun 2020, 08:30
- Location: Belarus, Gomel
- Contact:
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Then don't worry! I just won't be using these displays with espeasy. I will attach them to arduino.
Andy.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
The advantage of these displays over the OLed displays is that they are a bit larger, thus easier to read from some 'distance' (~1 meter), while an average OLed requires me to be within ~60 cm to be readable (age has quite an influence on the eyes ), so experimenting with it is just for fun, and they aren't expensive when buying from Aliexpress .Andrew Mamohin wrote: ↑01 Aug 2020, 16:18 Then don't worry! I just won't be using these displays with espeasy. I will attach them to arduino.
Disadvantage is the rather low resolution (84x48), but I'll be able to squeeze all the info on it, I think.
I'll probably want to add the oledframed-like commands too, so, not being a C++ programmer, that'll be a bit of a challenge (though I've contributed a few PRs to ESPEasy).
/Ton (PayPal.me)
- Andrew Mamohin
- Normal user
- Posts: 95
- Joined: 12 Jun 2020, 08:30
- Location: Belarus, Gomel
- Contact:
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
I find these displays are more durable with continuous use.
Andy.
- Andrew Mamohin
- Normal user
- Posts: 95
- Joined: 12 Jun 2020, 08:30
- Location: Belarus, Gomel
- Contact:
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Plugin: https://github.com/letscontrolit/ESPEas ... 6_eInk.ino
In the file are some links.
In the file are some links.
- Andrew Mamohin
- Normal user
- Posts: 95
- Joined: 12 Jun 2020, 08:30
- Location: Belarus, Gomel
- Contact:
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
This is a very high price for me. $9.90 + $5.28 = $15.18
I bought the display 5110 for $1.8
Andy.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
It looks like, this plugin is not working any more on ESPEasy_ESP32_mega-20201130.
Does somebody knows how to solve this compiling error: I'v treid to sole this problem for many hours....
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:99:39: error: expected primary-expression before '.' token
String tmpString = WebServer.arg(argc);
^
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:127:20: warning: unused variable 'setTextWrap' [-Wunused-variable]
boolean setTextWrap = false;
^
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:149:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
^
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:154:138: error: 'setPinState' was not declared in this scope
setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
^
^
*** [.pio\build\custom_ESP32_4M316k\src\ESPEasy.ino.cpp.o] Error 1
Does somebody knows how to solve this compiling error: I'v treid to sole this problem for many hours....
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:99:39: error: expected primary-expression before '.' token
String tmpString = WebServer.arg(argc);
^
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:127:20: warning: unused variable 'setTextWrap' [-Wunused-variable]
boolean setTextWrap = false;
^
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:149:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
^
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:154:138: error: 'setPinState' was not declared in this scope
setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
^
^
*** [.pio\build\custom_ESP32_4M316k\src\ESPEasy.ino.cpp.o] Error 1
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
There are probably more things to change, but for starters, change WebServer into web_server.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
I have done some initial work on this plugin, but didn't get it to display any text yet , I've shelved it for a while already, and probably give it a retry in the new year
/Ton (PayPal.me)
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Great, changing WebServer into web_server works.
Now i'm struggling with these two errors. Does anyone have any advice?
_P208_LCD_PCD8544.ino:149:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
_P208_LCD_PCD8544.ino:154:138: error: 'setPinState' was not declared in this scope
setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
Now i'm struggling with these two errors. Does anyone have any advice?
_P208_LCD_PCD8544.ino:149:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
_P208_LCD_PCD8544.ino:154:138: error: 'setPinState' was not declared in this scope
setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
I guess adding this as the first line of your .ino file will fix a lot of (future) compile errors:
But setPinState is no longer implemented in the code, so you will need to make a lot more changes which makes it very hard to tell you what you should change.
This means I probably have to look at the code myself to see what else is missing or needs to be changed.
Code: Select all
#include "_Plugin_Helper.h"
This means I probably have to look at the code myself to see what else is missing or needs to be changed.
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
I had already included the line "#include "_Plugin_Helper.h".....
-
- New user
- Posts: 8
- Joined: 06 Feb 2021, 20:25
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Hi Everybody,
i have successfully connected the LCD with the precompiled Image.
On thing won't work. Sending of display text via http cmd won't work.
As i understand the plugin code the behaviour should be compatible to the lcd2004 plugin:
http://192.168.1.242/control?cmd=pcd854 ... TTODISPLAY
But nothing appears. No Logging. But no message "wrong or unknown command". Thats appearing if you use cmd=whatever.
It's a pity, that the code isn'T working with the actual ESPEasy Source.
Any Idea, or what i'm doing wrong?
BR
Stephan
i have successfully connected the LCD with the precompiled Image.
On thing won't work. Sending of display text via http cmd won't work.
As i understand the plugin code the behaviour should be compatible to the lcd2004 plugin:
http://192.168.1.242/control?cmd=pcd854 ... TTODISPLAY
But nothing appears. No Logging. But no message "wrong or unknown command". Thats appearing if you use cmd=whatever.
Code: Select all
case PLUGIN_WRITE:
{
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("PCD8544")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
lcd2->setCursor(event->Par2 - 1, event->Par1 - 1);
lcd2->println(tmpString.c_str());
}
if (tmpString.equalsIgnoreCase(F("PCD8544CMD")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
if (tmpString.equalsIgnoreCase(F("Clear")))
lcd2->clearDisplay();
}
break;
}
It's a pity, that the code isn'T working with the actual ESPEasy Source.
Any Idea, or what i'm doing wrong?
BR
Stephan
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
What exact build did you use?
Asking this because lots of users still install old builds linked from some blog post for example.
Asking this because lots of users still install old builds linked from some blog post for example.
-
- New user
- Posts: 8
- Joined: 06 Feb 2021, 20:25
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
Hi,
I don't have tried to compile it by myself.
I have downloaded the binary from Post #23:
viewtopic.php?p=32154#p32154
And i have read the draft for the plugin. And read within this thread, that the plugin is only usable with sources around 2018.
So the next step for me is:
try to update the plugin to compile with actual releases, and / or use a release from ~2018.
Then it's possible to (re)check, if the http command will work.
In the precompiled version only the following informations are found on the info page:
Update:
Setting up platformio with visual studio code and compiling a unchanged repository successfully.
Now i have made the first advises to create a updated plugin.
Change for setPinState (might be the right way, after study of other plugins)
Compiling done and image is working. Display is showing the configured lines.
Next step: verify http command....
BR
Stephan
I don't have tried to compile it by myself.
I have downloaded the binary from Post #23:
viewtopic.php?p=32154#p32154
And i have read the draft for the plugin. And read within this thread, that the plugin is only usable with sources around 2018.
So the next step for me is:
try to update the plugin to compile with actual releases, and / or use a release from ~2018.
Then it's possible to (re)check, if the http command will work.
In the precompiled version only the following informations are found on the info page:
Code: Select all
Build 20102 - Mega
Libraries ESP82xx Core 2_4_2, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.0.3
GIT version
Plugins 73 [Normal] [Testing]
Build Md5 4d44355f4d44355f4d44355f4d44355f
Md5 check fail !
Build time Sep 22 2018 19:29:53
Binary filename ThisIsTheDummyPlaceHolderForTheBinaryFilename64ByteLongFilenames
Setting up platformio with visual studio code and compiling a unchanged repository successfully.
Now i have made the first advises to create a updated plugin.
Change for setPinState (might be the right way, after study of other plugins)
Code: Select all
pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT);
digitalWrite(Settings.TaskDevicePin3[event->TaskIndex],Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
// setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
portStatusStruct newStatus;
const uint32_t key = createKey(1, Settings.TaskDevicePin3[event->TaskIndex]);
// WARNING: operator [] creates an entry in the map if key does not exist
newStatus = globalMapPortStatus[key];
newStatus.command = 1;
newStatus.mode = PIN_MODE_OUTPUT;
newStatus.state = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
savePortStatus(key, newStatus);}
Compiling done and image is working. Display is showing the configured lines.
Next step: verify http command....
BR
Stephan
-
- New user
- Posts: 8
- Joined: 06 Feb 2021, 20:25
Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin
One step forward.
Find here the code for the PCD8544 Display compatible to ESP_Easy_mega_20210207.
Something might be buggy. The ESP was sometime not directly reachable. But i don't find any reason or logging about.
Feel free to optimize the code, but give here some feedback.
// Working:
// - Display Text & Var via ESPEasy Webinterface (Line1-LineX)
// - Clear Display via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,clear)
// - Send Text via httpcmd (but don't clear the line ) (http://ESP-IP/control?cmd=pcd8544,1,1,Hello%20World!)
//
// Mixed Mode (Display Data from ESP Easy and HTTP-request) is not easy to handle. Some problems are known from P012 LCD2004 Plugin
// Set Interval to 0 seconds for only using the http requests. Otherwise display clear will occur every cycle.
//
//
// ToDo:
// - If no Data via Webinterface (Line 1-x) exists. don't clear the display or no update!
// - How to "overwrite" via Webcmd the actual line. -> No garbage character
// (introduce clear line command? depending on orientation write n spaces. then write the new text?)
Find here the code for the PCD8544 Display compatible to ESP_Easy_mega_20210207.
Something might be buggy. The ESP was sometime not directly reachable. But i don't find any reason or logging about.
Feel free to optimize the code, but give here some feedback.
// Working:
// - Display Text & Var via ESPEasy Webinterface (Line1-LineX)
// - Clear Display via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,clear)
// - Send Text via httpcmd (but don't clear the line ) (http://ESP-IP/control?cmd=pcd8544,1,1,Hello%20World!)
//
// Mixed Mode (Display Data from ESP Easy and HTTP-request) is not easy to handle. Some problems are known from P012 LCD2004 Plugin
// Set Interval to 0 seconds for only using the http requests. Otherwise display clear will occur every cycle.
//
//
// ToDo:
// - If no Data via Webinterface (Line 1-x) exists. don't clear the display or no update!
// - How to "overwrite" via Webcmd the actual line. -> No garbage character
// (introduce clear line command? depending on orientation write n spaces. then write the new text?)
Code: Select all
#ifdef USES_P208
//#######################################################################################################
//################################## Plugin 208: NOKIA lcd2 ###############################################
//#######################################################################################################
// Working:
// - Display Text & Var via ESPEasy Webinterface (Line1-Linex)
// - Clear Display via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,clear)
// - Send Text via httpcmd (but don't clear the line :-( ) (http://ESP-IP/control?cmd=pcd8544,1,1,Hello%20World!)
//
// Mixed Mode (Display Data from ESP Easy and HTTP-request) is not easy to handle. Some problems are known from P012 LCD2004 Plugin
// Set Interval to 0 seconds for only using the http requests
//
// ToDo:
// - If no Data via Webinterface (Line 1-x) exists. don't clear the display or no update!
// - How to "overwrite" via Webcmd the actual line. -> No garbage character
//
#define PLUGIN_208
#define PLUGIN_ID_208 208
#define PLUGIN_NAME_208 "Display - LCD PCD8544 [TESTING]"
#define PLUGIN_VALUENAME1_208 "Backlight"
#define PLUGIN_VALUENAME2_208 "Contrast"
#define PLUGIN_VALUENAME3_208 "Rotation"
#include "_Plugin_Helper.h"
//#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
Adafruit_PCD8544 *lcd2;
byte lines = 6;
boolean Plugin_208(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_208 ;
Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_SINGLE;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = false;
Device[deviceCount].ValueCount = 3;
Device[deviceCount].SendDataOption = false;
Device[deviceCount].TimerOption = true;
Device[deviceCount].TimerOptional = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_208);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_208));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_208));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_208));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
addFormNumericBox(F("Display Contrast(50-100):"), F("plugin_208_contrast"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
addFormPinSelect(F("Backlight PIN"), F("taskdevicepin3"), Settings.TaskDevicePin3[event->TaskIndex]);
byte choice3 = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
int optionValues3[4] = { 0, 1, 2, 3 };
String options3[4] = { F("0"), F("90"), F("180"), F("270") };
addFormSelector(F("Display Rotation"), F("plugin_208_rotation"), 4, options3, optionValues3, choice3);
byte choice4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options4[2] = { F("ON"), F("OFF") };
int optionValues4[2] = { 0, 1 };
addFormSelector(F("Backlight"), F("plugin_208_backlight"), 2, options4, optionValues4, choice4);
char deviceTemplate [lines][48];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
for (byte varNr = 0; varNr < lines; varNr++)
{
addFormTextBox(String(F("Line ")) + (varNr + 1), String(F("Plugin_208_template")) + (varNr + 1), deviceTemplate[varNr], 80);
}
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_208_backlight"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_208_contrast"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_208_rotation"));
char deviceTemplate[lines][48];
for (byte varNr = 0; varNr < lines; varNr++)
{
char argc[25];
String arg = F("Plugin_208_template");
arg += varNr + 1;
arg.toCharArray(argc, 25);
String tmpString = web_server.arg(argc);
strncpy(deviceTemplate[varNr], tmpString.c_str(), sizeof(deviceTemplate[varNr]));
}
// Settings.TaskDeviceID[event->TaskIndex] = 1; // temp fix, needs a dummy value
SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
success = true;
break;
}
case PLUGIN_INIT:
{
if (!lcd2)
{
// pin 14 - Serial clock out (SCLK)
// pin 13 - Serial data out (DIN)
// pin 12 - Data/Command select (D/C)
// pin 5 - LCD chip select (CS)
// pin 4 - LCD reset (RST)
//lcd2 = new Adafruit_PCD8544(14, 13, 12, 5, 4);
#if defined(ESP8266)
lcd2 = new Adafruit_PCD8544(15, 2, -1); // D/C (need to be connected) GPIO2 , CS(CEN) GPIO15 , RESET not connected
#endif
#if defined(ESP32)
lcd2 = new Adafruit_PCD8544(16, 17, -1); // D/C (need to be connected) GPIO16 , CS(CEN) GPIO17 , RESET not connected
#endif
boolean setTextWrap = false;
}
// Setup lcd2 display
byte plugin1 = Settings.TaskDevicePluginConfig[event->TaskIndex][2]; // rotation
byte plugin2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1]; // contrast
byte plugin4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0]; // backlight_onoff
UserVar[event->BaseVarIndex+2]=plugin1;
UserVar[event->BaseVarIndex+1]=plugin2;
UserVar[event->BaseVarIndex]=!plugin4;
if (plugin1==0 || plugin1==2)
{
lines=6;
}
else{
lines=10;
}
lcd2->begin(); // initialize the lcd2
lcd2->setContrast(plugin2);
lcd2->setRotation(plugin1);
lcd2->clearDisplay();
char deviceTemplate[lines][48];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
displayText(deviceTemplate);
lcd2->display();
if (Settings.TaskDevicePin3[event->TaskIndex] != -1){
pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT);
digitalWrite(Settings.TaskDevicePin3[event->TaskIndex],Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
// setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
portStatusStruct newStatus;
const uint32_t key = createKey(1, Settings.TaskDevicePin3[event->TaskIndex]);
// WARNING: operator [] creates an entry in the map if key does not exist
newStatus = globalMapPortStatus[key];
newStatus.command = 1;
newStatus.mode = PIN_MODE_OUTPUT;
newStatus.state = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
savePortStatus(key, newStatus);}
success = true;
break;
}
case PLUGIN_READ:
{
char deviceTemplate[lines][48];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
displayText(deviceTemplate);
success = false;
break;
}
case PLUGIN_WRITE:
{
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("PCD8544")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
lcd2->setTextSize(1);
int colPos = event->Par2 - 1;
int rowPos = event->Par1 - 1;
lcd2->setCursor(colPos, rowPos*8); // 8 Pixel
//addLog(LOG_LEVEL_INFO, F("Position set"));
lcd2->println(tmpString.c_str());
lcd2->display();
}
if (tmpString.equalsIgnoreCase(F("PCD8544CMD")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
if (tmpString.equalsIgnoreCase(F("Clear")))
// addLog(LOG_LEVEL_INFO, F("Clear Display"));
// Works!
lcd2->clearDisplay();
lcd2->display();
}
break;
}
}
return success;
}
boolean displayText(char deviceTemplate[][48]){
String log = F("PCD8544: ");
String string = F("");
lcd2->clearDisplay();
lcd2->setTextSize(1);
lcd2->setTextColor(BLACK);
lcd2->setCursor(0,0);
for (byte x = 0; x < lines; x++)
{
String tmpString = deviceTemplate[x];
if (tmpString.length())
{
String newString = parseTemplate(tmpString, 48);
lcd2->setCursor(0,x*8);
lcd2->print(newString);
string+=newString+"\\";
}
}
log += String(F("displayed text: \"")) + String(string) + String(F("\""));
addLog(LOG_LEVEL_INFO, log);
lcd2->display();
return true;
}
#endif // USES_P208
Who is online
Users browsing this forum: No registered users and 116 guests