diff --git a/ESP32-ExposureAPI-Scanner.ino b/ESP32-ExposureAPI-Scanner.ino index 4ef2715..17bf9fa 100644 --- a/ESP32-ExposureAPI-Scanner.ino +++ b/ESP32-ExposureAPI-Scanner.ino @@ -2,12 +2,14 @@ #include #include #include -#include "Tone32.h" #include #include #include #include +#include "Tone32.h" +//#include "SparkLine.h" +// ssd1306 display SSD1306Wire display(0x3c, 5, 4); #define SSD1306_128_64 @@ -33,6 +35,25 @@ BLEScan *scanner; std::map seenNotifiers; +/** + * UI related functions + */ +void displayBootscreen() { + Serial.println("Show bootscreen"); + display.clear(); + display.setColor(WHITE); + display.setTextAlignment(TEXT_ALIGN_CENTER); + display.fillRect(4, 8, 121, 24); + display.drawRect(4, 32, 121, 19); + display.setFont(ArialMT_Plain_10); + display.drawString(64, 35, "Exposure API Scanner"); + display.setColor(BLACK); + display.setFont(ArialMT_Plain_24); + display.drawString(64, 7, "COVID-19"); + display.display(); +} + + /** * Called when a new exposure notifier is seen. */ @@ -95,13 +116,7 @@ void setup() { // Initialize display Serial.println("Init Display"); display.init(); - display.clear(); - display.setTextAlignment(TEXT_ALIGN_CENTER); - display.setFont(ArialMT_Plain_24); - display.drawString(64, 10, "COVID-19"); - display.setFont(ArialMT_Plain_10); - display.drawString(64, 32, "Exposure API Scanner"); - display.display(); + displayBootscreen(); // Initialize scanner. BLEDevice::init("ESP"); @@ -130,9 +145,11 @@ void loop() { Serial.printf("Show data on SSD1306 display"); display.clear(); display.setColor(WHITE); - display.drawRect(0, 0, 128, 64); // UI Outline - display.fillRect(0, 0, 128, 14); display.setTextAlignment(TEXT_ALIGN_CENTER); + display.setFont(ArialMT_Plain_10); + display.drawRect(0, 0, 128, 64); // UI Outline + display.fillRect(0, 0, 128, 14); // UI Header + display.drawString(64, 0, "Exposure API Counter"); if (seenNotifiers.size() == 1) { display.drawString(64, 48, "Device in last " + String(FORGET_AFTER_MINUTES) +"min."); } diff --git a/README.md b/README.md index efe48b0..aa052f0 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,9 @@ This repository contains code to scan the official COVID19 Exposure API with an ESP32 using Bluetooth LE and shows a counter on an SSD1306 OLED display. +![Early stage prototype](img/esp32_scanner.jpg) -![Device Image](img/esp32_scanner.jpg) - -![Device Image with case](img/esp32_scanner_case.jpg) +![Device with case](img/esp32_scanner_case.jpg) Code is based on [BLE Exposure Notification Beeper](https://github.com/kmetz/BLEExposureNotificationBeeper) which uses an LED and a piezo buzzer to notify about new detected devices but would not show the device count so I added the display part to it. You can still use the LED/Buzzer because this part is not touched in the code. In case you want to do so use this wiring: @@ -40,6 +39,9 @@ In case you have an [Anycubic i3 Mega](https://www.anycubic.com/products/anycubi ## Used Libraries + [ESP8266-oled-ssd1306 by ThingPulse](https://github.com/ThingPulse/esp8266-oled-ssd1306) ++ [ESParkline](https://github.com/0xPIT/ESParklines) ++ [Adafruit-GFX-Library](https://github.com/adafruit/Adafruit-GFX-Library) ++ [FixedPoints](https://github.com/Pharap/FixedPointsArduino) ## To do - [ ] [Sparklines](https://github.com/0xPIT/ESParklines)