So, i dont seem to understand how the LCD widget behavior is decided. I seem to be using the same code to run two separate LCDs via V2 and V5. The LCD on V2 blinks the data 3 times then erases the display, while the LCD on V5 flashes upon each update but retains the data on screen. I've troubleshot and found that it depends on which i call first in the main loop. the first called flashes ad gets erased while the second flashes and stays.
any idea how i can get them both to stay on screen? or how this is controlled? I've included a picture of the code for the functions.
I should also mention that the lcd.clear from the second called function is not the culprit because it is flashing after the second has been updated, and it flashes and disappears if i only run 1 LCD.
Summary: asking if you can turn on/off LCD blinking upon update and if you can turn on/off the data staying on screen
We might need to see the full sketch.
Its now under PrintDate(LCD6) and PrintSchedule(LCD7).
I aslo seem to be having trouble in the ConvM2C, where it updates the char* AP but not the int nhr after being called.
Thanks for looking at it
/*
* Tryin to get data from two sliders(V3&V4) and then display those values back to test LCD function using LCDs on V2&V5
*/
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
//-------------------------------------------------------------------------------------------------------------------------------------
char auth[] = "your auth number here"; // Auth Token Blynk App.
SimpleTimer timer;
WidgetRTC rtc;
BLYNK_ATTACH_WIDGET(rtc, V3);
int SttHrM;
int SttHrC;
int SttMin;
int StpHrM;
int StpHrC;
int StpMin;
int AutoSttHr;
int AutoSttMin;
int CustSttHr;
int CustSttMin;
int AutoStpHr;
int AutoStpMin;
int CustStpHr;
int CustStpMin;
int Mode;
int Latch;
int Test;
int Nhour;
char AmPm[5];
char AmPmStt[5];
char AmPmStp[5];
//------------------------------------------------------------------------------------------------
//*************************************** Print Time and Date
void PrintDate(){
WidgetLCD lcd(6);
lcd.clear();
ConvM2C(Nhour,hour(),AmPm);
lcd.print(1, 0, Nhour);
lcd.print(4, 0, minute());
lcd.print(7, 0, second());
lcd.print(10, 0, AmPm);
lcd.print(3, 1, day());
lcd.print(6, 1, month());
lcd.print(9, 1, year());
}
//*************************************** Print the Start and Stop Schedule
void PrintSchedule(){
WidgetLCD lcd(7);
lcd.clear();
ConvM2C(SttHrC,SttHrM,AmPmStt);
lcd.print(0, 0, "Start- ");
lcd.print(7, 0, CustSttHr);
lcd.print(9,0,":");
lcd.print(10,0, SttMin);
lcd.print(12,0, AmPmStt);
ConvM2C(StpHrC,StpHrM,AmPmStp);
lcd.print(0, 1, "Stop- ");
lcd.print(7, 1, StpHrC);
lcd.print(9,1,":");
lcd.print(10,1, StpMin);
lcd.print(12,1, AmPmStp);
}
//****************************************** Check Mode And Set Schedule
void SetSchedule(){
if ( Mode == 0){
SttHrM = AutoSttHr;
SttMin = AutoSttMin;
StpHrM = AutoStpHr;
StpMin = AutoStpMin;
}
else{
SttHrM = CustSttHr;
SttMin = CustSttMin;
StpHrM = CustStpHr;
StpMin = CustStpMin;
}
}
//****************************************** convert time from military to civilian
void ConvM2C(int nhr, int hr, char* AP){
if (hr > 12){
nhr = hr - 12;
strcpy (AP,"P.M.");
}
else {
nhr = hr;
strcpy (AP,"A.M.");
}
}
//********************************** Dummy Auto Times
void DummyAuto(){
AutoSttHr = 21;
AutoSttMin = 0;
AutoStpHr = 9;
AutoStpMin = 30;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------
BLYNK_WRITE(V0) {
Mode=param.asInt();
}
BLYNK_WRITE(V1) {
Latch=param.asInt();
}
BLYNK_WRITE(V2) {
Test=param.asInt();
}
//*************************************** Get and manange Custom Start time data
BLYNK_WRITE(V4) {
int CustStart = param.asInt();
CustSttHr = CustStart/100;
CustSttMin = (CustStart - CustSttHr*100);
if (CustSttMin > 59){
CustSttMin = 0;
CustSttHr = CustSttHr + 1;
}
}
//************************************** Get and manage Custom Stop time data
BLYNK_WRITE(V5) {
int CustStop = param.asInt();
CustStpHr = CustStop/100;
CustStpMin = (CustStop - CustStpHr*100);
if (CustStpMin > 59){
CustStpMin = 0;
CustStpHr = CustSttHr + 1;
}
}
//----------------------------------------------------------------------------------------------
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, "SSID","PASSWORD");
// timer.setInterval(10, uselcd5); // uncomment and comment out loop function call of uselcd5 to put function on timer
while (Blynk.connect() == false) { // Wait until connected
}
rtc.begin();
}
//-------------------------------------------------------------------------------------------------
void loop(){
// int hold=0;
// while (hold ==0){
BLYNK_CONNECTED();
if (true) {
Blynk.syncAll();
}
DummyAuto();
SetSchedule();
PrintDate();
PrintSchedule();
Blynk.run();
timer.run();
}
// }
SIlly Me, I fixed the ConvM2C like this, lcd still erases data on first LCD called though, even does it when only one LCD is used, { although both LCDs were on screen but only one being setup and called.}
//****************************************** convert time from military to civilian
int ConvM2C(int hr, char* AP){
int nhr;
if (hr > 12){
nhr = hr - 12;
strcpy (AP,"P.M.");
}
else {
nhr = hr;
strcpy (AP,"A.M.");
}
return nhr;
}
Upon further testing it seems that im also only getting data from Mode(V1), and nothing from Latch(V1) or Test(V2). I connected an LED and then printed them to the LCD and the only that would change from 0 to 1 no matter how long I waited was Mode(V1).
I’ve included a screenshot of my Blynk project, the numbers in the time slot for stop are actually the outputs of the buttons backwards, so it starts with test and ends with mode. even though test is unpressed i’ve tried it as well, the only one that can control the led from virtual pin data or have a 1 print to the LED is Mode(V0). I’ve tried changing them to other virtual pins, changing the order they were called, and even trying to change Latch(V1) to (D13) and physically control the LED. it was a nogo.
*Mode is (V0) as shown in code
Turned out to just be that it was printing the information too fast.
using timer.setinteval and delaying the information sent helped with the LCD screens. im still having issues getting all the data from the different widgets, but it is a different problem that i will start a new topic for once i thoroughly troubleshoot the program.
Just to mention here incase it sounds familiar and someone can answer before i make the other post. the issue is, i only get data from the GPS and the first 3 widgets i placed on the board, before the other data is sent and received, cmd error occurs and cmd skipped occurs multiple times. then a reconnect to the network to restart the process. I’ve read of SRAM issues but im using the latest Blynk as of 5/2/2016 and Arduino IDE 1.6.8 with a huzzah esp8266 standalone, which has 32k SRAM and i believe it compiles at 2k~ish. I’ll be sure to use the memory debug tools shown in the tutorial soon, but as i dont think its the issue im trying other things first.
i’ve also read things concerning setting your own mac address, i’ve not done this and what is the issue its causing if this is the problem.
ok, so i wasn’t able to get data from the virtual pins past the third because i had this code
BLYNK_CONNECTED();
if (true) {
Blynk.syncAll();
}
in my main loop, and it was pulling data in like crazy, and causing the error, is this a normal issue or does it have something to do with the router kicking the ESP if it makes too many requests in a given time?
i solved it by putting it the code in a function and setting the interval to every second, no more disconnects.