updated Display

This commit is contained in:
CodeCrafter912 2018-07-07 21:41:53 +02:00
parent ccd012a314
commit 3e3d04a755
2 changed files with 40 additions and 18 deletions

View file

@ -72,7 +72,7 @@ const float LEDStates[][3] =
#define STARTSEQ_LENGTH_MS 3100 // the length of the start sequence from the time the button was pressed ... includes the 3 tones #define STARTSEQ_LENGTH_MS 3100 // the length of the start sequence from the time the button was pressed ... includes the 3 tones
#define STARTSEQ_STARTPAUSE_MS 1000 #define STARTSEQ_STARTPAUSE_MS 1000
#define STARTSEQ_TONEPAUSE_MS 800 #define STARTSEQ_TONEPAUSE_MS 1000
#define STARTSEQ_TON_1_2_LENGTH_MS 200 #define STARTSEQ_TON_1_2_LENGTH_MS 200
#define STARTSEQ_TON_1_2_FREQUENCY NOTE_G4 #define STARTSEQ_TON_1_2_FREQUENCY NOTE_G4
#define STARTSEQ_TON_3_LENGTH_MS 100 #define STARTSEQ_TON_3_LENGTH_MS 100

View file

@ -320,33 +320,39 @@ void update_statemassage(timer_state_e timer_state){
void update_screen(timer_state_e timer_state){ void update_screen(timer_state_e timer_state){
bool scr_update = true; bool scr_update = true;
int ypos = 64-42/2; int ypos = 64-42/2;
String top_line = "no state"; String header = "no state";
char string_to_char[50]; String content = "";
String footer = "";
char header_to_char[50];
char content_to_char[50];
char footer_to_char[50];
switch(timer_state){ switch(timer_state){
case TIMER_INIT: case TIMER_INIT:
top_line = "Init"; header = "Init";
break; break;
case TIMER_READY: case TIMER_READY:
top_line = "Ready!"; header = "Ready!";
break; break;
case TIMER_STARTED: case TIMER_STARTED:
top_line = "Started ..."; header = "Started ...";
break; break;
case TIMER_RUNNING: case TIMER_RUNNING:
top_line = "Running ..."; header = "Running ...";
content = millis() - start_time;
break; break;
case TIMER_CANCELLED: case TIMER_CANCELLED:
top_line = "Cancelled!"; header = "Cancelled!";
break; break;
case TIMER_STOPPED: case TIMER_STOPPED:
top_line = "Stopped!"; header = "Stopped!";
break; break;
case TIMER_TIMEDOUT: case TIMER_TIMEDOUT:
top_line = "Time out!"; header = "Time out!";
break; break;
case TIMER_FAIL: case TIMER_FAIL:
top_line = "False start!"; header = "False start!";
break; break;
default: default:
scr_update = false; scr_update = false;
@ -354,17 +360,32 @@ void update_screen(timer_state_e timer_state){
} }
if(scr_update == true){ if(scr_update == true){
//snprintf( string_to_char, sizeof(string_to_char),"%s", top_line); //snprintf( string_to_char, sizeof(string_to_char),"%s", header);
top_line.toCharArray(string_to_char, sizeof(string_to_char)); header.toCharArray(header_to_char, sizeof(header_to_char));
content.toCharArray(content_to_char, sizeof(content_to_char));
footer.toCharArray(footer_to_char, sizeof(footer_to_char));
//Serial.print("DISPLAY: "); //Serial.print("DISPLAY: ");
//Serial.println(string_to_char); //Serial.println(string_to_char);
display.setFont(System5x7);
//int xpos = (128 - (display.getStrWidth(string_to_char)))/2 - 10;
display.setFont(System5x7);
display.set1X();
int xpos = (128 - (display.strWidth(header_to_char)))/2 - 10;
display.home(); display.home();
display.print("========"); display.setLetterSpacing(1);
display.print(string_to_char); display.setCursor(64 - (display.strWidth(header_to_char) / 2), 0);
display.println("======="); display.print(header_to_char);
display.setCursor(0,1);
display.setLetterSpacing(0);
display.print("----------------------------");
//end of the Header
display.set2X();
display.setCursor(64 - (display.strWidth(content_to_char) / 2), 3);
display.print(content_to_char);
//end of the Content
display.set1X();
display.setCursor(0,6);
display.print("___________________________");
display.setCursor(64 - (display.strWidth(footer_to_char) / 2), 4);
} }
} }
@ -410,6 +431,7 @@ void startSequence(void)
//third tone //third tone
if(timer_new_state == TIMER_RUNNING){ if(timer_new_state == TIMER_RUNNING){
tone(PIEZO_PIN, STARTSEQ_TON_3_FREQUENCY,STARTSEQ_TON_3_LENGTH_MS ); tone(PIEZO_PIN, STARTSEQ_TON_3_FREQUENCY,STARTSEQ_TON_3_LENGTH_MS );
delay(STARTSEQ_TON_3_LENGTH_MS);
} }
} }