main.cpp文件如下:
#include <Arduino.h> #include <ArduinoJson.h> #include <WiFiManager.h> #include "OneButton.h" #include "led.h" #include "_sntp.h" #include "weather.h" #include "screen_ink.h" #include "_preference.h" #include "version.h" #include <esp_attr.h> #define PIN_BUTTON GPIO_NUM_14 // 注意:由于此按键负责唤醒,因此需要选择支持RTC唤醒的PIN脚。 OneButton button; RTC_DATA_ATTR volatile int _display_mode =0; void IRAM_ATTR checkTicks() { button.tick(); } WiFiManager wm; WiFiManagerParameter para_qweather_host("qweather_host", "和风天气Host", "", 64); // 和风天气key WiFiManagerParameter para_qweather_key("qweather_key", "和风天气API Key", "", 32); // 和风天气key // const char* test_html = "<br/><label for='test'>天气模式</label><br/><input type='radio' name='test' value='0' checked> 每日天气test </input><input type='radio' name='test' value='1'> 实时天气test</input>"; // WiFiManagerParameter para_test(test_html); WiFiManagerParameter para_qweather_type("qweather_type", "天气类型(0:每日天气,1:实时天气)", "0", 2, "pattern='\[0-1]{1}'"); // 城市code WiFiManagerParameter para_qweather_location("qweather_loc", "位置ID", "", 64); // 城市code WiFiManagerParameter para_cd_day_label("cd_day_label", "倒数日(4字以内)", "", 10); // 倒数日 WiFiManagerParameter para_cd_day_date("cd_day_date", "日期(yyyyMMdd)", "", 8, "pattern='\d{8}'"); // 城市code WiFiManagerParameter para_tag_days("tag_days", "日期Tag(yyyyMMddx,详见README)", "", 30); // 日期Tag WiFiManagerParameter para_si_week_1st("si_week_1st", "每周起始(0:周日,1:周一)", "0", 2, "pattern='\[0-1]{1}'"); // 每周第一天 void print_wakeup_reason() { esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause(); switch (wakeup_reason) { case ESP_SLEEP_WAKEUP_EXT0: Serial.println(F("Wakeup caused by external signal using RTC_IO")); _display_mode++; _display_mode %= 3; Serial.printf("display mode: %drn", _display_mode); break; case ESP_SLEEP_WAKEUP_EXT1: Serial.println(F("Wakeup caused by external signal using RTC_CNTL")); break; case ESP_SLEEP_WAKEUP_TIMER: Serial.println(F("Wakeup caused by timer")); break; case ESP_SLEEP_WAKEUP_TOUCHPAD: Serial.println(F("Wakeup caused by touchpad")); break; case ESP_SLEEP_WAKEUP_ULP: Serial.println(F("Wakeup caused by ULP program")); break; default: Serial.printf( "Wakeup was not caused by deep sleep.n"); } } void buttonClick(void* oneButton); void buttonDoubleClick(void* oneButton); void buttonLongPressStop(void* oneButton); void go_sleep(); unsigned long _idle_millis; unsigned long TIME_TO_SLEEP = 180 * 1000; bool _wifi_flag = false; unsigned long _wifi_failed_millis; void setup() { delay(10); Serial.begin(115200); Serial.println("."); print_wakeup_reason(); Serial.println("rnrnrn"); delay(10); button.setup(PIN_BUTTON,INPUT_PULLUP,true); button.setClickMs(300); button.setPressMs(3000); // 设置长按的时长 button.attachClick(buttonClick, &button); button.attachDoubleClick(buttonDoubleClick, &button); // button.attachMultiClick() button.attachLongPressStop(buttonLongPressStop, &button); attachInterrupt(digitalPinToInterrupt(PIN_BUTTON), checkTicks, CHANGE); Serial.printf("***********************rn"); Serial.printf(" J-Calendarrn"); Serial.printf(" version: %srn", J_VERSION); Serial.printf("***********************rnrn"); Serial.printf("Copyright © 2022-2025 JADE Software Co., Ltd. All Rights Reserved.rnrn"); led_init(); led_fast();





没有回复内容