Bluetooth Display - Teil 6

Welcome to the sixth and last part of our Bluetooth display row.

Also in this part I have thought up again something nice as a supplement to the present functions. In the today's part we will devote ourselves to the energy and battery management of the unity. This as a supplement to the last part with which we have used our display as an advertising board on the flea market. On the flea market there is seldom plug, so that we must pursue our display with a power bank. What goes out, however, if to us the energy, or we want to know whether the care tension still amounts to 5 volts? This goes best of all, while we use one of the Analogously entrances to the measurement of the voltage and indicate directly in volt the operating voltage on our display.

Moreover, an energy savings function which we can serve with the tax elements eigebauten up to now (tracer) would make sense. Now besides our display gets finally one more Debug function given which helps us to find mistake at technical level and a relief with enlargements of the code with itself brings.

So that, however, our display can grasp first of all the tension of the care überhaut, it is to be carried out inevitably an other small hardware enlargement. This enlargement passes of the connection of the Analogously port 5 with the operating voltage VDD. In the following the connection existing of a wire bridge is illustrated in the diagramme and is marked by a red arrow.

Also in this part we pick up an enlargement or adaptation of the proficient ware spring code before and load, hence, the following code on the Arduino:

 

#include <SPI.H>
#include <Wire.H>
#include <SoftwareSerial.H>
#include <EEPROM.H>
#include <LiquidCrystal.H>
#include <avr/sleep.H>

#define MaxInputBufferSize 20 //maximum 255 signs adapt in vlcdr
#define EEpromSize 990

#define rLcdChr 20
#define LcdRows 4
#define interval 1000
#define BackgroundLight 5 //Port 5 background lighting LED
#define VoltageSensingPin 5 // 
#define SwitchPin 2 //Port 12 tracers news choice
#define DelayTOPWROFF 500 
#define MinOPVoltage 3.4

//Memory cell addresses EEprom for configuration
#define EEFadeSeconds  993
#define EEAdvertsecdelay 994
#define EEAdvertMsg 995
#define EEPINA 996
#define EEPINC 997
#define EEPINDD 998 

SoftwareSerial mySerial(7, 6); //RX, TX

//LiquidCrystal (rs, enable, d4, d5, d6, d7) 
LiquidCrystal lcd(8, 13, 12, 11, 10, 9);


//the variable
byte Display bank contents = 0; 

//Serial input Handling
char TBuffer;
char Cbuffer[MaxInputBufferSize+1];       //Code USB input buffer
String Sbuffer = "";                      //String USB input buffer
int value;                                //Input USB Nummeric buffer
byte Ccount = 0;                          //Number received Chars
byte Inptype = 0;
boolean StrInput = false;
boolean NumberInput = false;
boolean DataInput = false;
boolean EnterInput = false;
byte MenueSelection = 0;

//Pushbutton control
boolean Switchstate = true;
boolean SwitchstateBuffer = true;
byte SelectedMsg = 0;

//Give Debug Informations over serial interface
boolean DebugMode = false;
boolean Echo fashion = true;

//EEPROM
int eeaddress;                 //Pointer EEPROM Adress
byte EEPromBanks = 0;          //Used for Calculating the Banks EEPROM
//SerMnueControl
byte MnuState = 0;            //Maximum menu depth 255 icl Sub
byte Selectedbank =0;

//Real time Clock 
long previousMillis = 0;       //want interferes time read what measured
long previousMillisB = 0;       //want interferes time read what measured

//Display management
boolean DisplayLock = false;
boolean Directprint = false;
byte DirectprintROW = 0;
byte DirectprintLine = 0;

boolean RefreshDisplay = false;
byte FRMCheck = 0; //Used fpr Writing Operations to eeprom saves so landlords cycles
//Battery monitoring
float Voltage;
boolean Power ave fashion = false;

//Light control PWM 

byte Currentbrightness = 0;
byte Targetbrightness = 0;
byte FadeSeconds = 0; //Standard = 3

//Car Display Z.B for advertisement purposes

boolean Advertising = false;
byte AdvertMsg = 1; //Minimum 1
byte Advertsecdelay = 0; //Standard = 6
byte Advertseccounter = 0;


void set-up()    {    EEPromBanks = EEpromSize / ((rLcdChr) * LcdRows);   lcd.begin(rLcdChr, LcdRows);   lcd.clear();   lcd.set cursor(0, 0);   lcd.print("Bluetooth");   lcd.set cursor(0, 1);   lcd.print("Display");   mySerial.begin(9600);   pinMode(SwitchPin,INPUT_PULLUP); //Tracer choice text from EEprom   pinMode(BackgroundLight,OUTPUT); //Display lighting / display IN / FROM   digitalWrite(BackgroundLight,LOW);   //Read Config   FadeSeconds = EEPROM.Read(EEFadeSeconds);    Advertsecdelay =EEPROM.Read(EEAdvertsecdelay);   AdvertMsg =EEPROM.Read(EEAdvertMsg);   Currentbrightness = 0;   Targetbrightness = 0;   lcd.set cursor(0, 4);   if (DisplayLock) {  lcd.print(" System closed"); }   //Further set-up Routines / initalizing   lcd.set cursor(0, 0);   Targetbrightness = 255;   mySerial.flush();
}

// ###################################################################################################### //

void loop() 
{
SerialcommandProcessor();
runrealTimeClock();
Displayprocessor();
SwitchProcessor();
//The Main loop
}

// ###################################################################################################### //


void TextHeader(byte rowm)
{    mySerial.println("Text for bank" + String( Selectedbank) + "ROW" + String (rowm) + ":");   }

