56 lines
1008 B
C++
56 lines
1008 B
C++
#include <Arduino.h>
|
|
#include <WiFiManager.h>
|
|
#include <WiFi.h>
|
|
#include <SPI.h>
|
|
#include <Arduino_GFX_Library.h>
|
|
#include "ui.h"
|
|
#include "config.h"
|
|
#include "gauge_airspeed.h"
|
|
|
|
Arduino_DataBus *bus = new Arduino_ESP32SPI(27, 5, 14, 15, -1, VSPI);
|
|
Arduino_GFX *gfx = new Arduino_GC9A01(bus, 33, 0, true);
|
|
|
|
WiFiManager wifiManager;
|
|
#define SW1 19
|
|
#ifndef BAUDRATE
|
|
#define BAUDRATE 115200
|
|
#endif
|
|
bool serialEnabled = false;
|
|
|
|
void log(const char *msg) {
|
|
if (serialEnabled) {
|
|
Serial.print(msg);
|
|
}
|
|
}
|
|
|
|
void registerWifi() {
|
|
drawWifi(gfx);
|
|
log("Create Access Point SSID\n");
|
|
log(AP_SSID);
|
|
wifiManager.autoConnect(AP_SSID);
|
|
}
|
|
|
|
void setup() {
|
|
if (!gfx->begin()) {
|
|
while (1);
|
|
}
|
|
|
|
Serial.begin(BAUDRATE);
|
|
delay(2000);
|
|
serialEnabled = (bool)Serial;
|
|
log("Serial initialized\n");
|
|
|
|
pinMode(SW1, INPUT_PULLUP);
|
|
// registerWifi();
|
|
}
|
|
|
|
void loop() {
|
|
if (digitalRead(SW1) == LOW) {
|
|
log("Button pressed\n");
|
|
}
|
|
gfx->fillScreen(BACKGROUND);
|
|
gauge(gfx, 50);
|
|
delay(10);
|
|
for(;;);
|
|
}
|