src/main.cpp
/**************************************************************************************************************************/
// Upate Time on the VFD Display
/**************************************************************************************************************************/
Upate Time on the VFD Display
Upate Time on the VFD Display
void updateDisplayTime(){
  struct tm timeinfo;
  if(!getLocalTime(&timeinfo)){
    Serial.println("Failed to obtain time");
    return;
  }
  Serial2.write('\x1B');
  Serial2.write('\x6C');
  Serial2.write('\x10'); 
  Serial2.write('\x01');
  Serial2.write('\x1B');
  Serial2.write('\x11');
  char buffer[2];
  int myHour = timeinfo.tm_hour;
  if(myHour > 12){
    myHour = myHour - 12;
  }
  if(myHour < 10){
    Serial2.print(" ");
  }
  std::string myHourString = itoa(myHour,buffer,10);
  myHourString.erase(0, min(myHourString.find_first_not_of('0'), myHourString.size()-1));
  if(colonOnLastLoop){
    colonOnLastLoop = false;
    Serial2.print(myHourString.c_str());
    Serial2.print(" ");
    Serial2.print(&timeinfo, "%M");
  }
  else{
    colonOnLastLoop = true;
    Serial2.print(myHourString.c_str());
    Serial2.print(":");
    Serial2.print(&timeinfo, "%M");
  }
}
void updateDisplayTime ( ) { struct tm timeinfo ; if ( ! getLocalTime ( & timeinfo ) ) { Serial . println ( " " ) ; return ; } Serial2 . write ( ' \x1B ' ) ; Serial2 . write ( ' \x6C ' ) ; Serial2 . write ( ' \x10 ' ) ; Serial2 . write ( ' \x01 ' ) ; Serial2 . write ( ' \x1B ' ) ; Serial2 . write ( ' \x11 ' ) ; char buffer [ 2 ] ; int myHour = timeinfo . tm_hour ; if ( myHour > 12 ) { myHour = myHour - 12 ; } if ( myHour < 10 ) { Serial2 . print ( " " ) ; } std :: string myHourString = itoa ( myHour , buffer , 10 ) ; myHourString . erase ( 0 , min ( myHourString . find_first_not_of ( ' ' ) , myHourString . size ( ) - 1 ) ) ; if ( colonOnLastLoop ) { colonOnLastLoop = false ; Serial2 . print ( myHourString . c_str ( ) ) ; Serial2 . print ( " " ) ; Serial2 . print ( & timeinfo , " " ) ; } else { colonOnLastLoop = true ; Serial2 . print ( myHourString . c_str ( ) ) ; Serial2 . print ( " " ) ; Serial2 . print ( & timeinfo , " " ) ; } }
Upate Time on the VFD Display
Upate Time on the VFD Display
//move cursor to location where we want time to be displayed //set cursor to 16,1 (X,Y) //set overwrite mode //grab time from background time structure and convert from 24 to 12 hr time.  //if the hour is a single digit, we need to shift curson one to right to keep time justified in top right corner //take hour, convert it to a string, and remove leading zero if present //blink colon and print time 