Finalizing batt icon scale.

This commit is contained in:
Ricardo
2018-01-31 00:44:14 +00:00
parent 57a164bf1f
commit 32aee17fe5

View File

@@ -37,15 +37,14 @@ Adafruit_SSD1306 display(OLED_RESET);
// Function declarations // Function declarations
void zero(); void one(); // Menu one
void one(); void two(); // Menu two
void two(); void three(); // Menu three
void three(); void four(); // Menu four
void four(); void read_serial(); // Menu that reads the serial
void read_serial(); void write_serial(); // Menu that writes to serial
void write_serial(); void config(); // Configuration menu
void config(); void batt_icon(); // Draws the battery icon acording to value
void batt_icon();
// Variables creation // Variables creation
@@ -83,12 +82,6 @@ void setup() { // BEGIN SETUP ------------------------------------
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32) display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
// init done // init done
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
//display.display();
//delay(2000); // Wait 2 seconds
// initialize timer1 --------------------------------------- // initialize timer1 ---------------------------------------
noInterrupts(); // disable all interrupts noInterrupts(); // disable all interrupts
@@ -118,14 +111,13 @@ void setup() { // BEGIN SETUP ------------------------------------
display.clearDisplay(); display.clearDisplay();
display.display(); display.display();
} // END SETUP -------------------------------------------------------------------- } // END SETUP --------------------------------------------------------------------
// Timer compare interrupt service routine -------------------------- // Timer compare interrupt service routine --------------------------
ISR(TIMER1_COMPA_vect) // Here we chose between the blinker sequence ISR(TIMER1_COMPA_vect) //
{ // or to show the temperature on the LEDs { //
if (!rUP) { if (!rUP) {
if (menuState == 1) { if (menuState == 1) {
menuState = 1; menuState = 1;
@@ -205,6 +197,7 @@ void loop() {
batt_val = analogRead(batt); batt_val = analogRead(batt);
// Routine to check the battery analog value for calibration
/* display.drawRect(0, 8, 168, 24, BLACK); /* display.drawRect(0, 8, 168, 24, BLACK);
display.display(); display.display();
display.clearDisplay(); display.clearDisplay();
@@ -213,7 +206,7 @@ void loop() {
display.setCursor(50,18); display.setCursor(50,18);
display.println(batt_val); display.println(batt_val);
batt_icon(); batt_icon();
display.display(); */ display.display();*/
@@ -261,10 +254,23 @@ void batt_icon (void) {
} }
else if ((batt_val > 901) & (batt_val < 962)) { else if ((batt_val > 901) & (batt_val < 962)) {
// Draw the battery icon - Half full battery // Draw the battery icon - 2/3 battery
display.drawRect(111, 1, 16, 6, WHITE); display.drawRect(111, 1, 16, 6, WHITE);
display.drawRect(119, 2, 7, 4, WHITE); display.drawRect(116, 2, 10, 4, WHITE);
display.drawRect(120, 3, 5, 2, WHITE); display.drawRect(117, 3, 8, 2, WHITE);
display.drawPixel(110, 3, WHITE);
display.drawPixel(110, 4, WHITE);
display.drawPixel(109, 3, WHITE);
display.drawPixel(109, 4, WHITE);
display.drawPixel(108, 3, WHITE);
display.drawPixel(108, 4, WHITE);
}
else if ((batt_val > 840) & (batt_val < 901)) {
// Draw the battery icon - 1/3 battery
display.drawRect(111, 1, 16, 6, WHITE);
display.drawRect(121, 2, 5, 4, WHITE);
display.drawRect(122, 3, 3, 2, WHITE);
display.drawPixel(110, 3, WHITE); display.drawPixel(110, 3, WHITE);
display.drawPixel(110, 4, WHITE); display.drawPixel(110, 4, WHITE);
display.drawPixel(109, 3, WHITE); display.drawPixel(109, 3, WHITE);
@@ -287,21 +293,6 @@ void batt_icon (void) {
} }
} }
void zero (void) {
display.drawRect(0, 8, 168, 24, BLACK);
display.display();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(1,12);
display.println("Read NMEA0183");
display.setCursor(1,22);
display.println("Write NMEA0183");
batt_icon();
display.display();
}
void one (void) { void one (void) {
display.drawRect(0, 8, 168, 24, BLACK); display.drawRect(0, 8, 168, 24, BLACK);