接着上一次,这一次提交完成的有:
数据的断电保存
上电时数据的加载以及刷新
至此,余留的任务有:
方向控制
app
This commit is contained in:
parent
69b9efac27
commit
73d440be4d
13 changed files with 1851 additions and 1791 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -9,7 +9,7 @@ TriggerName=main
|
|||
LimitSize=0
|
||||
ByteLimit=50
|
||||
[DebugChecksum]
|
||||
Checksum=-2094893241
|
||||
Checksum=828444786
|
||||
[CodeCoverage]
|
||||
Enabled=_ 0
|
||||
[Exceptions]
|
||||
|
|
@ -54,9 +54,11 @@ ShowSource=1
|
|||
[Disassemble mode]
|
||||
mode=0
|
||||
[Breakpoints2]
|
||||
Bp0=_ 1 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\tft.c}.878.9" 0 0 1 "" 0 "" 0
|
||||
Bp1=_ 0 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\tft.c}.897.14" 0 0 1 "" 0 "" 0
|
||||
Count=2
|
||||
Bp0=_ 0 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\tft.c}.883.5" 0 0 1 "" 0 "" 0
|
||||
Bp1=_ 1 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\tft.c}.542.9" 0 0 1 "" 0 "" 0
|
||||
Bp2=_ 0 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\pm_flash.c}.95.5" 0 0 1 "" 0 "" 0
|
||||
Bp3=_ 0 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\plan_handle.c}.55.5" 0 0 1 "" 0 "" 0
|
||||
Count=4
|
||||
[Log file]
|
||||
LoggingEnabled=_ 0
|
||||
LogFile=_ ""
|
||||
|
|
|
|||
|
|
@ -11,3 +11,4 @@ void plan_handle_init(void);
|
|||
|
||||
void plan_handle(void);
|
||||
|
||||
void tft_to_plan_input(uint8_t objn);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#ifndef TFT_H
|
||||
#define TFT_H
|
||||
|
||||
enum { PLAN_DATA_NUM = 19 };
|
||||
|
||||
typedef struct input_limit_
|
||||
{
|
||||
|
|
@ -38,7 +37,6 @@ input_limit tft_input_limit(char *name);
|
|||
|
||||
//const kv_pair *get_plan_data(uint8_t objn)[][PLAN_DATA_NUM];
|
||||
|
||||
void tft_to_plan_input(uint8_t objn);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
36
plan_manage_main/src/app/include/tft_plan_internal.h
Normal file
36
plan_manage_main/src/app/include/tft_plan_internal.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* tft_handle_internal.h - tft和plan_handle模块共同使用部分的内部声明
|
||||
*
|
||||
* 这个文件只应包含在tft和plan_handle模块
|
||||
*/
|
||||
|
||||
#include "include/pm_time.h"
|
||||
|
||||
|
||||
typedef struct plan_input_
|
||||
{
|
||||
calendar_info bg_t;
|
||||
calendar_info ed_t;
|
||||
calendar_info pd_t;
|
||||
|
||||
uint8_t x_orient;
|
||||
uint8_t y_orient;
|
||||
uint8_t lg_r : 1;
|
||||
uint8_t lg_b : 1;
|
||||
uint8_t lg_uvb : 1;
|
||||
uint8_t water : 1;
|
||||
uint8_t sw : 1;
|
||||
} plan_input;
|
||||
|
||||
typedef struct kv_pair_
|
||||
{
|
||||
char *key;
|
||||
int16_t value;
|
||||
int8_t attr;
|
||||
} kv_pair;
|
||||
|
||||
enum { PLAN_DATA_NUM = 19 };
|
||||
|
||||
extern plan_input plan_in[PLAN_DATA_NUM];
|
||||
|
||||
extern kv_pair kvp_obj_set[][PLAN_DATA_NUM];
|
||||
|
|
@ -19,6 +19,8 @@
|
|||
void main(void)
|
||||
{
|
||||
|
||||
printf("\n\n\n程序开始执行!!!\n\n\n");
|
||||
|
||||
pm_init();
|
||||
|
||||
st_init(0, COMPARE, 10); // 作为按键扫描函数的定时使用,在simulat_timer.c的底层中使用
|
||||
|
|
@ -29,6 +31,7 @@ void main(void)
|
|||
|
||||
knob_enable();
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@
|
|||
|
||||
#include "gpio.h"
|
||||
|
||||
#include "include/tft_plan_internal.h"
|
||||
|
||||
#include "include/plan_handle.h"
|
||||
#include "include/pm_time.h"
|
||||
#include "include/tft.h"
|
||||
#include "config.h"
|
||||
#include "include/config.h"
|
||||
#include "include/pm_flash.h"
|
||||
|
||||
typedef struct plan_output_
|
||||
{
|
||||
|
|
@ -28,24 +30,10 @@ typedef struct plan_output_
|
|||
uint8_t cnt;
|
||||
} plan_output;
|
||||
|
||||
typedef struct plan_input_
|
||||
{
|
||||
calendar_info bg_t;
|
||||
calendar_info ed_t;
|
||||
calendar_info pd_t;
|
||||
|
||||
uint8_t x_orient;
|
||||
uint8_t y_orient;
|
||||
uint8_t lg_r : 1;
|
||||
uint8_t lg_b : 1;
|
||||
uint8_t lg_uvb : 1;
|
||||
uint8_t water : 1;
|
||||
uint8_t sw : 1;
|
||||
} plan_input;
|
||||
|
||||
static void indata_to_outdata(plan_input *ind, plan_output *outd);
|
||||
static void ctr_exe(uint8_t activity);
|
||||
|
||||
static void plan_inpu_to_tft(void);
|
||||
|
||||
static plan_output plan_out[PLAN_DATA_NUM] = { 0 };
|
||||
plan_input plan_in[PLAN_DATA_NUM] = { 0 };
|
||||
|
|
@ -59,6 +47,13 @@ void plan_handle_init(void)
|
|||
gpio_Interrupt_init(LGUVB_PINX, GPO, GPI_DISAB);
|
||||
gpio_Interrupt_init(WATER_PINX, GPO, GPI_DISAB);
|
||||
// 还有设置方向的初始化
|
||||
|
||||
/*
|
||||
* 数据恢复,数据从从flash到plan_handle模块,再从plan_handle模块到tft模块
|
||||
*/
|
||||
flash_read((uint8_t *)&plan_in, sizeof(plan_in));
|
||||
plan_inpu_to_tft();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -130,3 +125,79 @@ void plan_handle(void)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* tft_to_plan_input() - 将tft显示的数据提取到计划处理的输入数据结构中
|
||||
* @objn: 提取的对象号,0~7
|
||||
*
|
||||
* 这个函数应该在tft输入有改变是被调用。
|
||||
*/
|
||||
void tft_to_plan_input(uint8_t objn)
|
||||
{
|
||||
plan_in[objn].bg_t.year = *get_value_of_kvp("bg_y", objn);
|
||||
plan_in[objn].bg_t.month = *get_value_of_kvp("bg_mo", objn);
|
||||
plan_in[objn].bg_t.mday = *get_value_of_kvp("bg_d", objn);
|
||||
plan_in[objn].bg_t.hour = *get_value_of_kvp("bg_h", objn);
|
||||
plan_in[objn].bg_t.min = *get_value_of_kvp("bg_mi", objn);
|
||||
|
||||
/*
|
||||
* 结束时间在tft条目没有年、月、日,赋值为何开始时间相同
|
||||
*/
|
||||
plan_in[objn].ed_t.year = plan_in[objn].bg_t.year;
|
||||
plan_in[objn].ed_t.month = plan_in[objn].bg_t.month;
|
||||
plan_in[objn].ed_t.mday = plan_in[objn].bg_t.mday;
|
||||
plan_in[objn].ed_t.hour = *get_value_of_kvp("ed_h", objn);
|
||||
plan_in[objn].ed_t.min = *get_value_of_kvp("ed_mi", objn);
|
||||
|
||||
plan_in[objn].pd_t.mday = *get_value_of_kvp("pd_d", objn);
|
||||
plan_in[objn].pd_t.hour = *get_value_of_kvp("pd_h", objn);
|
||||
plan_in[objn].pd_t.min = *get_value_of_kvp("pd_mi", objn);
|
||||
|
||||
plan_in[objn].lg_r = *get_value_of_kvp("lg_r", objn);
|
||||
plan_in[objn].lg_b = *get_value_of_kvp("lg_b)", objn);
|
||||
plan_in[objn].lg_uvb = *get_value_of_kvp("lg_uvb", objn);
|
||||
plan_in[objn].water = *get_value_of_kvp("water", objn);
|
||||
|
||||
plan_in[objn].sw = *get_value_of_kvp("sw", objn);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* plan_inpu_to_tft() - 计划数据到tft
|
||||
*
|
||||
* 这个函数是为了在初始化时将从flash中恢复的计划数据重新装入tft
|
||||
*/
|
||||
static void plan_inpu_to_tft(void)
|
||||
{
|
||||
for(uint8_t objn = 0; objn < 8; objn++)
|
||||
{
|
||||
*get_value_of_kvp("bg_y", objn) = plan_in[objn].bg_t.year;
|
||||
*get_value_of_kvp("bg_mo", objn) = plan_in[objn].bg_t.month;
|
||||
*get_value_of_kvp("bg_d", objn) = plan_in[objn].bg_t.mday;
|
||||
*get_value_of_kvp("bg_h", objn) = plan_in[objn].bg_t.hour;
|
||||
*get_value_of_kvp("bg_mi", objn) = plan_in[objn].bg_t.min;
|
||||
|
||||
/*
|
||||
* 结束时间在tft条目没有年、月、日
|
||||
* *get_value_of_kvp("ed_y", objn) = plan_in[objn].ed_t.year;
|
||||
* *get_value_of_kvp("ed_mo", objn) = plan_in[objn].ed_t.month;
|
||||
* *get_value_of_kvp("ed_d", objn) = plan_in[objn].ed_t.mday;
|
||||
*/
|
||||
*get_value_of_kvp("ed_h", objn) = plan_in[objn].ed_t.hour;
|
||||
*get_value_of_kvp("ed_mi", objn) = plan_in[objn].ed_t.min;
|
||||
|
||||
*get_value_of_kvp("pd_d", objn) = plan_in[objn].pd_t.mday;
|
||||
*get_value_of_kvp("pd_h", objn) = plan_in[objn].pd_t.hour;
|
||||
*get_value_of_kvp("pd_mi", objn) = plan_in[objn].pd_t.min;
|
||||
|
||||
*get_value_of_kvp("lg_r", objn) = plan_in[objn].lg_r;
|
||||
*get_value_of_kvp("lg_b", objn) = plan_in[objn].lg_b;
|
||||
*get_value_of_kvp("lg_uvb", objn) = plan_in[objn].lg_uvb;
|
||||
*get_value_of_kvp("water", objn) = plan_in[objn].water;
|
||||
|
||||
*get_value_of_kvp("sw", objn) = plan_in[objn].sw;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void pm_flash_init(void)
|
|||
/*
|
||||
* flash_write() - 将数据写入flash
|
||||
* @saddr: 要写入的数据的起始地址
|
||||
* @size: 写入数据的字节数
|
||||
* @size: 写入数据的字节数,字节数必须要以4对齐!!!
|
||||
*
|
||||
* 这个函数的执行过程包括擦除和写入,默认的写入范围为flash的最后一个扇区,大小为
|
||||
* 1KB,如果要改变大小,改参数就可以了,注意不要覆盖了code,具体可看map文件。
|
||||
|
|
@ -107,7 +107,7 @@ void flash_write(uint8_t *saddr, uint16_t nbyte)
|
|||
|
||||
/* 校验和检验 */
|
||||
uint32_t sum = temp = 0x0U;
|
||||
for (uint8_t i = 0x0U; i < nbyte; i++)
|
||||
for (uint16_t i = 0x0U; i < nbyte; i++)
|
||||
{
|
||||
temp += saddr[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
void pm_init(void)
|
||||
{
|
||||
pm_flash_init();
|
||||
debug_init();
|
||||
key_init();
|
||||
knob_init();
|
||||
st_base_init();
|
||||
tft_init();
|
||||
ds1302_init();
|
||||
plan_handle_init();
|
||||
pm_flash_init();
|
||||
plan_handle_init(); // 计划处理初始化必须在flash初始化之后
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,34 +14,13 @@
|
|||
#include "include/knob.h"
|
||||
#include "include/key.h"
|
||||
#include "include/config.h"
|
||||
#include "include/pm_time.h"
|
||||
#include "include/plan_handle.h"
|
||||
|
||||
typedef struct plan_input_
|
||||
{
|
||||
calendar_info bg_t;
|
||||
calendar_info ed_t;
|
||||
calendar_info pd_t;
|
||||
|
||||
uint8_t x_orient;
|
||||
uint8_t y_orient;
|
||||
uint8_t lg_r : 1;
|
||||
uint8_t lg_b : 1;
|
||||
uint8_t lg_uvb : 1;
|
||||
uint8_t water : 1;
|
||||
uint8_t sw : 1;
|
||||
} plan_input;
|
||||
#include "include/tft_plan_internal.h"
|
||||
#include "include/pm_flash.h"
|
||||
|
||||
|
||||
extern plan_input plan_in[PLAN_DATA_NUM];
|
||||
|
||||
|
||||
typedef struct kv_pair_
|
||||
{
|
||||
char *key;
|
||||
int16_t value;
|
||||
int8_t attr;
|
||||
} kv_pair;
|
||||
|
||||
typedef struct tft_state_
|
||||
{
|
||||
|
|
@ -91,7 +70,7 @@ static kv_pair kvp_menu[] = {
|
|||
{ "note", 0, R_TXT }
|
||||
};
|
||||
|
||||
static kv_pair kvp_obj_set[][PLAN_DATA_NUM] =
|
||||
kv_pair kvp_obj_set[][PLAN_DATA_NUM] =
|
||||
{
|
||||
{
|
||||
{ "ob", 1, R_NUM}, { "sw", 1, RW_PIC },// 0~1
|
||||
|
|
@ -536,14 +515,6 @@ void refrush_obj(void)
|
|||
return;
|
||||
}
|
||||
|
||||
void refrush_menu(void)
|
||||
{
|
||||
for (int i = 0; i < sizeof(kvp_obj_set[tft_stt.objn]) / sizeof(kv_pair); i++)
|
||||
{
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void tft_ret(void)
|
||||
{
|
||||
|
|
@ -565,8 +536,12 @@ void tft_ret(void)
|
|||
tft_stt.etn = 0;
|
||||
tft_send_cmd("page menu");
|
||||
tft_page_refresh();
|
||||
|
||||
sw_to_obj();
|
||||
// refrush_menu();
|
||||
tft_to_plan_input(tft_stt.objn);
|
||||
enter_critical();
|
||||
flash_write((uint8_t *)plan_in, sizeof(plan_in));
|
||||
exit_critical();
|
||||
tft_set_color(tft_stt.etn, TFT_PURPLE);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -580,6 +555,7 @@ static void tft_input(void)
|
|||
{
|
||||
input_limit in_lmt;
|
||||
int16_t in_v, bg_v;
|
||||
|
||||
switch (tft_stt.pgn)
|
||||
{
|
||||
case ORIGINAL_PG:
|
||||
|
|
@ -686,7 +662,6 @@ static void tft_input(void)
|
|||
}
|
||||
knob_disable();
|
||||
tft_set_color(tft_stt.etn, TFT_PURPLE);
|
||||
//tft_to_plan_input(tft_stt.objn);
|
||||
clear_key_m();
|
||||
break;
|
||||
case RW_PIC:
|
||||
|
|
@ -705,7 +680,6 @@ static void tft_input(void)
|
|||
}
|
||||
}
|
||||
tft_set_color(tft_stt.etn, TFT_PURPLE);
|
||||
tft_to_plan_input(tft_stt.objn);
|
||||
clear_key_m();
|
||||
break;
|
||||
case SW_PAGE:
|
||||
|
|
@ -1017,38 +991,7 @@ uint8_t get_obj_num(void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* 将tft显示的数据提取到计划处理的输入数据结构中,这个函数应该在tft输入有改变是被调
|
||||
* 用。
|
||||
*/
|
||||
void tft_to_plan_input(uint8_t objn)
|
||||
{
|
||||
plan_in[objn].bg_t.year = *get_value_of_kvp("bg_y", objn);
|
||||
plan_in[objn].bg_t.month = *get_value_of_kvp("bg_mo", objn);
|
||||
plan_in[objn].bg_t.mday = *get_value_of_kvp("bg_d", objn);
|
||||
plan_in[objn].bg_t.hour = *get_value_of_kvp("bg_h", objn);
|
||||
plan_in[objn].bg_t.min = *get_value_of_kvp("bg_mi", objn);
|
||||
//plan_in[objn].bg_t.sec = *get_value_kvp("bg_s", objn);
|
||||
|
||||
plan_in[objn].ed_t.year = *get_value_of_kvp("ed_y", objn);
|
||||
plan_in[objn].ed_t.month = *get_value_of_kvp("ed_mo", objn);
|
||||
plan_in[objn].ed_t.mday = *get_value_of_kvp("ed_d", objn);
|
||||
plan_in[objn].ed_t.hour = *get_value_of_kvp("ed_h", objn);
|
||||
plan_in[objn].ed_t.min = *get_value_of_kvp("ed_mi", objn);
|
||||
//plan_in[objn].ed_t.sec = *get_value_of_kvp("ed_s", objn);
|
||||
|
||||
plan_in[objn].pd_t.mday = *get_value_of_kvp("pd_d", objn);
|
||||
plan_in[objn].pd_t.hour = *get_value_of_kvp("pd_h", objn);
|
||||
plan_in[objn].pd_t.min = *get_value_of_kvp("pd_mi", objn);
|
||||
|
||||
plan_in[objn].lg_r = *get_value_of_kvp("lg_r", objn);
|
||||
plan_in[objn].lg_b = *get_value_of_kvp("lg_b)", objn);
|
||||
plan_in[objn].lg_uvb = *get_value_of_kvp("lg_uvb", objn);
|
||||
plan_in[objn].water = *get_value_of_kvp("water", objn);
|
||||
|
||||
plan_in[objn].sw = *get_value_of_kvp("sw", objn);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1,2 @@
|
|||
[MainWindow]
|
||||
WindowPlacement=_ 129 165 1154 691 3
|
||||
WindowPlacement=_ 1686 219 2711 745 3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue