updated display to a faster lib
This commit is contained in:
parent
1d5e3515e8
commit
ccd012a314
2 changed files with 20 additions and 22 deletions
|
@ -50,6 +50,7 @@ typedef struct transcv_struct{
|
|||
#define RUN_LED_ON HIGH
|
||||
#define RUN_LED_OFF LOW
|
||||
|
||||
#define DISPLAY_I2C_ADDRESS 0x3C //Adress of the Display
|
||||
|
||||
typedef enum {TIMER_INIT = 0, TIMER_READY, TIMER_STARTED, TIMER_RUNNING , TIMER_CANCELLED, TIMER_STOPPED, TIMER_TIMEDOUT, TIMER_FAIL, TIMER_WAIT} timer_state_e;
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
#include <Arduino.h>
|
||||
#include <U8g2lib.h>
|
||||
//#include "fonts.h"
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include "SSD1306Ascii.h"
|
||||
#include "SSD1306AsciiWire.h"
|
||||
#include "RF24.h"
|
||||
#include "speedclock.h"
|
||||
#include "pitch.h"
|
||||
|
||||
// internal defines for the OLED display ...
|
||||
U8G2_SSD1306_128X64_NONAME_1_SW_I2C display(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
|
||||
//U8G2_SSD1306_128X64_NONAME_1_HW_I2C display(U8G2_R0,/* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
|
||||
|
||||
|
||||
SSD1306AsciiWire display;
|
||||
/****************** User Config for NRF24***************************/
|
||||
/*** Set this radio as radio number RADIO0 or RADIO1 ***/
|
||||
radio_type_e stationNumber = BASESTATION; //---> TOPSTATION has the button connected, BASESTATION is the default ...
|
||||
|
@ -92,9 +91,12 @@ void setup(){
|
|||
radio_data.topstationtime = millis(); // set the current milli second count
|
||||
radio_data.topbuttonpressedtime = 0; // set the time the button was pressed last time to 0
|
||||
|
||||
//initialise OLED and display Welcome Message ...
|
||||
display.begin();
|
||||
//initialise Wire and OLED
|
||||
Wire.begin();
|
||||
Wire.setClock(400000L);
|
||||
|
||||
display.begin(&Adafruit128x64, DISPLAY_I2C_ADDRESS);
|
||||
display.clear();
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
|
@ -356,16 +358,13 @@ void update_screen(timer_state_e timer_state){
|
|||
top_line.toCharArray(string_to_char, sizeof(string_to_char));
|
||||
//Serial.print("DISPLAY: ");
|
||||
//Serial.println(string_to_char);
|
||||
display.setFontPosCenter();
|
||||
display.setFont(u8g2_font_ncenB08_tr);
|
||||
int xpos = (128 - (display.getStrWidth(string_to_char)))/2 - 10;
|
||||
display.setFont(System5x7);
|
||||
//int xpos = (128 - (display.getStrWidth(string_to_char)))/2 - 10;
|
||||
|
||||
display.firstPage();
|
||||
do {
|
||||
display.setFont(u8g2_font_ncenB08_tr);
|
||||
display.setCursor(xpos,ypos);
|
||||
display.print(string_to_char);
|
||||
} while ( display.nextPage() );
|
||||
display.home();
|
||||
display.print("========");
|
||||
display.print(string_to_char);
|
||||
display.println("=======");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,17 +400,16 @@ void startSequence(void)
|
|||
// first tone
|
||||
if(timer_new_state == TIMER_RUNNING){
|
||||
tone(PIEZO_PIN, STARTSEQ_TON_1_2_FREQUENCY,STARTSEQ_TON_1_2_LENGTH_MS );
|
||||
delay(STARTSEQ_TONEPAUSE_MS + STARTSEQ_TON_1_2_LENGTH_MS);
|
||||
delay(STARTSEQ_TONEPAUSE_MS);
|
||||
}
|
||||
//second tone
|
||||
if(timer_new_state == TIMER_RUNNING){
|
||||
tone(PIEZO_PIN, STARTSEQ_TON_1_2_FREQUENCY,STARTSEQ_TON_1_2_LENGTH_MS );
|
||||
delay(STARTSEQ_TONEPAUSE_MS + STARTSEQ_TON_1_2_LENGTH_MS );
|
||||
delay(STARTSEQ_TONEPAUSE_MS);
|
||||
}
|
||||
//third tone
|
||||
if(timer_new_state == TIMER_RUNNING){
|
||||
tone(PIEZO_PIN, STARTSEQ_TON_3_FREQUENCY,STARTSEQ_TON_3_LENGTH_MS );
|
||||
delay(STARTSEQ_TON_3_LENGTH_MS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -432,13 +430,12 @@ void false_start_isr(void)
|
|||
// this will save the time when the runner is really started
|
||||
Serial.println("** Interrupt service routine started: false_start_ISR **");
|
||||
runner_start_time = millis();
|
||||
if(timer_state == TIMER_STARTED){
|
||||
Serial.println("** Interrupt service routine set timer_new_state to TIMER_FAIL **");
|
||||
if(timer_state == TIMER_STARTED & timer_new_state == TIMER_STARTED){
|
||||
timer_new_state = TIMER_FAIL;
|
||||
detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN));
|
||||
noTone(PIEZO_PIN);
|
||||
} else {
|
||||
if(timer_state == TIMER_RUNNING){
|
||||
if(timer_state == TIMER_RUNNING | timer_new_state == TIMER_RUNNING ){
|
||||
// disable this interrupt;
|
||||
detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN));
|
||||
}
|
||||
|
|
Reference in a new issue