更新界面

This commit is contained in:
Aladdin-Wang 2020-04-28 22:36:56 +08:00
parent a8f78c13dc
commit c9841b86c8
12 changed files with 72 additions and 39 deletions

View File

@ -42,7 +42,7 @@ extern int HAL_GetDeviceSecret(char device_secret[IOTX_DEVICE_SECRET_LEN + 1]);
extern int HAL_SetDeviceSecret(char* device_secret);
extern int hum_threshold;
extern int tem_threshold;
extern int time_alarm;
extern char time_alarm[];
typedef struct
{
const char *topic_filter;
@ -182,7 +182,7 @@ static void ali_mqtt_rgb_ctrl_msg_arrive (void *pcontext, void *handle, iotx_mqt
rgb_red->valueint,rgb_green->valueint,rgb_blue->valueint,humidity->valueint,temperatyre->valueint,time->valuestring );
hum_threshold = humidity->valueint;
tem_threshold= temperatyre->valueint;
time_alarm = atoi(time->valuestring);
strncpy(time_alarm, time->valuestring,strlen(time->valuestring));
if(rgb_red->valueint){
rt_pin_write(LED_RED_PIN, PIN_LOW);
}
@ -300,7 +300,7 @@ static void mqtt_period_task()
cJSON_AddItemToObject(root, "params", js_params);
cJSON_AddNumberToObject(js_params, "humidity", sht30_device->humidity);
cJSON_AddNumberToObject(js_params, "temperature", sht30_device->temperature);
cJSON_AddNumberToObject(js_params, "airquality", rt_pin_read(MQ135_PIN));
cJSON_AddNumberToObject(js_params, "airquality", 0);
cJSON_AddStringToObject(root, "method", "thing.event.property.post");
char *msg_pub = cJSON_PrintUnformatted(root);
if (msg_pub)
@ -407,7 +407,7 @@ int ali_mqtt_init(void)
{
rt_thread_t tid;
tid = rt_thread_create("ali.main", mqtt_thread_main_thread, RT_NULL, 6 * 1024, RT_THREAD_PRIORITY_MAX / 2, 10);
tid = rt_thread_create("ali.main", mqtt_thread_main_thread, RT_NULL, 8 * 1024, RT_THREAD_PRIORITY_MAX / 2, 10);
if (tid != RT_NULL)
rt_thread_startup(tid);
return 0;

View File

@ -9,21 +9,24 @@
#include <rtthread.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <string.h>
#include <board.h>
#include <sht3x.h>
#define SAMPLE_UART_NAME "uart2"
static rt_device_t serial;
char str[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\r\n";
char str1[] = "humidity alarm!\r\n";
char str2[] = "temperature alarm!\r\n";
char str3[] = "MQ135 alarm!!\r\n";
char str[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n";
char str1[] = "ʪ<EFBFBD>ȴ<EFBFBD>\r\n";
char str2[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n";
char str3[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n";
char str4[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n";
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; /* <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD> */
extern sht3x_device_t sht3x_device;
int hum_threshold=30;
int tem_threshold=60;
int time_alarm = 0;
char time_alarm[8];
char time_setalarm[8];
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻص<DDBB><D8B5><EFBFBD><EFBFBD><EFBFBD>*/
static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
{
@ -32,9 +35,21 @@ static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
static void serial_thread_entry(void *parameter)
{
time_t now; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ĵ<EFBFBD>ǰʱ<C7B0><CAB1>ֵ */
while (1)
{
/* <20><>ȡʱ<C8A1><CAB1> */
now = time(RT_NULL);
strncpy(time_setalarm,ctime(&now)+11,5);
rt_kprintf("time_setalarm = %s\r\n",time_setalarm);
if (strcmp(time_alarm, time_setalarm) == 0)
{
/* <20><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> */
rt_device_write(serial, 0, str4, (sizeof(str4) - 1));
rt_kprintf("time alarm!\r\n");
}
if(sht3x_device->humidity > hum_threshold)
{
/* <20><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> */
@ -57,7 +72,7 @@ static void serial_thread_entry(void *parameter)
rt_kprintf("MQ135 alarm!\r\n");
}
}
rt_kprintf("hum_threshold = %d,tem_threshold=%d,time_alarm = %d\r\n",hum_threshold,tem_threshold,time_alarm);
rt_kprintf("hum_threshold = %d,tem_threshold=%d,time_alarm = %s\r\n",hum_threshold,tem_threshold,time_alarm);
rt_thread_mdelay(5000);
}
}

View File

@ -27,7 +27,7 @@ char *gfxvalue;
#define URL_LEN_MAX 2048
#define GET_LOCAL_URI "http://api.seniverse.com/v3/weather/daily.json?key=S97hL3kj6EbnjEmyC&location=%s&language=zh-Hans&unit=c&start=0&days=5"
#define LOCAL_CITY "luoyang"
#define LOCAL_CITY "tianshui"
static weather_t gfx_weather[3];
@ -84,52 +84,52 @@ static void weather_data_parse(char* data)
if((list = cJSON_GetObjectItem(item,"date")) != NULL)
{
rt_kprintf("date: %s\r\n",list->valuestring);
gfx_weather[i].date = list->valuestring;
strncpy(gfx_weather[i].date, list->valuestring,strlen(list->valuestring));
}
if((list = cJSON_GetObjectItem(item,"text_day")) != NULL)
{
rt_kprintf("text_day: %s\r\n",list->valuestring);
gfx_weather[i].text_day = list->valuestring;
strncpy(gfx_weather[i].text_day, list->valuestring,strlen(list->valuestring));
}
if((list = cJSON_GetObjectItem(item,"code_day")) != NULL)
{
rt_kprintf("code_day: %s\r\n",list->valuestring);
gfx_weather[i].code_day = list->valuestring;
strncpy(gfx_weather[i].code_day, list->valuestring,strlen(list->valuestring));
}
if((list = cJSON_GetObjectItem(item,"text_night")) != NULL)
{
rt_kprintf("text_night: %s\r\n",list->valuestring);
gfx_weather[i].text_night = list->valuestring;
strncpy(gfx_weather[i].text_night, list->valuestring,strlen(list->valuestring));
}
if((list = cJSON_GetObjectItem(item,"high")) != NULL)
{
rt_kprintf("high: %s\r\n",list->valuestring);
gfx_weather[i].high = list->valuestring;
strncpy(gfx_weather[i].high, list->valuestring,strlen(list->valuestring));
}
if((list = cJSON_GetObjectItem(item,"low")) != NULL)
{
rt_kprintf("low: %s\r\n",list->valuestring);
gfx_weather[i].low = list->valuestring;
strncpy(gfx_weather[i].low, list->valuestring,strlen(list->valuestring));
}
if((list = cJSON_GetObjectItem(item,"wind_direction")) != NULL)
{
rt_kprintf("wind_direction: %s\r\n",list->valuestring);
gfx_weather[i].wind_direction = list->valuestring;
strncpy(gfx_weather[i].wind_direction, list->valuestring,strlen(list->valuestring));
}
if((list = cJSON_GetObjectItem(item,"wind_speed")) != NULL)
{
rt_kprintf("wind_speed: %s\r\n",list->valuestring);
gfx_weather[i].wind_speed = list->valuestring;
strncpy(gfx_weather[i].wind_speed, list->valuestring,strlen(list->valuestring));
}
if((list = cJSON_GetObjectItem(item,"rainfall")) != NULL)
{
rt_kprintf("rainfall: %s\r\n",list->valuestring);
gfx_weather[i].rainfall = list->valuestring;
strncpy(gfx_weather[i].rainfall, list->valuestring,strlen(list->valuestring));
}
if((list = cJSON_GetObjectItem(item,"humidity")) != NULL)
{
rt_kprintf("humidity: %s\r\n",list->valuestring);
gfx_weather[i].humidity = list->valuestring;
strncpy(gfx_weather[i].humidity, list->valuestring,strlen(list->valuestring));
}
rt_kprintf("\n");
}

View File

@ -2,16 +2,16 @@
#define __WEATHER_H_
#include <rtthread.h>
typedef struct weather {
char *date;
char *text_day;
char *code_day;
char *text_night;
char *high;
char *low;
char *wind_direction;
char *wind_speed;
char *rainfall;
char *humidity;
char date[8];
char text_day[8];
char code_day[8];
char text_night[8];
char high[8];
char low[8];
char wind_direction[8];
char wind_speed[8];
char rainfall[8];
char humidity[8];
} weather_t;

View File

@ -20,6 +20,7 @@ public:
mainViewBase();
virtual ~mainViewBase() {}
virtual void setupScreen();
virtual void handleKeyEvent(uint8_t key);
protected:
FrontendApplication& application() {

View File

@ -199,3 +199,20 @@ void mainViewBase::setupScreen()
{
}
//Handles when a key is pressed
void mainViewBase::handleKeyEvent(uint8_t key)
{
if(0 == key)
{
//Interaction1
//When hardware button 0 clicked change screen to Screensaver
//Go to Screensaver with no screen transition
application().gotoScreensaverScreenNoTransition();
//Interaction2
//When hardware button 0 clicked change screen to set
//Go to set with screen transition towards East
application().gotosetScreenSlideTransitionEast();
}
}

View File

@ -1 +1 @@
{"remap":"yes","languages":["Gb"],"characters":[2,47,2,8451,0,48,48,48,48,45,48,48,45,48,48,0,2,37,0,2,0,22478,24066,58,27931,38451,0,48,48,46,48,32,0,48,48,46,48,0,28287,24230,38408,20540,0,28201,24230,38408,20540,0,48,48,48,0,83,117,110,0,21518,22825,0,40644,28783,0,32418,28783,0,32511,28783,0,26126,22825,0,20170,22825,0,20248,0]}
{"remap":"yes","languages":["Gb"],"characters":[2,47,2,8451,0,48,48,48,48,45,48,48,45,48,48,0,2,37,0,2,0,22478,24066,58,22825,27700,0,48,48,46,48,32,0,48,48,46,48,0,28287,24230,38408,20540,0,28201,24230,38408,20540,0,48,48,48,0,83,117,110,0,21518,22825,0,40644,28783,0,32418,28783,0,32511,28783,0,26126,22825,0,20170,22825,0,20248,0]}

View File

@ -24,7 +24,7 @@ KEEP extern const touchgfx::Unicode::UnicodeChar texts_all_languages[] TEXT_LOCA
0x30, 0x30, 0x30, 0x30, 0x2d, 0x30, 0x30, 0x2d, 0x30, 0x30, 0x0, // @5 "0000-00-00"
0x2, 0x25, 0x0, // @16 "<>%"
0x2, 0x0, // @19 "<>"
0x57ce, 0x5e02, 0x3a, 0x6d1b, 0x9633, 0x0, // @21 "??:??"
0x57ce, 0x5e02, 0x3a, 0x5929, 0x6c34, 0x0, // @21 "??:??"
0x30, 0x30, 0x2e, 0x30, 0x20, 0x0, // @27 "00.0 "
0x30, 0x30, 0x2e, 0x30, 0x0, // @33 "00.0"
0x6e7f, 0x5ea6, 0x9608, 0x503c, 0x0, // @38 "????"

View File

@ -459,7 +459,7 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\applications\uart_Alarm.c</PathWithFileName>
<PathWithFileName>applications\uart_Alarm.c</PathWithFileName>
<FilenameWithoutPath>uart_Alarm.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
@ -468,7 +468,7 @@
<Group>
<GroupName>Drivers</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -620,7 +620,7 @@
<Group>
<GroupName>TouchGFX_app</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

View File

@ -495,7 +495,7 @@
<File>
<FileName>uart_Alarm.c</FileName>
<FileType>1</FileType>
<FilePath>.\applications\uart_Alarm.c</FilePath>
<FilePath>applications\uart_Alarm.c</FilePath>
</File>
</Files>
</Group>

View File

@ -195,8 +195,8 @@
#define AT_DEVICE_USING_ESP8266
#define AT_DEVICE_ESP8266_INIT_ASYN
#define AT_DEVICE_ESP8266_SAMPLE
#define ESP8266_SAMPLE_WIFI_SSID "xgld1"
#define ESP8266_SAMPLE_WIFI_PASSWORD "xgld64627816"
#define ESP8266_SAMPLE_WIFI_SSID "ChinaNet-ssssss"
#define ESP8266_SAMPLE_WIFI_PASSWORD "SQHWLK9394"
#define ESP8266_SAMPLE_CLIENT_NAME "uart3"
#define ESP8266_SAMPLE_RECV_BUFF_LEN 512
#define PKG_USING_AT_DEVICE_LATEST_VERSION