updated display to a faster lib

This commit is contained in:
CodeCrafter912 2018-07-07 19:27:47 +02:00
parent 1d5e3515e8
commit ccd012a314
2 changed files with 20 additions and 22 deletions

View file

@ -50,6 +50,7 @@ typedef struct transcv_struct{
#define RUN_LED_ON HIGH #define RUN_LED_ON HIGH
#define RUN_LED_OFF LOW #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; typedef enum {TIMER_INIT = 0, TIMER_READY, TIMER_STARTED, TIMER_RUNNING , TIMER_CANCELLED, TIMER_STOPPED, TIMER_TIMEDOUT, TIMER_FAIL, TIMER_WAIT} timer_state_e;

View file

@ -1,16 +1,15 @@
#include <Arduino.h> #include <Arduino.h>
#include <U8g2lib.h> #include <U8g2lib.h>
//#include "fonts.h" //#include "fonts.h"
#include <SPI.h> #include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
#include "RF24.h" #include "RF24.h"
#include "speedclock.h" #include "speedclock.h"
#include "pitch.h" #include "pitch.h"
// internal defines for the OLED display ... // 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 SSD1306AsciiWire display;
//U8G2_SSD1306_128X64_NONAME_1_HW_I2C display(U8G2_R0,/* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
/****************** User Config for NRF24***************************/ /****************** User Config for NRF24***************************/
/*** Set this radio as radio number RADIO0 or RADIO1 ***/ /*** Set this radio as radio number RADIO0 or RADIO1 ***/
radio_type_e stationNumber = BASESTATION; //---> TOPSTATION has the button connected, BASESTATION is the default ... 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.topstationtime = millis(); // set the current milli second count
radio_data.topbuttonpressedtime = 0; // set the time the button was pressed last time to 0 radio_data.topbuttonpressedtime = 0; // set the time the button was pressed last time to 0
//initialise OLED and display Welcome Message ... //initialise Wire and OLED
display.begin(); Wire.begin();
Wire.setClock(400000L);
display.begin(&Adafruit128x64, DISPLAY_I2C_ADDRESS);
display.clear();
} }
void loop(void) { 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)); top_line.toCharArray(string_to_char, sizeof(string_to_char));
//Serial.print("DISPLAY: "); //Serial.print("DISPLAY: ");
//Serial.println(string_to_char); //Serial.println(string_to_char);
display.setFontPosCenter(); display.setFont(System5x7);
display.setFont(u8g2_font_ncenB08_tr); //int xpos = (128 - (display.getStrWidth(string_to_char)))/2 - 10;
int xpos = (128 - (display.getStrWidth(string_to_char)))/2 - 10;
display.firstPage(); display.home();
do { display.print("========");
display.setFont(u8g2_font_ncenB08_tr); display.print(string_to_char);
display.setCursor(xpos,ypos); display.println("=======");
display.print(string_to_char);
} while ( display.nextPage() );
} }
} }
@ -401,17 +400,16 @@ void startSequence(void)
// first tone // first tone
if(timer_new_state == TIMER_RUNNING){ if(timer_new_state == TIMER_RUNNING){
tone(PIEZO_PIN, STARTSEQ_TON_1_2_FREQUENCY,STARTSEQ_TON_1_2_LENGTH_MS ); 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 //second tone
if(timer_new_state == TIMER_RUNNING){ if(timer_new_state == TIMER_RUNNING){
tone(PIEZO_PIN, STARTSEQ_TON_1_2_FREQUENCY,STARTSEQ_TON_1_2_LENGTH_MS ); 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 //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);
} }
} }
@ -432,13 +430,12 @@ void false_start_isr(void)
// this will save the time when the runner is really started // this will save the time when the runner is really started
Serial.println("** Interrupt service routine started: false_start_ISR **"); Serial.println("** Interrupt service routine started: false_start_ISR **");
runner_start_time = millis(); runner_start_time = millis();
if(timer_state == TIMER_STARTED){ if(timer_state == TIMER_STARTED & timer_new_state == TIMER_STARTED){
Serial.println("** Interrupt service routine set timer_new_state to TIMER_FAIL **");
timer_new_state = TIMER_FAIL; timer_new_state = TIMER_FAIL;
detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN)); detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN));
noTone(PIEZO_PIN); noTone(PIEZO_PIN);
} else { } else {
if(timer_state == TIMER_RUNNING){ if(timer_state == TIMER_RUNNING | timer_new_state == TIMER_RUNNING ){
// disable this interrupt; // disable this interrupt;
detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN)); detachInterrupt(digitalPinToInterrupt(FAILSTARTBUTTON_IN));
} }