fix: usage of PROGMEM

This commit is contained in:
liuyihui 2022-01-10 20:26:01 +08:00
parent c5b6d731ba
commit ebd1a07f6d
2 changed files with 29 additions and 19 deletions

View File

@ -28,13 +28,13 @@ void oledTitle(OLEDDisplay *display, String s, int16_t x, int16_t y) {
void oledWebFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
// Title
oledTitle(display, "Fox Home", x, y);
oledTitle(display, F("Fox Home"), x, y);
// Items
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0+x, 16+y, "Today");
display->drawString(0+x, 30+y, "Last Week");
display->drawString(0+x, 44+y, "Last Month");
display->drawString(0+x, 16+y, F("Today"));
display->drawString(0+x, 30+y, F("Last Week"));
display->drawString(0+x, 44+y, F("Last Month"));
// Values
display->setTextAlignment(TEXT_ALIGN_RIGHT);
@ -49,13 +49,13 @@ void oledMQTTFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, i
void oledBilibiliFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
// Title
oledTitle(display, "BiliBili", x, y);
oledTitle(display, F("BiliBili"), x, y);
// Items
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0+x, 16+y, "Follower");
display->drawString(0+x, 30+y, "View");
display->drawString(0+x, 44+y, "Likes");
display->drawString(0+x, 16+y, F("Follower"));
display->drawString(0+x, 30+y, F("View"));
display->drawString(0+x, 44+y, F("Likes"));
// Values
display->setTextAlignment(TEXT_ALIGN_RIGHT);
@ -66,11 +66,17 @@ void oledBilibiliFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t
void oledOsFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
// Title
oledTitle(display, "INFO BOARD", x, y);
display->setTextAlignment(TEXT_ALIGN_LEFT);
oledTitle(display, F("INFO BOARD"), x, y);
// Version
display->drawString(0+x, 16+y, "Ver: " + Board.Version);
display->drawString(0+x, 30+y, "IP : " + Board.ip.toString());
display->drawString(0+x, 44+y, "Mem: " + (String)(80.0-ESP.getFreeHeap()/1024.0) + "/80 kB");
// Items
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0+x, 16+y, F("Ver: "));
display->drawString(0+x, 30+y, F("IP : "));
display->drawString(0+x, 44+y, F("Mem: "));
// Values
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->drawString(120+x, 16+y, Board.Version);
display->drawString(120+x, 30+y, Board.ip.toString());
display->drawString(120+x, 44+y, (String)(ESP.getFreeHeap()) + " byte");
}

View File

@ -124,8 +124,8 @@ static String followerUrl = "http://api.bilibili.com/x/relation/stat?vmid=" + UI
static String viewAndLikesUrl = "http://api.bilibili.com/x/space/upstat?mid=" + UID;
static String webViewerUrl = "https://api.foolishfox.cn/data/board.json";
static const char UserAgent[] PROGMEM = "UserAgent";
static const char Cookie[] PROGMEM = "Cookie";
const char UserAgent[] PROGMEM = "UserAgent";
const char Cookie[] PROGMEM = "Cookie";
static WiFiClient client;
std::unique_ptr<BearSSL::WiFiClientSecure>clientSecure(new BearSSL::WiFiClientSecure);
@ -136,8 +136,10 @@ static void getFollower() {
http.begin(client, followerUrl);
int resCode = http.GET();
if( resCode == 200 ) {
String resBuffer = http.getString();
Serial.println(resBuffer);
DeserializationError error = deserializeJson(jsonBuffer, resBuffer);
if( error ) {
@ -148,7 +150,7 @@ static void getFollower() {
follower = jsonBuffer["data"]["follower"];
} else {
Serial.printf("[HTTP] GET Follower failed, error: %d\n", resCode);
Serial.printf_P(PSTR("[HTTP] GET Follower failed, error: %d\n"), resCode);
}
http.end();
@ -165,6 +167,7 @@ static void getViewAndLikes() {
int resCode = http.GET();
if( resCode == 200 ) {
String resBuffer = http.getString();
Serial.println(resBuffer);
DeserializationError error = deserializeJson(jsonBuffer, resBuffer);
if( error ) {
@ -176,7 +179,7 @@ static void getViewAndLikes() {
likes = jsonBuffer["data"]["likes"];
view = jsonBuffer["data"]["archive"]["view"];
} else {
Serial.printf("[HTTP] GET View & Likes failed, error: %d\n", resCode);
Serial.printf_P(PSTR("[HTTP] GET View & Likes failed, error: %d\n"), resCode);
}
http.end();
@ -190,6 +193,7 @@ static void getWebView() {
int resCode = https.GET();
if( resCode == 200 ) {
String resBuffer = https.getString();
Serial.println(resBuffer);
DeserializationError error = deserializeJson(jsonBuffer, resBuffer);
if( error ) {
@ -202,7 +206,7 @@ static void getWebView() {
weekView = jsonBuffer["week"];
monthView = jsonBuffer["month"];
} else {
Serial.printf("[HTTP] GET Web View failed, error: %d\n", resCode);
Serial.printf_P(PSTR("[HTTP] GET Web View failed, error: %d\n"), resCode);
}
https.end();