Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API修复 #36

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions AIO_Firmware_PIO/AIO_Firmware_PIO.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"files.associations": {
"*.ino": "cpp",
"array": "cpp",
"deque": "cpp",
"list": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"string_view": "cpp",
"initializer_list": "cpp"
}
}
}
4 changes: 2 additions & 2 deletions AIO_Firmware_PIO/lib/lvgl-v8.3/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
*-----------*/

/*Enable the log module*/
#define LV_USE_LOG 0
#define LV_USE_LOG 1
#if LV_USE_LOG

/*How important log should be added:
Expand Down Expand Up @@ -377,7 +377,7 @@
#define LV_FONT_MONTSERRAT_12_SUBPX 0
#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/
#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/
#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/
#define LV_FONT_SIMSUN_16_CJK 1 /*1000 most common CJK radicals*/

/*Pixel perfect monospace fonts*/
#define LV_FONT_UNSCII_8 0
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion AIO_Firmware_PIO/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ build_flags =
; -D LV_FONT_MONTSERRAT_10=1
-fPIC -Wreturn-type -Werror=return-type

upload_port = COM3
upload_port = COM83
; upload_port = COM6
upload_speed = 921600
board_build.partitions = partitions-no-ota.csv
Expand Down
30 changes: 30 additions & 0 deletions AIO_Firmware_PIO/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 临时更新 v2.1.6.x

备注:v2.1.6.x为临时修改版本(4位版本号)【by:神秘藏宝室】

等待AIO作者:溜马小哥 有空时候更新会发布正式版本(3位版本号)

```
//v2.1.6.3
修复API接口

#define AIO_VERSION "2.1.6.2"
//修改by:神秘藏宝室
//v2.1.6.2
//修正Weather最高和最低温度显示

//v2.1.6.1
//修复Weather的API,原来的API已废弃
//修复Weater的第二页y轴坐标显示
//默认开启性能模式【第一次烧录,或者清空重新刷固件有效】
```



## 更新1:修复Weather的API,原来的API已废弃

![image-20230613220752512](media/image-20230613220752512.png)

## 更新2:修复Weater的第二页y轴坐标显示

![image-20230613220830046](media/image-20230613220830046.png)
4 changes: 2 additions & 2 deletions AIO_Firmware_PIO/src/app/media_player/media_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ static bool video_start(bool create_new)
if (NULL != strstr(run_data->pfile->file_name, ".mjpeg") || NULL != strstr(run_data->pfile->file_name, ".MJPEG"))
{
// 直接解码mjpeg格式的视频
run_data->player_docoder = new MjpegPlayDocoder(&run_data->file, true);
run_data->player_docoder = new MjpegPlayDocoder(&run_data->file, false);
Serial.print(F("MJPEG video start --------> "));
}
else if (NULL != strstr(run_data->pfile->file_name, ".rgb") || NULL != strstr(run_data->pfile->file_name, ".RGB"))
{
// 使用RGB格式的视频
run_data->player_docoder = new RgbPlayDocoder(&run_data->file, true);
run_data->player_docoder = new RgbPlayDocoder(&run_data->file, false);
Serial.print(F("RGB565 video start --------> "));
}

Expand Down
15 changes: 15 additions & 0 deletions AIO_Firmware_PIO/src/app/media_player/mjpeg_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ bool MjpegPlayDocoder::video_start()
else
{
m_displayBuf = (uint8_t *)malloc(MOVIE_BUFFER_SIZE);
m_jpegBuf = (uint8_t *)malloc(JPEG_BUFFER_SIZE);
tft->setAddrWindow((tft->width() - VIDEO_WIDTH) / 2,
(tft->height() - VIDEO_HEIGHT) / 2,
VIDEO_WIDTH, VIDEO_HEIGHT);
Expand Down Expand Up @@ -185,6 +186,7 @@ bool MjpegPlayDocoder::video_play_screen(void)

if (m_isUseDMA)
{
LV_LOG_USER("video_play_screen() m_isUseDMA ");
// 一帧数据大概3000B 240M主频时花费50ms 80M时需要150ms
// unsigned long Millis_1 = GET_SYS_MILLIS(); // 更新的时间
uint32_t jpg_size = readJpegFromFile(m_pFile);
Expand All @@ -198,6 +200,19 @@ bool MjpegPlayDocoder::video_play_screen(void)
}
else
{

LV_LOG_USER("video_play_screen() notUseDMA ");
// 一帧数据大概3000B 240M主频时花费50ms 80M时需要150ms
// unsigned long Millis_1 = GET_SYS_MILLIS(); // 更新的时间
uint32_t jpg_size = readJpegFromFile(m_pFile);
// Serial.println(jpg_size);
// Serial.print(GET_SYS_MILLIS() - Millis_1);
// Serial.print(" ");
// Millis_1 = GET_SYS_MILLIS();
// Draw the image, top left at 0,0 - DMA request is handled in the call-back tft_output() in this sketch
TJpgDec.drawJpg(0, 0, m_jpegBuf, jpg_size);
// Serial.println(GET_SYS_MILLIS() - Millis_1);

}
return true;
}
Expand Down
31 changes: 27 additions & 4 deletions AIO_Firmware_PIO/src/app/weather/weather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
#include <map>

