add: oled display when in wifi config mode
This commit is contained in:
parent
d11420a398
commit
c7c4d2940d
@ -12,7 +12,7 @@ OverlayCallback overlays[] = { timeOverlay };
|
||||
void timeOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
|
||||
String time("");
|
||||
|
||||
if( localIP == "Unconnected" ) {
|
||||
if( localIP == "Unconnected" or localIP == "10.1.1.1" ) {
|
||||
unsigned long mscount = millis();
|
||||
unsigned long sec = mscount / 1000;
|
||||
unsigned long mse = mscount / 100 - sec * 10;
|
||||
@ -29,7 +29,7 @@ void timeOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
|
||||
int frameCount = 3;
|
||||
FrameCallback frames[] = { oledWebFrame, oledBilibiliFrame, oledOsFrame };
|
||||
|
||||
static void oledTitle(OLEDDisplay *display, String s, int16_t x, int16_t y) {
|
||||
void oledTitle(OLEDDisplay *display, String s, int16_t x, int16_t y) {
|
||||
// Title
|
||||
display->setFont(Roboto_Mono_13);
|
||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||
@ -82,7 +82,7 @@ void oledOsFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int
|
||||
|
||||
// Version
|
||||
display->drawFastImage(0+x, 16+y, 16, 16, Board_Icon);
|
||||
display->drawString(24+x, 18+y, ver);
|
||||
display->drawString(24+x, 18+y, boardVersion);
|
||||
|
||||
// WiFi
|
||||
if( localIP == "Unconnected")
|
||||
|
@ -36,35 +36,6 @@ const unsigned char Bilibilitv_Icon[] PROGMEM = {
|
||||
0x03,0x00,0xc0,0xff,0xff,0xff,0x78,0x00,0x1e,0x30,0x00,0x0c
|
||||
};
|
||||
|
||||
#define WiFi_Logo_width 60
|
||||
#define WiFi_Logo_height 36
|
||||
const uint8_t WiFi_Logo_bits[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
|
||||
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
|
||||
0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
|
||||
0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
|
||||
0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
|
||||
0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
|
||||
0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
|
||||
0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
|
||||
0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
|
||||
0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
|
||||
0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
|
||||
0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
|
||||
0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
|
||||
0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
|
||||
0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
|
||||
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
const uint8_t Active_Symbol_Icon[] PROGMEM = {
|
||||
B00000000,
|
||||
B00000000,
|
||||
@ -87,6 +58,7 @@ const uint8_t Inactive_Symbol_Icon[] PROGMEM = {
|
||||
B00000000
|
||||
};
|
||||
|
||||
void oledTitle(OLEDDisplay *display, String s, int16_t x, int16_t y);
|
||||
void oledWebFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
||||
void oledMQTTFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
||||
void oledBilibiliFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifdef __UTILS__
|
||||
#ifndef __UTILS__
|
||||
#include <utils.h>
|
||||
#endif
|
||||
|
||||
@ -13,9 +13,21 @@
|
||||
#include <TimeLib.h>
|
||||
#include <WiFiUdp.h>
|
||||
|
||||
String ver("v0.0.1");
|
||||
// Global Config
|
||||
String boardVersion("v0.0.1");
|
||||
String localIP("Unconnected");
|
||||
|
||||
IPConfig APStatic = {
|
||||
IPAddress(10, 1, 1, 1),
|
||||
IPAddress(10, 0, 1, 1),
|
||||
IPAddress(255, 255, 255, 0)
|
||||
};
|
||||
IPConfig STAStatic = {
|
||||
IPAddress(192, 168, 43, 141),
|
||||
IPAddress(192,168,0,1),
|
||||
IPAddress(255, 255, 255, 0)
|
||||
};
|
||||
|
||||
// https://github.com/PaulStoffregen/Time/blob/master/examples/TimeNTP_ESP8266WiFi/TimeNTP_ESP8266WiFi.ino
|
||||
static const int timeZone = 8;
|
||||
static const int NTP_PACKET_SIZE = 48;
|
||||
|
@ -2,9 +2,24 @@
|
||||
#define __UTILS__
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
extern String ver;
|
||||
#define WiFiSSID "Info Board"
|
||||
#define WiFipswd "cj160217"
|
||||
|
||||
// Variable Type Definition
|
||||
typedef struct IPConfig {
|
||||
IPAddress ip;
|
||||
IPAddress gw;
|
||||
IPAddress sn;
|
||||
} IPConfig;
|
||||
|
||||
|
||||
// Global Variable
|
||||
extern String boardVersion;
|
||||
extern String localIP;
|
||||
extern IPConfig APStatic;
|
||||
extern IPConfig STAStatic;
|
||||
|
||||
extern long follower;
|
||||
extern long view;
|
||||
|
45
src/main.cpp
45
src/main.cpp
@ -15,26 +15,29 @@
|
||||
// Global arguments
|
||||
Ticker temp;
|
||||
Ticker task;
|
||||
// 128 * 64 display
|
||||
SSD1306Wire display(0x3c, 4, 5);
|
||||
int minCount;
|
||||
SSD1306Wire display(0x3c, SDA, SCL); // 128 * 64 display
|
||||
OLEDDisplayUi ui(&display);
|
||||
|
||||
void initSystem();
|
||||
void initWiFi();
|
||||
void configModeCallback(WiFiManager *config);
|
||||
void initOLED();
|
||||
void blink();
|
||||
// void minCountCallBack();
|
||||
|
||||
void setup() {
|
||||
initSystem();
|
||||
Serial.begin(115200);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
temp.attach(1, blink);
|
||||
|
||||
initOLED();
|
||||
|
||||
initWiFi();
|
||||
initNtp();
|
||||
initOLED();
|
||||
initData();
|
||||
|
||||
|
||||
temp.detach();
|
||||
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
// task.attach(60, minCountCallBack);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@ -48,12 +51,6 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
void initSystem() {
|
||||
Serial.begin(115200);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
temp.attach(1, blink);
|
||||
}
|
||||
|
||||
void blink() {
|
||||
int state = digitalRead(LED_BUILTIN);
|
||||
digitalWrite(LED_BUILTIN, !state);
|
||||
@ -67,18 +64,10 @@ void initWiFi() {
|
||||
manager.setMinimumSignalQuality(40);
|
||||
|
||||
manager.setAPCallback(configModeCallback);
|
||||
manager.setAPStaticIPConfig(
|
||||
IPAddress(10, 1, 1, 1),
|
||||
IPAddress(10, 0, 1, 1),
|
||||
IPAddress(255, 255, 255, 0)
|
||||
);
|
||||
manager.setSTAStaticIPConfig(
|
||||
IPAddress(192, 168, 43, 141),
|
||||
IPAddress(192,168,0,1),
|
||||
IPAddress(255, 255, 255, 0)
|
||||
);
|
||||
manager.setAPStaticIPConfig(APStatic.ip, APStatic.gw, APStatic.sn);
|
||||
manager.setSTAStaticIPConfig(STAStatic.ip, STAStatic.gw, STAStatic.sn);
|
||||
|
||||
if( !manager.autoConnect("Info Board", "cj160217") ) {
|
||||
if( !manager.autoConnect(WiFiSSID, WiFipswd) ) {
|
||||
ESP.reset();
|
||||
delay(1000);
|
||||
}
|
||||
@ -88,6 +77,12 @@ void initWiFi() {
|
||||
|
||||
void configModeCallback(WiFiManager *config) {
|
||||
temp.attach(0.1, blink);
|
||||
|
||||
oledTitle(&display, "Info Board", 0, 0);
|
||||
display.setTextAlignment(TEXT_ALIGN_LEFT);
|
||||
display.drawString(0, 16, "SSID : " + (String)WiFiSSID);
|
||||
display.drawString(0, 30, " IP : " + APStatic.ip.toString());
|
||||
display.display();
|
||||
}
|
||||
|
||||
void initOLED() {
|
||||
|
Loading…
Reference in New Issue
Block a user