Debug console #41

Closed
opened 2020-08-25 01:21:04 +00:00 by kemonine · 2 comments
Owner

Come up with a solid debug console to avoid the need for a dedicated uart -> usb chip

Hardware

Docs

Implementation

  • Battery level on feather neopixel (green = >80% ; yellow >=40% ; orange >= 25% ; red < 25%)
  • Setup 2nd feather + proto board as a 40 pin socket
  • 2nd feather acts as a mux between different rpi uarts (0 and 1 and 5 in particular)
  • 2nd feather talks via qwiic connector over i2c to main board
  • User button on feather to flip between usb and local serial (aka : can be used as a serial adapter)
    • Note this on the UI
  • Fall back to internal uart pins if no expander is present
    • Note this on the UI
  • Main board startup shows connection setup + waits for OK prompt via main hat switch
  • Main board has a status bar @ bottom with battery level, selected uart, selected speed
  • Main board does simple display of serial in/out via lcd
  • Main board has a button for accessing symbols via pop-up list that aren't on keyboard
  • Main board has a button for accessing a uart selection pop-up that maps to rpi uarts
  • Main board has a button for accessing password selection pop-up to help with password entry over serial
  • Main board has a button for accessing uart speed pop-up to help with configuring line speeds
Come up with a solid debug console to avoid the need for a dedicated uart -> usb chip Hardware - https://www.tindie.com/products/arturo182/keyboard-featherwing-qwerty-keyboard-26-lcd/ - https://www.adafruit.com/product/4062 - https://www.adafruit.com/product/2772 - https://www.adafruit.com/product/2884 - https://www.adafruit.com/product/1993 - https://www.adafruit.com/product/1988 Docs - https://www.solder.party/docs/keyboard-featherwing/downloads/ - https://github.com/arturo182/bbq10kbd_i2c_sw - https://github.com/lvgl/lv_arduino Implementation - ~~Battery level on feather neopixel (green = >80% ; yellow >=40% ; orange >= 25% ; red < 25%)~~ - ~~https://learn.adafruit.com/adafruit-feather-m0-basic-proto/power-management~~ - Setup 2nd feather + proto board as a 40 pin socket - 2nd feather acts as a mux between different rpi uarts (0 and 1 and 5 in particular) - 2nd feather talks via qwiic connector over i2c to main board - User button on feather to flip between usb and local serial (aka : can be used as a serial adapter) - Note this on the UI - Fall back to internal uart pins if no expander is present - Note this on the UI - Main board startup shows connection setup + waits for OK prompt via main hat switch - Main board has a status bar @ bottom with battery level, selected uart, selected speed - Main board does simple display of serial in/out via lcd - Main board has a button for accessing symbols via pop-up list that aren't on keyboard - Main board has a button for accessing a uart selection pop-up that maps to rpi uarts - Main board has a button for accessing password selection pop-up to help with password entry over serial - Main board has a button for accessing uart speed pop-up to help with configuring line speeds
kemonine added the
help wanted
enhancement
labels 2020-08-25 01:21:09 +00:00
kemonine added this to the Future milestone 2020-08-25 01:21:11 +00:00
Author
Owner

// Varous system / library includes
#include <Adafruit_NeoPixel.h>

// Debugging via serial monitor (don't turn this on unless you're hacking on the firmware code)
#define DEBUG true

// Battery level measurement
#define VBATPIN A6
float measuredVBat;
float batteryPercent;

#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);

void setup() {
  // Setup red LED to indicate device is on (in case we disable NeoPixel battery level later)
  pinMode(3, OUTPUT);
  digitalWrite(3, HIGH);

  // Setup NeoPixels
  pixels.begin();
  pixels.clear();
  pixels.setBrightness(10);

  // Green : pixels.Color(0, 255, 0)
  // Yellow : pixels.Color(255, 255, 0)
  // Orange : pixels.Color(255, 128, 0)
  // Red : pixels.Color(255, 0, 0)
  pixels.setPixelColor(0, pixels.Color(0, 0, 0));
  pixels.show();
}

// Measure battery level and change NeoPixel accordingly
void batteryLevel() {
  measuredVBat = analogRead(VBATPIN);
  measuredVBat *= 2;    // we divided by 2, so multiply back
  measuredVBat *= 3.3;  // Multiply by 3.3V, our reference voltage
  measuredVBat /= 1024; // convert to voltage
  batteryPercent = measuredVBat / 3.3;
  if (batteryPercent >= 0.75) {
    pixels.setPixelColor(0, pixels.Color(0, 255, 0));
  }
  else if (batteryPercent >= 0.50) {
    pixels.setPixelColor(0, pixels.Color(255, 255, 0));
  }
  else if (batteryPercent >= 0.25) {
    pixels.setPixelColor(0, pixels.Color(255, 128, 0));
  }
  else {
    pixels.setPixelColor(0, pixels.Color(255, 0, 0));
  }
  pixels.show();

  if (DEBUG) {
    Serial.print("VBat: " ); Serial.println(measuredVBat);
    Serial.print("Bat %: "); Serial.println(batteryPercent);
  }
}

void loop() {
  // Update battery level as appropriate
  batteryLevel();
  
  delay(250);
}

``` c // Varous system / library includes #include <Adafruit_NeoPixel.h> // Debugging via serial monitor (don't turn this on unless you're hacking on the firmware code) #define DEBUG true // Battery level measurement #define VBATPIN A6 float measuredVBat; float batteryPercent; #define NUMPIXELS 1 Adafruit_NeoPixel pixels(NUMPIXELS, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800); void setup() { // Setup red LED to indicate device is on (in case we disable NeoPixel battery level later) pinMode(3, OUTPUT); digitalWrite(3, HIGH); // Setup NeoPixels pixels.begin(); pixels.clear(); pixels.setBrightness(10); // Green : pixels.Color(0, 255, 0) // Yellow : pixels.Color(255, 255, 0) // Orange : pixels.Color(255, 128, 0) // Red : pixels.Color(255, 0, 0) pixels.setPixelColor(0, pixels.Color(0, 0, 0)); pixels.show(); } // Measure battery level and change NeoPixel accordingly void batteryLevel() { measuredVBat = analogRead(VBATPIN); measuredVBat *= 2; // we divided by 2, so multiply back measuredVBat *= 3.3; // Multiply by 3.3V, our reference voltage measuredVBat /= 1024; // convert to voltage batteryPercent = measuredVBat / 3.3; if (batteryPercent >= 0.75) { pixels.setPixelColor(0, pixels.Color(0, 255, 0)); } else if (batteryPercent >= 0.50) { pixels.setPixelColor(0, pixels.Color(255, 255, 0)); } else if (batteryPercent >= 0.25) { pixels.setPixelColor(0, pixels.Color(255, 128, 0)); } else { pixels.setPixelColor(0, pixels.Color(255, 0, 0)); } pixels.show(); if (DEBUG) { Serial.print("VBat: " ); Serial.println(measuredVBat); Serial.print("Bat %: "); Serial.println(batteryPercent); } } void loop() { // Update battery level as appropriate batteryLevel(); delay(250); } ```
Author
Owner

Closing / wontfix as this is well outside the scope of PiFrame. Moved to a personal project instead.

Closing / wontfix as this is well outside the scope of PiFrame. Moved to a personal project instead.
kemonine added
invalid
wontfix
and removed
enhancement
help wanted
labels 2020-09-03 19:56:44 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: PiFrame/piframe#41
No description provided.