From f3df0b0d98a52cf7bdc8e0f06b4155417ed032f7 Mon Sep 17 00:00:00 2001 From: Fisch Date: Tue, 23 May 2023 21:46:34 +0200 Subject: [PATCH] add new led ring progress --- controller_teensy/include/display.h | 6 +- controller_teensy/include/led.h | 105 +++++++++++++++++++++++++--- controller_teensy/include/logging.h | 6 +- controller_teensy/src/main.cpp | 46 +++++++----- 4 files changed, 130 insertions(+), 33 deletions(-) diff --git a/controller_teensy/include/display.h b/controller_teensy/include/display.h index 6fbb740..6ea10e6 100644 --- a/controller_teensy/include/display.h +++ b/controller_teensy/include/display.h @@ -12,18 +12,20 @@ #define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); -void display_init(); +bool display_init(); void display_update(); -void display_init(){ +bool display_init(){ if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); + return false; } display.clearDisplay(); display.setTextSize(1); // Normal 1:1 pixel scale display.setTextColor(SSD1306_WHITE); // Draw white text display.setCursor(0,0); // Start at top-left corner display.display(); + return true; } void display_update(){ diff --git a/controller_teensy/include/led.h b/controller_teensy/include/led.h index 9cb9f8e..41ba30d 100644 --- a/controller_teensy/include/led.h +++ b/controller_teensy/include/led.h @@ -17,27 +17,110 @@ Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800); unsigned long last_ledupdate=0; #define LEDUPDATEINTERVAL 100 +uint8_t led_errorcount=0; //count led progress errors. used for delay at end if any errors occured + +void led_dotcircle(unsigned long loopmillis); + void init_led() { strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(BRIGHTNESS); } -void led_update(unsigned long loopmillis) { +void led_testLEDSBlocking(){ + strip.clear(); + strip.show(); + delay(10); + uint32_t color=strip.Color(0, 0, 0, 0); + + for(int i=0; i0) { + delay(5000); + }else{ + delay(100); + } +} + +void led_update(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm& escRear) { if (loopmillis>last_ledupdate+LEDUPDATEINTERVAL) { last_ledupdate=loopmillis; - uint32_t color=strip.Color(0, 0, 0, 255); - uint32_t colorOff=strip.Color(30, 0, 0, 0); - uint8_t position=(loopmillis/100)%strip.numPixels(); - for(int i=0; i 2ms, 6-> 3-4ms , 5-> 5-6ms, 4-> 9ms, 0-> 124ms + // also set ADSREADPERIOD to at least the read interval + ADS.requestADC(0); //Start requesting a channel + led_simpeProgress(6,true); } - ADS.setGain(0); - ADS.setDataRate(7);// Read Interval: 7-> 2ms, 6-> 3-4ms , 5-> 5-6ms, 4-> 9ms, 0-> 124ms - // also set ADSREADPERIOD to at least the read interval - ADS.requestADC(0); //Start requesting a channel delay(10); - led_update(millis()); + setSyncProvider(getTeensy3Time); //See https://www.pjrc.com/teensy/td_libs_Time.html#teensy3 if (timeStatus()!= timeSet) { Serial.println("Unable to sync with the RTC"); + led_simpeProgress(7,false); } else { Serial.println("RTC has set the system time"); + led_simpeProgress(7,true); } - led_update(millis()); + writeLogComment(millis(), "Setup Finished"); - led_update(millis()); + led_simpeProgress(15,true); + led_simpleProgressWait(); //wait longer if any errors were displayed with led_simpeProgress() } unsigned long loopmillis; @@ -234,7 +244,7 @@ void loop() { loggingLoop(loopmillis,escFront,escRear); leds(); - led_update(loopmillis); + led_update(loopmillis,escFront,escRear); //ws2812 led ring static unsigned long last_display_update=0; if (loopmillis - last_display_update > DISPLAYUPDATEPERIOD) {