#define WEATHER_APP_NAME "Weather"
#define WEATHER_NOW_API "https://www.yiketianqi.com/free/day?appid=%s&appsecret=%s&unescape=1&city=%s"
#define WEATHER_NOW_API_UPDATE "https://yiketianqi.com/api?unescape=1&version=v6&appid=%s&appsecret=%s&city=%s"
#define WEATHER_NOW_API "https://v0.yiketianqi.com/api?unescape=1&version=v6&appid=%s&appsecret=%s&city=%s"
// #define WEATHER_NOW_API_UPDATE "https://v0.yiketianqi.com/free/day?appid=%s&appsecret=%s&unescape=1&city=%s"
#define WEATHER_NOW_API_UPDATE "https://www.yiketianqi.com/free/day?appid=%s&appsecret=%s&unescape=1&city=%s"

// #define WEATHER_DALIY_API "https://v0.yiketianqi.com/free/week?unescape=1&appid=%s&appsecret=%s&city=%s"
#define WEATHER_DALIY_API "https://www.yiketianqi.com/free/week?unescape=1&appid=%s&appsecret=%s&city=%s"
#define TIME_API "http://api.m.taobao.com/rest/api3.do?api=mtop.common.gettimestamp"
#define WEATHER_PAGE_SIZE 2
Expand Down Expand Up @@ -142,6 +145,26 @@ static void get_weather(void)
// file found at server
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY)
{
// {
// "nums": 10,
// "cityid": "101180901",
// "city": "洛阳",
// "date": "2023-06-14",
// "week": "星期三",
// "update_time": "20:38",
// "wea": "晴",
// "wea_img": "qing",
// "tem": "30",
// "tem_day": "35",
// "tem_night": "22",
// "win": "南风",
// "win_speed": "1级",
// "win_meter": "3km\/h",
// "air": "119",
// "pressure": "966",
// "humidity": "25%"
// }

String payload = http.getString();
Serial.println(payload);
DynamicJsonDocument doc(1024);
Expand All @@ -158,8 +181,8 @@ static void get_weather(void)
humidity[strlen(humidity) - 1] = 0; // 去除尾部的 % 号
run_data->wea.humidity = atoi(humidity);

run_data->wea.maxTemp = sk["tem1"].as<int>();
run_data->wea.minTemp = sk["tem2"].as<int>();
run_data->wea.maxTemp = sk["tem_day"].as<int>();
run_data->wea.minTemp = sk["tem_night"].as<int>();
strcpy(run_data->wea.windDir, sk["win"].as<String>().c_str());
run_data->wea.windLevel = windLevelAnalyse(sk["win_speed"].as<String>());
run_data->wea.airQulity = airQulityLevel(sk["air"].as<int>());
Expand Down
20 changes: 15 additions & 5 deletions AIO_Firmware_PIO/src/app/weather/weather_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,34 @@ void display_curve_init(lv_scr_load_anim_t anim_type)
lv_label_set_text(titleLabel, "查看更多天气");

chart = lv_chart_create(scr_2);
lv_obj_set_size(chart, 220, 180);
lv_obj_set_size(chart, 200, 180);
lv_obj_align(chart, LV_ALIGN_CENTER, 15, 10);
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, -50, 50); // 设置进度条表示的温度为-50~50
lv_chart_set_point_count(chart, 7);
lv_chart_set_div_line_count(chart, 5, 7);
lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/

lv_obj_set_style_text_color(chart, lv_palette_lighten(LV_PALETTE_YELLOW, 2), LV_PART_TICKS);
lv_obj_set_style_line_color(chart, lv_palette_lighten(LV_PALETTE_YELLOW, 2), LV_PART_TICKS);

// 设置Y轴上刻度线的数量
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y,
10, 5, 10, 2, true, 100);

ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_SECONDARY_Y);
ser2 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_BLUE), LV_CHART_AXIS_SECONDARY_Y);
// lv_obj_set_style_pad_left(chart, 40, LV_STATE_DEFAULT);

// 设置Y轴上刻度线的数量
// lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y,
// 10, 5, 10, 2, true, 20);
// lv_chart_set_zoom_y();



// 绘制
lv_obj_align(titleLabel, LV_ALIGN_TOP_MID, 0, 10);
lv_obj_align(chart, LV_ALIGN_CENTER, 0, 10);


lv_chart_refresh(chart);


if (LV_SCR_LOAD_ANIM_NONE != anim_type)
{
Expand Down
18 changes: 15 additions & 3 deletions AIO_Firmware_PIO/src/common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#ifndef COMMON_H
#define COMMON_H

#define AIO_VERSION "2.1.6"
#define AIO_VERSION "2.1.6.3"
//修改by:神秘藏宝室


//v2.1.6.3
//修复API接口
//v2.1.6.2
//修正Weather最高和最低温度显示

//v2.1.6.1
//修复Weather的API,原来的API已废弃
//修复Weater的第二页y轴坐标显示
//默认开启性能模式【第一次烧录,或者清空重新刷固件有效】

#define GET_SYS_MILLIS xTaskGetTickCount // 获取系统毫秒数
// #define GET_SYS_MILLIS millis // 获取系统毫秒数

Expand All @@ -14,8 +27,7 @@
#include "driver/imu.h"
#include "network.h"

// RGB
#define RGB_LED_PIN 27
#include "esp_log.h"

// SD_Card
#define SD_SCK 14
Expand Down
46 changes: 23 additions & 23 deletions AIO_Firmware_PIO/src/driver/imu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ ImuAction *IMU::update(int interval)
action_info.isValid = 1;
action_info.active = ACTIVE_TYPE::TURN_RIGHT;
}
else if (action_info.v_ay > 1000 || action_info.v_ay < -1000)
{
// 震动检测
encoder_diff--;
action_info.isValid = 1;
action_info.active = ACTIVE_TYPE::SHAKE;
}
// else if (action_info.v_ay > 1000 || action_info.v_ay < -1000)
// {
// // 震动检测
// encoder_diff--;
// action_info.isValid = 1;
// action_info.active = ACTIVE_TYPE::SHAKE;
// }
else
{
action_info.isValid = 0;
Expand Down Expand Up @@ -147,12 +147,12 @@ ImuAction *IMU::update(int interval)
encoder_state = LV_INDEV_STATE_REL;
}
}
else if (action_info.v_ax > 1000 || action_info.v_ax < -1000)
{
// 震动检测
action_info.isValid = 1;
action_info.active = ACTIVE_TYPE::SHAKE;
}
// else if (action_info.v_ax > 1000 || action_info.v_ax < -1000)
// {
// // 震动检测
// action_info.isValid = 1;
// action_info.active = ACTIVE_TYPE::SHAKE;
// }
else
{
action_info.isValid = 0;
Expand Down Expand Up @@ -186,11 +186,11 @@ ImuAction *IMU::getAction(void)
{
tmp_info.active = ACTIVE_TYPE::TURN_RIGHT;
}
else if (tmp_info.v_ay > 1000 || tmp_info.v_ay < -1000)
{
// 震动检测
tmp_info.active = ACTIVE_TYPE::SHAKE;
}
// else if (tmp_info.v_ay > 1000 || tmp_info.v_ay < -1000)
// {
// // 震动检测
// tmp_info.active = ACTIVE_TYPE::SHAKE;
// }
}

if (ACTIVE_TYPE::UNKNOWN == tmp_info.active)
Expand All @@ -203,11 +203,11 @@ ImuAction *IMU::getAction(void)
{
tmp_info.active = ACTIVE_TYPE::DOWN;
}
else if (action_info.v_ax > 1000 || action_info.v_ax < -1000)
{
// 震动检测
tmp_info.active = ACTIVE_TYPE::SHAKE;
}
// else if (action_info.v_ax > 1000 || action_info.v_ax < -1000)
// {
// // 震动检测
// tmp_info.active = ACTIVE_TYPE::SHAKE;
// }
}

// 储存当前检测的动作数据到动作缓冲区中
Expand Down
1 change: 1 addition & 0 deletions AIO_Firmware_PIO/src/driver/rgb_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <esp32-hal-timer.h>

#define RGB_LED_NUM 2
#define RGB_LED_PIN 27

#define LED_MODE_RGB 0
#define LED_MODE_HSV 1
Expand Down
3 changes: 3 additions & 0 deletions AIO_Firmware_PIO/src/sys/app_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ int AppController::app_auto_start()
{
// APP自启动
int index = this->getAppIdxByName(sys_cfg.auto_start_app.c_str());
//int index = this->getAppIdxByName("Weather");
// int index = this->getAppIdxByName("WebServer");
// int index = this->getAppIdxByName("Media");
if (index < 0)
{
// 没找到相关的APP
Expand Down
2 changes: 1 addition & 1 deletion AIO_Firmware_PIO/src/sys/app_controller_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void AppController::read_config(SysUtilConfig *cfg)
if (size == 0)
{
// 默认值
cfg->power_mode = 0; // 功耗模式(0为节能模式 1为性能模式)
cfg->power_mode = 1; // 功耗模式(0为节能模式 1为性能模式)
cfg->backLight = 80; // 屏幕亮度(1-100)
cfg->rotation = 4; // 屏幕旋转方向
cfg->auto_calibration_mpu = 1; // 是否自动校准陀螺仪 0关闭自动校准 1打开自动校准
Expand Down