mcu_ab568x/userboot240328/app/projects/AB5681G_320/functions/func_weather.c
2025-05-30 18:03:10 +08:00

91 lines
2.0 KiB
C

#include "include.h"
#include "func.h"
#if TRACE_EN
#define TRACE(...) printf(__VA_ARGS__)
#else
#define TRACE(...)
#endif
typedef struct f_weather_t_ {
} f_weather_t;
//创建天气窗体,创建窗体中不要使用功能结构体 func_cb.f_cb
compo_form_t *func_weather_form_create(void)
{
//新建窗体和背景
compo_form_t *frm = compo_form_create(true);
compo_form_add_image(frm, UI_BUF_WEATHER_SUNNY_BIN, 160, 153);
//创建文本
compo_textbox_t *txt_title = compo_textbox_create(frm, 2);
compo_textbox_set_location(txt_title, 30, 22, 80, 40);
compo_textbox_set(txt_title, "天气");
compo_textbox_t *txt = compo_textbox_create(frm, 4);
compo_textbox_set_location(txt, 105, 270, 140, 40);
compo_textbox_set(txt, "20~25°C");
compo_textbox_t *txt2 = compo_textbox_create(frm, 2);
compo_textbox_set_location(txt2, 135, 315, 80, 40);
compo_textbox_set(txt2, "晴天");
func_text_time_create(frm); //时间文本框
return frm;
}
//天气功能事件处理
static void func_weather_process(void)
{
func_process();
}
//天气功能消息处理
static void func_weather_message(size_msg_t msg)
{
switch (msg) {
case MSG_CTP_CLICK:
break;
case MSG_CTP_SHORT_UP:
break;
case MSG_CTP_SHORT_DOWN:
break;
case MSG_CTP_LONG:
break;
default:
func_message(msg);
break;
}
}
//进入天气功能
static void func_weather_enter(void)
{
func_cb.f_cb = func_zalloc(sizeof(f_weather_t));
func_cb.frm_main = func_weather_form_create();
}
//退出天气功能
static void func_weather_exit(void)
{
func_cb.last = FUNC_WEATHER;
}
//天气功能
void func_weather(void)
{
printf("%s\n", __func__);
func_weather_enter();
while (func_cb.sta == FUNC_WEATHER) {
func_weather_process();
func_weather_message(msg_dequeue());
}
func_weather_exit();
}