mirror of
https://github.com/JADE-Jerry/jcalendar.git
synced 2025-12-06 09:32:48 +08:00
Compare commits
3 Commits
d085750073
...
21dc3ff831
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21dc3ff831 | ||
|
|
6e3d9cd06d | ||
|
|
0865a9492a |
@@ -126,12 +126,16 @@ A: 2025年3月1日后注册的和风天气账户有API Host限制,请下载1.0
|
||||
A: 在系统运行状态下(状态灯常亮),单击按键,稍等即可切换课程表的展示。
|
||||
|
||||
## Releases
|
||||
### 1.1.3
|
||||
* Fix: some bugs.
|
||||
### 1.1.2
|
||||
* Refine: 功耗
|
||||
### 1.1.1
|
||||
* New Featue: 增加对电池的测量和显示。
|
||||
### 1.1.0
|
||||
* New Feature: 课程表。
|
||||
* Refine: 对针脚统一配置。
|
||||
* Fix: Some bugs.
|
||||
* Fix: some bugs.
|
||||
### 1.0.27
|
||||
* Fix: 闰月错误。(bug from nongli lib)
|
||||
### 1.0.26
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -18,7 +18,6 @@
|
||||
#define I2C_SDA GPIO_NUM_21
|
||||
#define I2C_SCL GPIO_NUM_22
|
||||
// Other PIN
|
||||
#define PIN_BUZZ -1
|
||||
#define KEY_M GPIO_NUM_14 // 注意:由于此按键负责唤醒,因此需要选择支持RTC唤醒的PIN脚。
|
||||
#define PIN_LED_R GPIO_NUM_22
|
||||
|
||||
|
||||
73
src/main.cpp
73
src/main.cpp
@@ -329,71 +329,62 @@ void buttonLongPressStop(void* oneButton) {
|
||||
#define TIMEOUT_TO_SLEEP 10 // seconds
|
||||
time_t blankTime = 0;
|
||||
void go_sleep() {
|
||||
// 设置唤醒时间为下个偶数整点。
|
||||
time_t now = time(NULL);
|
||||
struct tm tmNow = { 0 };
|
||||
// Serial.printf("Now: %ld -- %s\n", now, ctime(&now));
|
||||
localtime_r(&now, &tmNow); // 时间戳转化为本地时间结构
|
||||
|
||||
uint64_t p;
|
||||
// 根据配置情况来刷新,如果未配置qweather信息,则24小时刷新,否则每2小时刷新
|
||||
Preferences pref;
|
||||
pref.begin(PREF_NAMESPACE);
|
||||
String _qweather_key = pref.getString(PREF_QWEATHER_KEY, "");
|
||||
pref.end();
|
||||
|
||||
time_t now;
|
||||
time(&now);
|
||||
struct tm local;
|
||||
localtime_r(&now, &local);
|
||||
if (_qweather_key.length() == 0 || weather_type() == 0) { // 没有配置天气或者使用按日天气,则第二天刷新。
|
||||
Serial.println("Sleep to next day.");
|
||||
now += 3600 * 24;
|
||||
localtime_r(&now, &tmNow); // 将新时间转成tm
|
||||
// Serial.printf("Set1: %ld -- %s\n", now, ctime(&now));
|
||||
|
||||
struct tm tmNew = { 0 };
|
||||
tmNew.tm_year = tmNow.tm_year;
|
||||
tmNew.tm_mon = tmNow.tm_mon; // 月份从0开始
|
||||
tmNew.tm_mday = tmNow.tm_mday; // 日期
|
||||
tmNew.tm_hour = 0; // 小时
|
||||
tmNew.tm_min = 0; // 分钟
|
||||
tmNew.tm_sec = 10; // 秒, 防止离线时出现时间误差,所以,延后10s
|
||||
time_t set = mktime(&tmNew);
|
||||
|
||||
p = (uint64_t)(set - time(NULL));
|
||||
} else {
|
||||
if (tmNow.tm_hour % 2 == 0) { // 将时间推后两个小时,偶整点刷新。
|
||||
now += 7200;
|
||||
} else {
|
||||
now += 3600;
|
||||
// Sleep to next day
|
||||
int secondsToNextDay = (24 - local.tm_hour) * 3600 - local.tm_min * 60 - local.tm_sec;
|
||||
if (secondsToNextDay <= 0) {
|
||||
secondsToNextDay += 24 * 3600;
|
||||
}
|
||||
localtime_r(&now, &tmNow); // 将新时间转成tm
|
||||
// Serial.printf("Set1: %ld -- %s\n", now, ctime(&now));
|
||||
|
||||
struct tm tmNew = { 0 };
|
||||
tmNew.tm_year = tmNow.tm_year;
|
||||
tmNew.tm_mon = tmNow.tm_mon; // 月份从0开始
|
||||
tmNew.tm_mday = tmNow.tm_mday; // 日期
|
||||
tmNew.tm_hour = tmNow.tm_hour; // 小时
|
||||
tmNew.tm_min = 0; // 分钟
|
||||
tmNew.tm_sec = 10; // 秒, 防止离线时出现时间误差,所以,延后10s
|
||||
time_t set = mktime(&tmNew);
|
||||
|
||||
p = (uint64_t)(set - time(NULL));
|
||||
Serial.printf("Seconds to next day: %d seconds.\n", secondsToNextDay);
|
||||
p = (uint64_t)(secondsToNextDay);
|
||||
} else {
|
||||
// Sleep to next even hour.
|
||||
int secondsToNextHour = (60 - local.tm_min) * 60 - local.tm_sec;
|
||||
if (secondsToNextHour <= 0) {
|
||||
secondsToNextHour += 3600;
|
||||
}
|
||||
if ((local.tm_hour % 2) == 0) { // 如果是奇数点,则多睡1小时
|
||||
secondsToNextHour += 3600;
|
||||
}
|
||||
Serial.printf("Seconds to next even hour: %d seconds.\n", secondsToNextHour);
|
||||
p = (uint64_t)(secondsToNextHour);
|
||||
}
|
||||
Serial.printf("Sleep time: %ld seconds\n", p);
|
||||
p += 10; // 额外增加10秒,避免过早唤醒
|
||||
|
||||
esp_sleep_enable_timer_wakeup(p * (uint64_t)uS_TO_S_FACTOR);
|
||||
esp_sleep_enable_ext0_wakeup(KEY_M, LOW);
|
||||
|
||||
// 省电考虑,关闭RTC外设和存储器
|
||||
// esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF); // RTC IO, sensors and ULP, 注意:由于需要按键唤醒,所以不能关闭,否则会导致RTC_IO唤醒失败
|
||||
// esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF); // RTC IO, sensors and ULP, 注意:由于需要按键唤醒,所以不能关闭,否则会导致RTC_IO唤醒(ext0)失败
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF); //
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF);
|
||||
|
||||
gpio_deep_sleep_hold_dis(); // 解除所有引脚的保持状态
|
||||
|
||||
// 省电考虑,重置gpio,平均每针脚能省8ua。
|
||||
gpio_reset_pin(PIN_LED_R); // 减小deep-sleep电流
|
||||
gpio_reset_pin(SPI_CS); // 减小deep-sleep电流
|
||||
gpio_reset_pin(SPI_DC); // 减小deep-sleep电流
|
||||
gpio_reset_pin(SPI_RST); // 减小deep-sleep电流
|
||||
gpio_reset_pin(SPI_BUSY); // 减小deep-sleep电流
|
||||
gpio_reset_pin(SPI_MOSI); // 减小deep-sleep电流
|
||||
gpio_reset_pin(SPI_MISO); // 减小deep-sleep电流
|
||||
gpio_reset_pin(SPI_SCK); // 减小deep-sleep电流
|
||||
gpio_reset_pin(PIN_ADC); // 减小deep-sleep电流
|
||||
gpio_reset_pin(I2C_SDA); // 减小deep-sleep电流
|
||||
gpio_reset_pin(I2C_SCL); // 减小deep-sleep电流
|
||||
|
||||
delay(10);
|
||||
Serial.println("Deep sleep...");
|
||||
|
||||
@@ -1057,6 +1057,7 @@ void task_screen(void* param) {
|
||||
|
||||
init_cal_layout_size();
|
||||
display.setFullWindow();
|
||||
display.firstPage();
|
||||
display.fillScreen(GxEPD_WHITE);
|
||||
do {
|
||||
if (_si_type == 1) {
|
||||
@@ -1074,7 +1075,7 @@ void task_screen(void* param) {
|
||||
if (weather_status() == 1) {
|
||||
draw_weather(false);
|
||||
}
|
||||
if (voltage > 1000) {
|
||||
if (voltage > 1000 && voltage < 4300) {
|
||||
draw_status(false);
|
||||
}
|
||||
} while (display.nextPage());
|
||||
@@ -1087,6 +1088,7 @@ void task_screen(void* param) {
|
||||
pref.end();
|
||||
|
||||
display.powerOff(); // !!!important!!!, 关闭屏幕,否则会多0.5ma的空载电流(全屏刷新的话会自动关闭,局部刷新必须手动关闭)
|
||||
display.hibernate();
|
||||
Serial.println("[Task] screen update end...");
|
||||
|
||||
_screen_status = 1;
|
||||
@@ -1154,4 +1156,5 @@ void si_warning(const char* str) {
|
||||
} while (display.nextPage());
|
||||
|
||||
display.powerOff();
|
||||
display.hibernate();
|
||||
}
|
||||
Reference in New Issue
Block a user