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

增加股票行情APP #27

Open
wants to merge 9 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
4 changes: 2 additions & 2 deletions HoloCubic_Firmware/lib/lvgl/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
#define LV_FONT_MONTSERRAT_42 0
#define LV_FONT_MONTSERRAT_44 0
#define LV_FONT_MONTSERRAT_46 0
#define LV_FONT_MONTSERRAT_48 0
#define LV_FONT_MONTSERRAT_48 1

/* Demonstrate special features */
#define LV_FONT_MONTSERRAT_12_SUBPX 0
Expand Down Expand Up @@ -531,7 +531,7 @@ typedef void * lv_font_user_data_t;
#define LV_USE_ARABIC_PERSIAN_CHARS 0

/*Change the built in (v)snprintf functions*/
#define LV_SPRINTF_CUSTOM 0
#define LV_SPRINTF_CUSTOM 1
#if LV_SPRINTF_CUSTOM
# define LV_SPRINTF_INCLUDE <stdio.h>
# define lv_snprintf snprintf
Expand Down
4 changes: 3 additions & 1 deletion HoloCubic_Firmware/src/HoloCubic_AIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "app/weather_old/weather_old.h"
#include "app/anniversary/anniversary.h"
#include "app/heartbeat/heartbeat.h"
#include "app/stockmarket/stockmarket.h"

#include <SPIFFS.h>
#include <esp32-hal.h>
Expand Down Expand Up @@ -127,6 +128,7 @@ void setup()
app_controller->app_install(&game_2048_app);
app_controller->app_install(&anniversary_app);
app_controller->app_install(&heartbeat_app, APP_TYPE_BACKGROUND);
app_controller->app_install(&stockmarket_app);

// 自启动APP
// app_controller->app_auto_start();
Expand Down Expand Up @@ -195,4 +197,4 @@ void loop()
app_controller->main_process(act_info); // 运行当前进程
// Serial.println(ambLight.getLux() / 50.0);
// rgb.setBrightness(ambLight.getLux() / 500.0);
}
}
4 changes: 3 additions & 1 deletion HoloCubic_Firmware/src/app/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void start_web_config()
server.on("/weather_setting", weather_setting);
server.on("/weather_old_setting", weather_old_setting);
server.on("/bili_setting", bili_setting);
server.on("/stock_setting", stock_setting);
server.on("/picture_setting", picture_setting);
server.on("/media_setting", media_setting);
server.on("/screen_setting", screen_setting);
Expand All @@ -54,6 +55,7 @@ void start_web_config()
server.on("/saveWeatherConf", saveWeatherConf);
server.on("/saveWeatherOldConf", saveWeatherOldConf);
server.on("/saveBiliConf", saveBiliConf);
server.on("/saveStockConf", saveStockConf);
server.on("/savePictureConf", savePictureConf);
server.on("/saveMediaConf", saveMediaConf);
server.on("/saveScreenConf", saveScreenConf);
Expand Down Expand Up @@ -181,4 +183,4 @@ static void server_message_handle(const char *from, const char *to,

APP_OBJ server_app = {SERVER_APP_NAME, &app_server, "",
server_init, server_process, server_background_task,
server_exit_callback, server_message_handle};
server_exit_callback, server_message_handle};
42 changes: 41 additions & 1 deletion HoloCubic_Firmware/src/app/server/web_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ String file_size(int bytes)
"<label class=\"input\"><span>数据更新周期(毫秒)</span><input type=\"text\"name=\"updataInterval\"value=\"%s\"></label>" \
"</label><input class=\"btn\" type=\"submit\" name=\"submit\" value=\"保存\"></form>"

#define STOCK_SETTING "<form method=\"GET\" action=\"saveStockConf\">" \
"<label class=\"input\"><span>股票代码,例如:sz000001或sh601126</span><input type=\"text\"name=\"stock_id\"value=\"%s\"></label>" \
"<label class=\"input\"><span>数据更新周期(毫秒)</span><input type=\"text\"name=\"updataInterval\"value=\"%s\"></label>" \
"</label><input class=\"btn\" type=\"submit\" name=\"submit\" value=\"保存\"></form>"