void SerialcommandProcessor()
{
int a;
Inptype = 0;
Inptype = SerInputHandler();
//0 no return 
//1 number 
//2 strings 
//3 Data

if ((Inptype > 0) & (!Directprint))                {    if (Power ave fashion) {    TogglePowerSave(false);      }      MenueSelection = 0;    if (Advertising)    {      lcd.clear();      Advertising = false;      mySerial.print(AND THE FOLLOWING("Advertising"));      mySerial.println(AND THE FOLLOWING(" OUT OF VISION."));      }    if ((MnuState < 2) && (Inptype == 2)) {Sbuffer.toUpperCase(); } //For easy duck's ring Commands    if ((Sbuffer == "DEBUG") && (MnuState == 0) && (Inptype == 2))   { MenueSelection = 1;}    if ((Sbuffer == "ECHO")&& (MnuState == 0) && (Inptype == 2))       { MenueSelection = 2;}    if ((Sbuffer == "S") && (MnuState == 0) && (Inptype == 2))       { MenueSelection = 3;}    //Erasing ALL contents EEprom    if ((Sbuffer == "E") && (MnuState == 0) && (Inptype == 2))       { MenueSelection = 4;}    if ((Sbuffer == "YES") && (MnuState == 1)&& (Inptype == 2))      { MenueSelection = 5;}    if ((Sbuffer != "YES") && (MnuState == 1) && (Inptype == 2))     { MenueSelection = 6;}    //Edit Selected contents    if ((Sbuffer == "W") && (MnuState == 0) && (Inptype == 2))       { MenueSelection = 7;}    if ((MnuState == 2) && (value  < EEPromBanks) && (Inptype == 1)) { MenueSelection = 8;}    if (MnuState == 3)                                               { MenueSelection = 9;}    if (MnuState == 4)                                               { MenueSelection = 10;}    //Display Selected contents    if ((Sbuffer == "P") && (MnuState == 0) && (Inptype == 2))       { MenueSelection = 11;}    if ((MnuState == 5) && (Inptype == 1))                           { MenueSelection = 12;}    if ((Sbuffer == "R") && (MnuState == 0) && (Inptype == 2))       { MenueSelection = 13;}    if ((MnuState == 6) && (Inptype == 1))                           { MenueSelection = 14;}    if ((Sbuffer == "D") && (MnuState == 0) && (Inptype == 2))       { MenueSelection = 15;}    if ((Sbuffer == "Z") && (MnuState == 0) && (Inptype == 2))       { MenueSelection = 16;}    if ((Sbuffer == "B") && (MnuState == 0) && (Inptype == 2))       { MenueSelection = 17;}    if ((MnuState == 7) && (Inptype == 1))                           { MenueSelection = 18;}    if ((Sbuffer == "TASTELESS") && (MnuState == 0) && (Inptype == 2))     { MenueSelection = 19;}    if (MnuState == 9)                                               { MenueSelection = 20;}    if (MnuState == 10)                                              { MenueSelection = 21;}    if ((Sbuffer == "A") && (MnuState == 0) && (Inptype == 2))       { MenueSelection = 22;}    if ((Sbuffer == "ADVERT") && (MnuState == 0) && (Inptype == 2))  { MenueSelection = 23;}    if (MnuState == 11)                                              { MenueSelection = 24;}    if (MnuState == 12)                                              { MenueSelection = 25;}    if ((Sbuffer == "ADSEC") && (MnuState == 0) && (Inptype == 2))   { MenueSelection = 26;}    if (MnuState == 13)                                              { MenueSelection = 27;}    if ((Sbuffer == "ADMSG") && (MnuState == 0) && (Inptype == 2))   { MenueSelection = 28;}    if (MnuState == 14)                                              { MenueSelection = 29;}      switch (MenueSelection)      {        case 1:            {          mySerial.print("Debug");          DebugMode = !DebugMode;          if (DebugMode) {          mySerial.println(AND THE FOLLOWING(" ON."));          Echo fashion = false;           } else           {              mySerial.println(AND THE FOLLOWING(" OUT OF VISION."));             Echo fashion = true;           }          mySerial.println("");          mySerial.flush();          value = 0;          MnuState = 0;          Sbuffer = "";          break;        }        case 2:            {           mySerial.print(AND THE FOLLOWING("Echo"));           Echo fashion = !Echo fashion;           if (Echo fashion) {             mySerial.println(AND THE FOLLOWING(" ON."));             DebugMode = false;             } else             {              mySerial.println(AND THE FOLLOWING(" OUT OF VISION."));             }           mySerial.println(AND THE FOLLOWING(""));           mySerial.flush();           value = 0;           MnuState = 0;           Sbuffer = "";           break;        }        case 3:            {          mySerial.println(AND THE FOLLOWING("Read EEEPROM Content:" ));          mySerial.flush();          for (int a = 0; a < EEPromBanks; a++)            {              mySerial.println("EEPROM Memory Bank:" + String(a) );              mySerial.flush();              for (int B = 1; B <= LcdRows;B++)                 {                   mySerial.print("Row" + String(B) +": ");                   mySerial.flush();                   for (int C = 0; C <rLcdChr; C++)                       {                         eeaddress = 0;                           eeaddress = (a * (rLcdChr)* LcdRows) + ((rLcdChr) * B) + C;                         value = EEPROM.Read(eeaddress);                         mySerial.print(char(value));                         mySerial.flush();                                              }                   mySerial.println(AND THE FOLLOWING(" "));                   mySerial.flush();                 }                                           }                    Sbuffer = "";          mySerial.println(AND THE FOLLOWING("No more EEPROM Banks available."));          mySerial.flush();          break;        }        case 4:            {          value = 0;          mySerial.print("Erasing EEPROM");          mySerial.println(AND THE FOLLOWING("YES/NO:"));          mySerial.flush();          MnuState = 1;          Sbuffer = "";          break;        }        case 5:            {         value = 0;       mySerial.print(AND THE FOLLOWING("Erasing EEPROM"));         mySerial.println(AND THE FOLLOWING("State by."));         mySerial.flush();         for (int a = 0; a < EEPromBanks; a++)           {             //Memory bank a             mySerial.println("Clear bank:" + String(a));             for (int B = 1; B <= LcdRows;B++)               {                for (int C = 0; C <rLcdChr; C++)                   {                     eeaddress = 0;                       eeaddress = (a * (rLcdChr)* LcdRows) + ((rLcdChr ) * B) + C;                     FRMCheck = EEPROM.Read(eeaddress);                     if (FRMCheck > 0)                     {                     EEPROM.write(eeaddress,00); //Formatting                     mySerial.print(".");                     value++;                     delay(30);                     mySerial.flush();                     }                   }               }             mySerial.println("");             mySerial.flush();           }         mySerial.println("");                             mySerial.println("Finished."+ String(value) + "Bytes cleared");         mySerial.println("");         mySerial.flush();         Sbuffer = "";         MnuState = 0;         break;        }        case 6:        {         value = 0;         Sbuffer = "";         MnuState = 0;         mySerial.println(AND THE FOLLOWING("Toilet OP."));         mySerial.flush();         break;          }        case 7:        {        mySerial.println("Bank EEPPROM of Number (0-" + String(EEPromBanks-1) + "):");        mySerial.flush();        MnuState = 2;        value = 0;        Sbuffer = "";        break;        }        case 8:        {        Selectedbank = value;        TextHeader(1);               MnuState = 3;        Sbuffer = "";        value = 0;        break;        }        case 9:        {        WriteEEPROM(Selectedbank,1);             TextHeader(2);        value = 0;        MnuState = 4;        Sbuffer = "";        break;        }        case 10:        {        WriteEEPROM(Selectedbank,2);         value = 0;        MnuState = 0;        Sbuffer = "";        TextHeader(3);        mySerial.flush();        value = 0;        MnuState = 9;        Sbuffer = "";        break;        }                case 11:        {        value = 0;      mySerial.println("Bank EEPPROM of Number (0-" + String(EEPromBanks-1) + "):");        MnuState = 5;        Sbuffer = "";        mySerial.flush();        break;        }         case 12:        {        SelectedMsg = value;        Display bank(value);          break;        }        case 13:        {        value = 0;        mySerial.println("Bank EEPPROM of Number (0-" + String(EEPromBanks-1) + "):");        MnuState = 6;        Sbuffer = "";        mySerial.flush();        break;        }        case 14:        {         a = value;         if ( a < EEPromBanks)         {         mySerial.println("Memory bank:" + String(a) );         mySerial.flush();         for (int B = 1; B <= LcdRows;B++)           {             mySerial.print("Row" + String(B) +": ");             mySerial.flush();             for (int C = 0; C <rLcdChr; C++)               {                 eeaddress = 0;                   eeaddress = (a * (rLcdChr)* LcdRows) + ((rLcdChr) * B) + C;                 value = EEPROM.Read(eeaddress);                 mySerial.print(char(value));                 mySerial.flush();                                      }             mySerial.println(" ");             mySerial.flush();           }         } else            {            mySerial.println(AND THE FOLLOWING("Value out of to rank."));               }                     value = 0;              Sbuffer = "";         MnuState = 0;         break;        }        case 15:        {        //Direct pPrint to display        Directprint = true;        mySerial.println ("Directprint ON.");        if (Directprint)        {        DirectprintROW = 0;        DirectprintLine = 0;        lcd.clear();        lcd.cursor();        lcd.flash();        }        value = 0;             Sbuffer = "";        MnuState = 0;        break;         }        case 16:        {        value = 0;             Sbuffer = "";        MnuState = 0;        break;         }        case 17:        {        mySerial.println(AND THE FOLLOWING("Display Brightness: (max. 255)"));        MnuState = 7;        value = 0;        Sbuffer = "";        break;        }        case 18:        {        if ((value < 256))          {            Targetbrightness = value;            mySerial.println("Brightness:" + String (Targetbrightness) + "Set");                  } else           {            mySerial.println(AND THE FOLLOWING("Value out of to rank."));                }        MnuState = 0;              value = 0;        Sbuffer = "";        break;        }        case 19:        {       mySerial.println(AND THE FOLLOWING("Tasteless Delay: (max. 255 Sec)"));        MnuState = 12;        value = 0;        Sbuffer = "";        break;        }        case 20:        {        WriteEEPROM(Selectedbank,3);         value = 0;        MnuState = 0;        Sbuffer = "";        TextHeader(4);        mySerial.flush();        value = 0;        MnuState = 10;        Sbuffer = "";        break;        }        case 21:        {        WriteEEPROM(Selectedbank,4);         value = 0;        MnuState = 0;        Sbuffer = "";        break;        }        case 22:        {        MnuState = 0;        Sbuffer = "";        mySerial.println(AND THE FOLLOWING("Enter NEW BT Pin"));        mySerial.flush();        MnuState = 11;        break;        }        case 23:        {        Advertising  = !Advertising;             mySerial.print(AND THE FOLLOWING("Advertising"));        if (Advertising)          {          mySerial.println(AND THE FOLLOWING(" ON."));         } else  { mySerial.println(AND THE FOLLOWING(" OUT OF VISION.")); }        mySerial.flush();        value = 0;        MnuState = 0;        Sbuffer = "";        break;        }                case 24:        {         if ((value > 1000) & (value < 10000))        {        mySerial.print("NEW PIN"+ Sbuffer);              delay(1000);        mySerial.flush();               delay(1000);         mySerial.println("AT PIN"+ Sbuffer);        delay(3000);        mySerial.flush();              } else        {        value = 0;        Sbuffer = "";        mySerial.println(AND THE FOLLOWING("Value out of to rank."));         }                 value = 0;        MnuState = 0;        Sbuffer = "";        break;        }        case 25:        {         if ((value > 0) & (value < 251))        {                FadeSeconds = value;        EEPROM.write(EEFadeSeconds, FadeSeconds);        mySerial.println("Value" + String (value) + " set.");        } else        {        value = 0;        Sbuffer = "";        mySerial.println(AND THE FOLLOWING("Value out of to rank."));        }                 value = 0;        MnuState = 0;        Sbuffer = "";        break;        }        case 26:        {       mySerial.println(AND THE FOLLOWING("ADverDelay: (max. 255 Sec)"));        MnuState = 13;        value = 0;        Sbuffer = "";        break;        }        case 27:        {         if ((value > 0) & (value < 256))        {                Advertsecdelay = value;        EEPROM.write(EEAdvertsecdelay,Advertsecdelay);      mySerial.println("Value" + String (value) + " set.");        } else        {        value = 0;        Sbuffer = "";        mySerial.println(AND THE FOLLOWING("Value out of to rank."));         }                 value = 0;        MnuState = 0;        Sbuffer = "";        break;        }        case 28:        {       mySerial.println("ADMsgs: (max." + String (EEPromBanks) + ")");       MnuState = 14;        value = 0;        Sbuffer = "";        break;        }        case 29:        {         if ((value > 0) & (value < EEPromBanks +1))        {                AdvertMsg = value;        EEPROM.write(EEAdvertMsg,AdvertMsg);      mySerial.println("Value" + String (value) + " set.");        } else        {        value = 0;        Sbuffer = "";        mySerial.println(AND THE FOLLOWING("Value out of to rank."));         }                 value = 0;        MnuState = 0;        Sbuffer = "";        break;        }        default:        {          if (DisplayLock)             {              lcd.clear();             DisplayLock = false;            }          mySerial.println(AND THE FOLLOWING("-------Smart Bluetooth display 1.1------"));          mySerial.println(AND THE FOLLOWING("See - Read ALL Banks EEPROM"));          mySerial.println(AND THE FOLLOWING("E - Erase ALL EEPROM Banks"));          mySerial.println(AND THE FOLLOWING("W - Write sel. Bank EEPROM"));          mySerial.println(AND THE FOLLOWING("R - Read sel. Bank EEPROM"));          mySerial.println(AND THE FOLLOWING("P - Print EEPROM Bank on Display"));          mySerial.println(AND THE FOLLOWING("----------------------------------------"));          mySerial.println(AND THE FOLLOWING("D - Direct Print"));          mySerial.println("B - display Brighness Current Value:" + String (Currentbrightness));          mySerial.println(AND THE FOLLOWING("----------------------------------------"));          mySerial.println(AND THE FOLLOWING("A - Bluetooth Access PIN"));          mySerial.println(AND THE FOLLOWING("Other: ADVERT, ADSEC, ADMSG, FADE, ECHO"));           mySerial.인쇄하(에프("----------------------------------------"));          균사체.인쇄하(에프("Cmd 유형 및 입력"));          균사체.플러시();          만약 (데부그모드)            {                  균사체.인쇄하("Debug : CmdProc End Typ : " + (인포타입) + "흡입 : " +스버퍼);            균사체.플러시();           }          므누스테이트 = 0;          가치 = 0;          스버퍼 = "";        }     }    } // 에잉가베 에르칸트
}

공허 기록(바이트 FBank,바이트 파우)
{
바이트 필기체;

필기체 = 0; 
 균사체.인쇄하다("구하는 것");         (인트 c = 0; c <rLcdChr; c++)           {            이드드레스 = 0;              이드드레스 = (FBank * (rLcdChr)* LCdRows) + ((rLcdChr) * 파우) + c;              가치 = 에프롬.읽다(이드드레스);            만약 (스버퍼[c] != 가치)            {            에프롬.쓰다(이드드레스,스버퍼[c]);            균사체.인쇄하다(".");            필기체++;              }           }        균사체.인쇄하(" " +  (필기체) + "바이트 글");     }

공허 클리어버퍼 ()
{
  (바이트 = 0; 최대입력버퍼사이즈 -1;++)   버퍼[] = 0;   }    바이트 서인풋핸들러()

{
바이트 결과 = 0;
인트 c;
인트 디디;
인트 ;
인트 ;
결과 = 0;
만약 (체크포시리얼 이벤트())     {       만약 ((숫자 입력) 그리고 아니 (데이터 입력)그리고 아니 (스트린풋))     //수만        {        스버퍼 = "";        가치 = 0;        스트린풋 = 거짓;        숫자 입력 = 거짓;        데이터 입력 = 거짓;        입력 = 거짓;          = 0;         = 0;        c = 0;        디디 = 0;        스버퍼 = 버퍼; // Zahl wird AUCH! SBUFFER übernommen에서, Benötigt가 떨어진다.        만약 (계산 == 1) { 가치  = 버퍼[0]- 48 ; }        만약 (계산 == 2) {            = 버퍼[0] - 48 ;            =  * 10;           = 버퍼[1] - 48 ;          가치 =  + ;          }        만약 (계산 == 3) {            = 버퍼[0] - 48 ;            =  * 100;           = 버퍼[1] - 48 ;           =  * 10;          c = 버퍼[2] - 48 ;          가치 =  +  + c;          }        만약 (계산 == 4) {            = 버퍼[0] - 48 ;            =  * 1000;           = 버퍼[1] - 48 ;           =  * 100;          c = 버퍼[2] - 48 ;          c = c * 10;          디디 = 버퍼[3] - 48 ;          가치 =  +  + c + 디디;          }        만약 (계산 >= 5)            {            스버퍼 = "";            가치 = 0;            스버퍼 = 버퍼;            클리어버퍼;            결과 = 2;             } 기타           {            클리어버퍼;            만약 (데부그모드)              {             균사체.인쇄하("Debug : 번호 : "+(가치));              균사체.플러시();            }            계산 = 0;            결과 = 1;                                                //넘버 리턴코드            숫자 입력 = 거짓;            스트린풋 = 거짓;            데이터 입력 = 거짓;            입력 = 거짓;             계산 = 0;            반환 결과;            }        }      만약 ((스트린풋) 그리고 아니 (데이터 입력))                          //스트링 입력만        {         스버퍼 = "";         스버퍼 = 버퍼;          만약 (데부그모드)              {                균사체.인쇄하("Debug : 문자열 : "+스버퍼);               균사체.플러시();             }        가치 = 0;        스트린풋 = 거짓;        숫자 입력 = 거짓;        데이터 입력 = 거짓;        입력 = 거짓;         계산 = 0;        클리어버퍼;        결과 = 2;                                                 //넘버 리턴코드        }       만약 (데이터 입력) {        스버퍼 = "";        스버퍼 = 버퍼;        가치 = 0;        스트린풋 = 거짓;        숫자 입력 = 거짓;        데이터 입력 = 거짓;        입력 = 거짓;         만약 (데부그모드)           {            균사체.인쇄하("Debug : 데이터 : "+스버퍼);             균사체.플러시();          }        계산 = 0;        클리어버퍼;        결과 = 3;                                               //넘버 리턴코드        }        만약 ((입력) 그리고 아니 (스트린풋) 그리고 아니 (숫자 입력) 그리고 아니 (데이터 입력))        {        스버퍼 = "";        가치 = 0;        만약 (데부그모드)           {            균사체.인쇄하(에프("Debug : 누르기만 입력"));             균사체.플러시();          }        계산 = 0;        클리어버퍼;        결과 = 4;                                               //넘버 리턴코드        }             숫자 입력 = 거짓;    스트린풋 = 거짓;    DataInput = false;    EnterInput = false;     Ccount = 0;    return result;     } 
return result;          //CheckforSerialEvent
}

//Input buffer
boolean CheckforserialEvent()
{   while (mySerial.available()) {      //get the new byte:      TBuffer = mySerial.Read();       if (TBuffer > 9 && TBuffer < 14)        {         Cbuffer[Ccount] = 0;         TBuffer =0;         if (Echo fashion)           {            mySerial.print(char(13));            mySerial.flush();          }            if (Directprint)           {           mySerial.println("");           DirectprintLine = 0;           DirectprintROW = DirectprintROW + 1;           if ( DirectprintROW > 3)            {                     Directprint = false;                    lcd.noCursor();                    lcd.noBlink();                    Sbuffer = "";                    value = 0;                                 } else            {           lcd.cursor();           lcd.flash();           lcd.set cursor(0,DirectprintROW);           }           }                if (DebugMode)            {                 mySerial.println("Debug: Enter received. Length:" + String(Ccount));           mySerial.flush();           }          EnterInput = true;           return true;      } else if (TBuffer > 47 && TBuffer <58 )       {        if ( Ccount < MaxInputBufferSize)           {             Cbuffer[Ccount] = TBuffer;               Ccount++;             if ((Directprint))               {                  lcd.print(char(TBuffer));                  DirectprintLine = DirectprintLine + 1;                  if ( Ccount > MaxInputBufferSize -1)                   {                    lcd.noCursor();                    lcd.noBlink();                    } else {                    lcd.cursor();                    lcd.flash();                    }                                 }                      if (Echo fashion) {              mySerial.print(char(TBuffer));              mySerial.flush();             }            } else {mySerial.print("#"); }            if (DebugMode) {        mySerial.println(AND THE FOLLOWING("Debug: Number over Serial received"));        mySerial.flush();       }       //Number input detected       NumberInput = true;       }        else if (TBuffer > 64 && TBuffer < 123 )       {        if ( Ccount < MaxInputBufferSize)           {             Cbuffer[Ccount] = TBuffer;               Ccount++;             if ((Directprint))               {                  lcd.print(char(TBuffer));                                 DirectprintLine = DirectprintLine + 1;                  if ( Ccount > MaxInputBufferSize -1)                   {                    lcd.noCursor();                    lcd.noBlink();                    } else {                    lcd.cursor();                    lcd.flash();                    }                       }                if (Echo fashion) {              mySerial.print(char(TBuffer));              mySerial.flush();             }            } else {mySerial.print("#"); }          if (DebugMode) { mySerial.println(AND THE FOLLOWING("Debug: Char over Serial received"));       mySerial.flush(); }         //Character Char input detected       StrInput = true;      }     else if ( (TBuffer == 127 )  |  (TBuffer == 8 ) )          {                                                if ( DirectprintLine > 0 )                  {                  DirectprintLine = DirectprintLine - 1;                  lcd.set cursor(DirectprintLine, DirectprintROW);                   lcd.print(" ");                  lcd.set cursor(DirectprintLine, DirectprintROW);                   }                                                       if (( DirectprintLine == 0 ) & ( DirectprintROW > 0 ))                  {                  DirectprintROW = DirectprintROW - 1;                   DirectprintLine = rLcdChr -1;                  lcd.set cursor(DirectprintLine, DirectprintROW);                   }           if ( Ccount > 0)           {             Ccount--;             Cbuffer[Ccount] = 0;             if ((Directprint))               {                  if ( Ccount > MaxInputBufferSize -1)                   {                    lcd.noCursor();                    lcd.noBlink();                    } else {                    lcd.cursor();                    lcd.flash();                    }                       }                                          if (Echo fashion) {              mySerial.print("-");              mySerial.flush();             }            }        }          else         {                if ( Ccount < MaxInputBufferSize)           {             Cbuffer[Ccount] = TBuffer;               Ccount++;              if ((Directprint))               {                  DirectprintLine = DirectprintLine + 1;                  if (TBuffer < 128) {lcd.print(char(TBuffer)); } else  {lcd.print(String(TBuffer)); }                  if ( Ccount > MaxInputBufferSize -1)                   {                    lcd.noCursor();                    lcd.noBlink();                    } else {                    lcd.커서();                    엘시디.눈 깜빡임();                    }                       }                만약 (에코모드) {              균사체.인쇄하다(차르(테르베르));              균사체.플러시();             }            } 기타 {균사체.인쇄하다("#"); }              만약 (데부그모드)           {             균사체.인쇄하(에프("Debug : 일련 번호에 대한 데이터 수신"));            균사체.플러시();          }        //데이터 입력 감지       데이터 입력 = ;       }      반환 거짓;      }     반환 거짓;   }    공허 디스플레이 프로세서()  / / Bei Blauem Display wird auf Scrollfunktion verzichtet, da das nur "schmiert"
{
만약 (새로 고침 디스플레이)   {     엘시디.투명한();     새로 고침 디스플레이 = 거짓;         (인트  = 1;  <= LCdRows;++)                 {                   엘시디.세트커서(0,  -1);                   만약 (!광고) {균사체.인쇄하다( + () +": "); }                    (인트 c = 0; c <rLcdChr; c++)                       {                         이드드레스 = 0;                           이드드레스 = (디스플레이뱅크콘텐츠 * (rLcdChr)* LCdRows) + ((rLcdChr) * ) + c;                         가치 = 0;                         가치 = 에프롬.읽다(이드드레스);                         만약 (가치 > 31) / / 손더제이첸의 엔제이겐                         {                          만약 (!광고) { 균사체.인쇄하다(차르(가치)); } 기타 { 지연(100);}                          엘시디.인쇄하다(차르(가치));                          } 기타                         { 엘시디.인쇄하다(차르(32)); }                                              }                    만약 (!광고) { 균사체.인쇄하();  }                 }                               }         }

공허 런리얼타임클록()    //시간대
{   / / 실시간 시계 & amp; 카운트 다운
 // 이전 밀리스 = 0; // 마지막으로 측정한 저장 중
 // 바이트 분리기 = 0;
서명되지 않은  커런트 밀리스 = 밀리스();

인트 스텝밸류 = 0;
// PWM 디스플레이 슈테룽
 스텝밸류 = 4 * 페이드세컨즈;   만약(커런트 밀리스 - 이전 밀리스 > 스텝밸류)   {      이전 밀리스 = 커런트 밀리스;              만약 (전류 밝기 < 표적명도   )   {   전류 밝기 = 전류 밝기 + 1;   아날로그 쓰기 (배경 조명,전류 밝기);        } 기타 만약 (전류 밝기 > 표적명도)    {   전류 밝기 = 전류 밝기 - 1;   아날로그 쓰기 (배경 조명,전류 밝기);     }    }   만약(커런트 밀리스 - 이전 밀리스비 > 1000)    {   // 세쿤덴탁트     이전 밀리스비 = 커런트 밀리스;      배트모니터링();
광고     만약 (광고)     {      만약 (광고계측자 >  광고지연)       {       광고계측자 = 0;         디스플레이뱅크콘텐츠 = 디스플레이뱅크콘텐츠 + 1;       만약 (디스플레이뱅크콘텐츠 > 광고Msg - 1) { 디스플레이뱅크콘텐츠 = 0; }       새로 고침 디스플레이 = ;       } 기타 { 광고계측자 = 광고계측자 +1; }            }       }   }

공허 디스플레이뱅크 ( 바이트 코뱅크)
 {        만약 (코뱅크  < 이프롬뱅크스 )        {        새로 고침 디스플레이 = ;   // 디스플레이 출력 초기화        디스플레이뱅크콘텐츠 = 코뱅크;        균사체.인쇄하("은행" + (코뱅크) + "LCD에 표시됨");                 므누스테이트 = 0;        스버퍼 = "";        가치 =0;        균사체.플러시();        } 기타               {                 균사체.인쇄하(에프("은행은 구할 수 없다."));                 가치 = 0;                 므누스테이트 = 0;                 스버퍼 = "";                 균사체.플러시();               }        }

공허 토글파워세이브(부울 상태)
{
균사체.인쇄하다("파워세이브 모드"); 
 만약 (!상태)     {     파워세이브모드 = 거짓;    표적명도 = 255;    균사체.인쇄하(에프("오프"));    } 기타    {    파워세이브모드 = ;    표적명도 = 0;    균사체.인쇄하(에프("on"));      }
}    공허 스위치프로세서()
{
스위치스테이트 = 디지털 리드(스위치핀);
만약 ((!스위치스테이트) && (스위치스테이트버퍼) && (아니 디스플레이락))// 방진 샬터   {    스위치스테이트버퍼 = 거짓;    광고 = 거짓;    직인 = 거짓;    엘시디.노커서();    엘시디.노블링크();    만약 (파워세이브모드)     {    토글파워세이브(거짓);     } 기타    {    선택 Msg = 선택 Msg + 1;      만약 (선택 Msg >  이프롬뱅크스 - 1 )        {       선택 Msg = 0;       }     엘시디.투명한();     엘시디.세트커서(0,0);     엘시디.인쇄하다("은행 : " + (선택 Msg) + "선택");     엘시디.세트커서(0,2);          엘시디.인쇄하다("시스템 VDD : " + (전압) + "V");     지연(10);     가치 = 지연초파리;          ~동안 (디지털 리드(스위치핀) == 0)     {      지연(1);      만약 (가치 > 0) {가치 = 가치 - 1;};      만약 (가치 == 0 &&  아니 파워세이브모드)      {      토글파워세이브();      // (SelectedMsg = 0) SelectedMsg = EEPromBanks; 기타 SelectedMsg = SelectedMsg - 1;      엘시디.세트커서(0,3);      엘시디.인쇄하다("좋아, 전원 꺼");         }      엘시디.세트커서(0,3);      만약 (가치 > 0) {엘시디.인쇄하다("전원 끄기 : " + (가치 /100)+ "초");};      }     디스플레이뱅크(선택 Msg);    }      }    만약 (스위치스테이트)      {       스위치스테이트버퍼 = ;     // 지연(10);     }    }

공허 파워다운 ()  // 임계 전압에 도달하면 파워다운을 전환합니다.
{
 엘시디.투명한();
 엘시디.세트커서(0,0);
 엘시디.인쇄하다("전지 저경보");
 엘시디.세트커서(0,2);
 엘시디.인쇄하다("차지 배터리");
 직인 = 거짓;
 광고 = 거짓;
 지연(5000);
 토글파워세이브();
}

공허 배트모니터링()

{   인트 배터리스테이트;   배터리스테이트 = 아날로그 리드(전압감지핀);    // 입력 핀 읽기
 / / 미텔룽 데 메스베르테 노치 힌주퓌겐   전압 = 배터리스테이트 * (0.00489);
 만약 (전압 <= 민오프볼트) 
{ 
파워다운(); 
}

}

 

It is now not only displayed, as before, the currently selected text bank, but also now the current operating voltage. (in the picture below 4.97 volts) as well as a counter that counts down starting with 5 and down the system when reaching 0. The system is also shut down when signing the minimum operating voltage specified in the source code. Although the display is emptyed and the background lights are switched off, it still remains in principle powered. Wer möchte kann das Display per Feldeffekt Transistor auch noch spannungsfrei schalten. I have, however, for reasons of simplicity waived this.

In the menu itself, it now starts the “hidden” debug command that turns on and off the debug mode by simply entering the command. The following screenshot from the mobile phone APP “BlueTerm” which I can recommend very much for this project is seen by the additional editions (marked with the prefix “Debug:” ) which are issued when the mode is turned on. In the screenshot you can see the debug output of all characters received via serial interface. (Hier debug)
After receiving the debug command, the debug mode is switched off and quitted with "Debug OFF".

I wish you a lot of fun rebuilding. See you soon at the next blog and the next project. I hope you've had as much fun recreating as I've been developing.

DisplaysFor arduinoProjects for advanced

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN