change: board info
This commit is contained in:
parent
c7c4d2940d
commit
75739c0f69
@ -10,19 +10,8 @@ int overlaysCount = 1;
|
|||||||
OverlayCallback overlays[] = { timeOverlay };
|
OverlayCallback overlays[] = { timeOverlay };
|
||||||
|
|
||||||
void timeOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
|
void timeOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
|
||||||
String time("");
|
|
||||||
|
|
||||||
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;
|
|
||||||
time = (String)sec + "." + (String)mse;
|
|
||||||
} else {
|
|
||||||
time = ntpTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display->drawString(64, 54, time);
|
display->drawString(64, 54, ntpTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
// frames
|
// frames
|
||||||
@ -81,13 +70,7 @@ void oledOsFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int
|
|||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
display->drawFastImage(0+x, 16+y, 16, 16, Board_Icon);
|
display->drawString(0+x, 16+y, "Ver: " + Board.Version);
|
||||||
display->drawString(24+x, 18+y, boardVersion);
|
display->drawString(0+x, 30+y, "IP : " + Board.ip.toString());
|
||||||
|
display->drawString(0+x, 44+y, "Mem: " + (String)(80.0-ESP.getFreeHeap()/1024) + "/80 kB");
|
||||||
// WiFi
|
|
||||||
if( localIP == "Unconnected")
|
|
||||||
display->drawFastImage(0+x, 34+y, 16, 16, Wifi_Unconnected_Icon);
|
|
||||||
else
|
|
||||||
display->drawFastImage(0+x, 34+y, 16, 16, Wifi_Connected_Icon);
|
|
||||||
display->drawString(24+x, 36+y, localIP);
|
|
||||||
}
|
}
|
@ -14,9 +14,6 @@
|
|||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
|
|
||||||
// Global Config
|
// Global Config
|
||||||
String boardVersion("v0.0.1");
|
|
||||||
String localIP("Unconnected");
|
|
||||||
|
|
||||||
IPConfig APStatic = {
|
IPConfig APStatic = {
|
||||||
IPAddress(10, 1, 1, 1),
|
IPAddress(10, 1, 1, 1),
|
||||||
IPAddress(10, 0, 1, 1),
|
IPAddress(10, 0, 1, 1),
|
||||||
@ -27,6 +24,10 @@ IPConfig STAStatic = {
|
|||||||
IPAddress(192,168,0,1),
|
IPAddress(192,168,0,1),
|
||||||
IPAddress(255, 255, 255, 0)
|
IPAddress(255, 255, 255, 0)
|
||||||
};
|
};
|
||||||
|
BoardInfo Board = {
|
||||||
|
"0.0.1",
|
||||||
|
WiFi.localIP()
|
||||||
|
};
|
||||||
|
|
||||||
// https://github.com/PaulStoffregen/Time/blob/master/examples/TimeNTP_ESP8266WiFi/TimeNTP_ESP8266WiFi.ino
|
// https://github.com/PaulStoffregen/Time/blob/master/examples/TimeNTP_ESP8266WiFi/TimeNTP_ESP8266WiFi.ino
|
||||||
static const int timeZone = 8;
|
static const int timeZone = 8;
|
||||||
@ -110,19 +111,20 @@ String ntpTime() {
|
|||||||
return timeString;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long view = 0;
|
||||||
|
long likes = 0;
|
||||||
|
long follower = 0;
|
||||||
|
long dayView = 0;
|
||||||
|
long weekView = 0;
|
||||||
|
long monthView = 0;
|
||||||
|
|
||||||
static String UID = "450115492";
|
static String UID = "450115492";
|
||||||
static String followerUrl = "https://api.bilibili.com/x/relation/stat?vmid=" + UID;
|
static String followerUrl = "https://api.bilibili.com/x/relation/stat?vmid=" + UID;
|
||||||
static String viewAndLikesUrl = "https://api.bilibili.com/x/space/upstat?mid=" + UID;
|
static String viewAndLikesUrl = "https://api.bilibili.com/x/space/upstat?mid=" + UID;
|
||||||
static String webViewerUrl = "https://api.foolishfox.cn/data/board.json";
|
static String webViewerUrl = "https://api.foolishfox.cn/data/board.json";
|
||||||
|
|
||||||
long follower = 0;
|
static bool clientFlag = false;
|
||||||
long view = 0;
|
|
||||||
long likes = 0;
|
|
||||||
|
|
||||||
long dayView = 0;
|
|
||||||
long weekView = 0;
|
|
||||||
long monthView = 0;
|
|
||||||
|
|
||||||
static HTTPClient httpFllower;
|
static HTTPClient httpFllower;
|
||||||
static HTTPClient httpViewAndLikes;
|
static HTTPClient httpViewAndLikes;
|
||||||
static HTTPClient httpWebView;
|
static HTTPClient httpWebView;
|
||||||
@ -198,8 +200,11 @@ void getWebView() {
|
|||||||
httpWebView.end();
|
httpWebView.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initData() {
|
void getData() {
|
||||||
client.setInsecure();
|
if( !clientFlag ) {
|
||||||
|
client.setInsecure();
|
||||||
|
clientFlag = true;
|
||||||
|
}
|
||||||
getWebView();
|
getWebView();
|
||||||
getFollower();
|
getFollower();
|
||||||
getViewAndLikes();
|
getViewAndLikes();
|
||||||
|
@ -14,12 +14,16 @@ typedef struct IPConfig {
|
|||||||
IPAddress sn;
|
IPAddress sn;
|
||||||
} IPConfig;
|
} IPConfig;
|
||||||
|
|
||||||
|
typedef struct BoardInfo {
|
||||||
|
String Version;
|
||||||
|
IPAddress ip;
|
||||||
|
} BoardInfo;
|
||||||
|
|
||||||
|
|
||||||
// Global Variable
|
// Global Variable
|
||||||
extern String boardVersion;
|
|
||||||
extern String localIP;
|
|
||||||
extern IPConfig APStatic;
|
extern IPConfig APStatic;
|
||||||
extern IPConfig STAStatic;
|
extern IPConfig STAStatic;
|
||||||
|
extern BoardInfo Board;
|
||||||
|
|
||||||
extern long follower;
|
extern long follower;
|
||||||
extern long view;
|
extern long view;
|
||||||
@ -32,7 +36,7 @@ extern long monthView;
|
|||||||
void initNtp();
|
void initNtp();
|
||||||
String ntpTime();
|
String ntpTime();
|
||||||
|
|
||||||
void initData();
|
void getData();
|
||||||
void getFollower();
|
void getFollower();
|
||||||
void getViewAndLikes();
|
void getViewAndLikes();
|
||||||
void getWebView();
|
void getWebView();
|
||||||
|
19
src/main.cpp
19
src/main.cpp
@ -15,15 +15,15 @@
|
|||||||
// Global arguments
|
// Global arguments
|
||||||
Ticker temp;
|
Ticker temp;
|
||||||
Ticker task;
|
Ticker task;
|
||||||
int minCount;
|
int minCount = 0;
|
||||||
SSD1306Wire display(0x3c, SDA, SCL); // 128 * 64 display
|
SSD1306Wire display(0x3c, SDA, SCL); // 128 * 64 display
|
||||||
OLEDDisplayUi ui(&display);
|
OLEDDisplayUi ui(&display);
|
||||||
|
|
||||||
|
void blink();
|
||||||
void initWiFi();
|
void initWiFi();
|
||||||
void configModeCallback(WiFiManager *config);
|
void configModeCallback(WiFiManager *config);
|
||||||
void initOLED();
|
void initOLED();
|
||||||
void blink();
|
void minCountCallBack();
|
||||||
// void minCountCallBack();
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
@ -37,7 +37,8 @@ void setup() {
|
|||||||
|
|
||||||
temp.detach();
|
temp.detach();
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
// task.attach(60, minCountCallBack);
|
minCountCallBack();
|
||||||
|
task.attach(60, minCountCallBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@ -72,7 +73,7 @@ void initWiFi() {
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
localIP = WiFi.localIP().toString();
|
Board.ip = WiFi.localIP();
|
||||||
}
|
}
|
||||||
|
|
||||||
void configModeCallback(WiFiManager *config) {
|
void configModeCallback(WiFiManager *config) {
|
||||||
@ -103,3 +104,11 @@ void initOLED() {
|
|||||||
|
|
||||||
display.flipScreenVertically();
|
display.flipScreenVertically();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void minCountCallBack() {
|
||||||
|
if( minCount%60 == 0 ) {
|
||||||
|
minCount = 0;
|
||||||
|
getData();
|
||||||
|
}
|
||||||
|
minCount += 1;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user