#define PICTURE_SETTING "<form method=\"GET\" action=\"savePictureConf\">" \
"<label class=\"input\"><span>自动切换时间间隔(毫秒)</span><input type=\"text\"name=\"switchInterval\"value=\"%s\"></label>" \
"</label><input class=\"btn\" type=\"submit\" name=\"submit\" value=\"保存\"></form>"
Expand Down Expand Up @@ -173,6 +178,7 @@ void init_page_header()
webpage_header += F("<li><a href='/screen_setting'>屏幕分享</a></li>");
webpage_header += F("<li><a href='/heartbeat_setting'>心跳</a></li>");
webpage_header += F("<li><a href='/anniversary_setting'>纪念日</a></li>");
webpage_header += F("<li><a href='/stock_setting'>股票行情</a></li>");
webpage_header += F("</ul>");
}

Expand Down Expand Up @@ -350,6 +356,24 @@ void bili_setting()
Send_HTML(webpage);
}


void stock_setting()
{
char buf[2048];
char bili_uid[32];
char updataInterval[32];
// 读取数据
app_controller->send_to(SERVER_APP_NAME, "Stock", APP_MESSAGE_READ_CFG,
NULL, NULL);
app_controller->send_to(SERVER_APP_NAME, "Stock", APP_MESSAGE_GET_PARAM,
(void *)"stock_id", bili_uid);
app_controller->send_to(SERVER_APP_NAME, "Stock", APP_MESSAGE_GET_PARAM,
(void *)"updataInterval", updataInterval);
sprintf(buf, STOCK_SETTING, bili_uid, updataInterval);
webpage = buf;
Send_HTML(webpage);
}

void picture_setting()
{
char buf[2048];
Expand Down Expand Up @@ -589,6 +613,22 @@ void saveBiliConf(void)
NULL, NULL);
}

void saveStockConf(void)
{
Send_HTML(F("<h1>设置成功! 退出APP或者继续其他设置.</h1>"));
app_controller->send_to(SERVER_APP_NAME, "Stock",
APP_MESSAGE_SET_PARAM,
(void *)"stock_id",
(void *)server.arg("stock_id").c_str());
app_controller->send_to(SERVER_APP_NAME, "Stock",
APP_MESSAGE_SET_PARAM,
(void *)"updataInterval",
(void *)server.arg("updataInterval").c_str());
// 持久化数据
app_controller->send_to(SERVER_APP_NAME, "Stock", APP_MESSAGE_WRITE_CFG,
NULL, NULL);
}

void savePictureConf(void)
{
Send_HTML(F("<h1>设置成功! 退出APP或者继续其他设置.</h1>"));
Expand Down Expand Up @@ -843,4 +883,4 @@ void ReportCouldNotCreateFile(const String &target)
webpage += F("<a href='/");
webpage += target + "'>[Back]</a><br><br>";
Send_HTML(webpage);
}
}
4 changes: 3 additions & 1 deletion HoloCubic_Firmware/src/app/server/web_setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void rgb_setting(void);
void weather_setting(void);
void weather_old_setting(void);
void bili_setting(void);
void stock_setting(void);
void picture_setting(void);
void media_setting(void);
void screen_setting(void);
Expand All @@ -28,6 +29,7 @@ void saveRgbConf(void);
void saveWeatherConf(void);
void saveWeatherOldConf(void);
void saveBiliConf(void);
void saveStockConf(void);
void savePictureConf(void);
void saveMediaConf(void);
void saveScreenConf(void);
Expand All @@ -40,4 +42,4 @@ void ReportSDNotPresent(void);
void ReportFileNotPresent(const String &target);
void ReportCouldNotCreateFile(const String &target);

#endif
#endif
11 changes: 11 additions & 0 deletions HoloCubic_Firmware/src/app/stockmarket/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 股票行情实时查看功能

> 作者:redwolf

> 时间:2022-10-07 12:58
> 修改:

> 功能描述:获取选择的股票的当前价格、最高价格、最低价格、今日开盘价、昨日收盘价、成交量、成交金额等

## 查看股票实时行情
http://hq.sinajs.cn/list= + uid;
Loading