解决了一些bug,添加完善了程序注释
This commit is contained in:
parent
fe11958be3
commit
bd1902939a
23 changed files with 7250 additions and 7073 deletions
|
|
@ -1,58 +1,40 @@
|
|||
/* key.h - 监测并采集按键的输入
|
||||
* 共有四种输入,无键,单击,双击,长击。
|
||||
* 使用一个定时器每10ms采集一次io状态来实现的。
|
||||
*/
|
||||
|
||||
#ifndef KEY_H
|
||||
#define KEY_H
|
||||
|
||||
|
||||
typedef enum key_mean_
|
||||
{
|
||||
N_KEY = 0, S_KEY, D_KEY, L_KEY
|
||||
} key_mean;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* key_type - 按键的种类
|
||||
*/
|
||||
typedef enum key_type_
|
||||
{
|
||||
UP_KEY = 0, DOWN_KEY, OK_KEY, RET_KEY, AMS_KEY, WIFI_KEY, MR_KEY, MB_KEY, MUVB_KEY
|
||||
} key_type;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* key_init() - 按键模块初始化
|
||||
*
|
||||
*/
|
||||
void key_init(void);
|
||||
|
||||
|
||||
/*
|
||||
* key_detect() - 检测按键
|
||||
*
|
||||
* 要求每隔10ms调用一次
|
||||
*/
|
||||
void key_detect(void);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* get_key_mean() - 得到指定的按键信息
|
||||
*
|
||||
* 这个函数中在取得信息后会将对应按键重新标记为N_KEY
|
||||
*/
|
||||
key_mean get_key_mean(key_type key_t);
|
||||
|
||||
|
||||
|
||||
|
||||
void clear_key_m(void);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // KEY_H
|
||||
/* key.h - 监测并采集按键的输入
|
||||
* 共有四种输入,无键,单击,双击,长击。
|
||||
* 使用一个定时器每10ms采集一次io状态来实现的。
|
||||
*/
|
||||
|
||||
#ifndef KEY_H
|
||||
#define KEY_H
|
||||
|
||||
|
||||
/*
|
||||
* key_mean - 按键的状态标志符号
|
||||
* N_KEY表示无键按下状态,S_KEY表示单击,D_KEY表示双击,L_KEY表示长按
|
||||
*/
|
||||
typedef enum key_mean_
|
||||
{
|
||||
N_KEY = 0, S_KEY, D_KEY, L_KEY
|
||||
} key_mean;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* key_type - 按键的种类
|
||||
*/
|
||||
typedef enum key_type_
|
||||
{
|
||||
UP_KEY = 0, DOWN_KEY, OK_KEY, RET_KEY, AMS_KEY, WIFI_KEY, MR_KEY, MB_KEY, MUVB_KEY
|
||||
} key_type;
|
||||
|
||||
|
||||
|
||||
|
||||
void key_init(void);
|
||||
void key_detect(void);
|
||||
key_mean get_key_mean(key_type key_t);
|
||||
void clear_key_m(void);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // KEY_H
|
||||
|
|
|
|||
|
|
@ -1,56 +1,29 @@
|
|||
/*
|
||||
* knob.h - 提供旋钮输入的接口函数
|
||||
*
|
||||
* 使用的是一个数字旋钮,利用计数来采集输入
|
||||
*/
|
||||
|
||||
#ifndef KNOB_H
|
||||
#define KNOB_H
|
||||
|
||||
#include "arm_cm0.h"
|
||||
#include "vectors.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* knob_init() - 为旋钮输入而执行的初始化
|
||||
*
|
||||
* 旋钮的检测初始化后默认是禁止的
|
||||
*/
|
||||
void knob_init(void);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* knob_enable() - 使能旋钮脉冲检测
|
||||
*/
|
||||
void knob_enable(void);
|
||||
|
||||
|
||||
/*
|
||||
* knob_disable() - 禁止旋钮脉冲检测
|
||||
*/
|
||||
void knob_disable(void);
|
||||
|
||||
|
||||
/*
|
||||
* knob_clear() - 清除旋钮值
|
||||
*/
|
||||
void knob_clear(void);
|
||||
|
||||
/*
|
||||
* get_knob_val() - 返回旋钮值
|
||||
*/
|
||||
int32_t get_knob_val(void);
|
||||
|
||||
|
||||
/*
|
||||
* knob_detect() - 旋钮检测
|
||||
*
|
||||
* 这个函数需要在旋钮编码器的A相输出发生沿跳变时调用,即上下沿中断时
|
||||
*/
|
||||
void knob_detect(void);
|
||||
|
||||
|
||||
#endif /* KNOB_H */
|
||||
/*
|
||||
* knob.h - 提供旋钮输入的接口函数
|
||||
*
|
||||
* 使用的是一个数字旋钮,利用计数来采集输入
|
||||
*/
|
||||
|
||||
#ifndef KNOB_H
|
||||
#define KNOB_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void knob_init(void);
|
||||
|
||||
|
||||
void knob_enable(void);
|
||||
|
||||
void knob_disable(void);
|
||||
|
||||
void knob_clear(void);
|
||||
|
||||
int32_t get_knob_val(void);
|
||||
|
||||
void knob_detect(void);
|
||||
|
||||
|
||||
#endif /* KNOB_H */
|
||||
|
|
|
|||
|
|
@ -1,38 +1,34 @@
|
|||
/*
|
||||
* time.h - 时间处理
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
typedef struct calendar_info_
|
||||
{
|
||||
uint8_t sec;
|
||||
uint8_t min;
|
||||
uint8_t hour;
|
||||
uint8_t mday;
|
||||
uint8_t month;
|
||||
uint16_t year;
|
||||
uint8_t wday;
|
||||
uint16_t yday;
|
||||
} calendar_info;
|
||||
|
||||
enum { START_YEAR = 2000, SEC_IN_DAY = 24 * 60 * 60};
|
||||
|
||||
uint8_t is_leapyear(uint16_t year);
|
||||
|
||||
uint8_t get_month_days(uint16_t year, uint8_t month);
|
||||
|
||||
void ds1302_init(void);
|
||||
|
||||
void ds1302_set_time(calendar_info *cal);
|
||||
|
||||
void ds1302_read_time(calendar_info *cal);
|
||||
|
||||
void maintain_system_time(void);
|
||||
|
||||
calendar_info get_system_time(void);
|
||||
|
||||
uint32_t calendar_to_sec(calendar_info *cal);
|
||||
|
||||
calendar_info sec_to_calendar(uint32_t sec);
|
||||
/*
|
||||
* time.h - 时间处理
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/*
|
||||
* calendar_info - 分解时间
|
||||
*/
|
||||
typedef struct calendar_info_
|
||||
{
|
||||
uint8_t sec;
|
||||
uint8_t min;
|
||||
uint8_t hour;
|
||||
uint8_t mday;
|
||||
uint8_t month;
|
||||
uint16_t year;
|
||||
uint8_t wday;
|
||||
uint16_t yday;
|
||||
} calendar_info;
|
||||
|
||||
// START_YEAR为计算日历时间时的起始时间
|
||||
enum { START_YEAR = 2000, SEC_IN_DAY = 24 * 60 * 60};
|
||||
|
||||
uint8_t is_leapyear(uint16_t year);
|
||||
uint8_t get_month_days(uint16_t year, uint8_t month);
|
||||
void ds1302_init(void);
|
||||
void ds1302_set_time(calendar_info *cal);
|
||||
void ds1302_read_time(calendar_info *cal);
|
||||
void maintain_system_time(void);
|
||||
calendar_info get_system_time(void);
|
||||
uint32_t calendar_to_sec(calendar_info *cal);
|
||||
calendar_info sec_to_calendar(uint32_t sec);
|
||||
|
|
|
|||
|
|
@ -1,107 +1,52 @@
|
|||
/*
|
||||
* simulat_timer.h - 实现一个模拟定时器
|
||||
*/
|
||||
|
||||
#ifndef SIMULAT_TIMER_H
|
||||
#define SIMULAT_TIMER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* 模拟定时器的数量
|
||||
*/
|
||||
#define SIMULAT_TIMER_NUM 5
|
||||
|
||||
|
||||
|
||||
typedef struct st_register_
|
||||
{
|
||||
uint32_t count; // 定时器计数
|
||||
uint32_t cmr; // 比较寄存器
|
||||
struct
|
||||
{
|
||||
uint8_t ten : 1; // 使能标志
|
||||
uint8_t tov : 1; // 溢出标志
|
||||
uint8_t tfc : 1; // 自由运行标志
|
||||
uint8_t tcf : 1; // 比较标志
|
||||
} flag;
|
||||
} st_register;
|
||||
|
||||
|
||||
typedef enum st_mode_
|
||||
{
|
||||
COMPARE = 0,
|
||||
NO_COMPARE
|
||||
} st_mode;
|
||||
|
||||
/*
|
||||
* st_init() - 初始化实现模拟定时器所需的pit定时器
|
||||
*
|
||||
* 基础定时为1ms
|
||||
*/
|
||||
void st_base_init(void);
|
||||
|
||||
|
||||
/*
|
||||
* st_init() - 初始化一个给定编号的模拟定时器
|
||||
* @n: 定时器编号
|
||||
* @st_m: 定时模式
|
||||
* @cmr_v: 定时器比较值,在非比较模式可以为任意值
|
||||
*
|
||||
* 这个函数返回0表示正常完成了初始化任务,返回~0表示定时器已打开或不存在
|
||||
*/
|
||||
uint8_t st_init(uint8_t n, st_mode st_m, uint32_t cmr_v);
|
||||
|
||||
|
||||
/*
|
||||
* st_close() - 关闭一个给定编号的模拟定时器
|
||||
* @n: 定时器编号
|
||||
*/
|
||||
void st_close(uint8_t n);
|
||||
|
||||
/*
|
||||
* st_tcf() - 查询tcf位返回
|
||||
* @n: 定时器编号
|
||||
*
|
||||
* 这个函数在没有过比较值的时候返回0,已过比较值得时候返回1,对于不存在或未打开
|
||||
*/
|
||||
uint8_t st_tcf(uint8_t n);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* st_tov() - 查询tov位返回
|
||||
* @n: 定时器编号
|
||||
*
|
||||
* 这个函数在没有溢出时返回0,没有溢出时返回1,对于不存在或未打开
|
||||
*/
|
||||
uint8_t st_tov(uint8_t n);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* st_count() - 查询当前模拟定时值
|
||||
* @n: 定时器编号
|
||||
*
|
||||
* 对于不存在或未打开
|
||||
*/
|
||||
uint32_t st_count(uint8_t n);
|
||||
|
||||
|
||||
|
||||
/********************ISR******************/
|
||||
|
||||
/*
|
||||
* st_base() -定时调用以模拟N路定时器
|
||||
*
|
||||
* 定时的最小间隔等于这个函数被调用的周期
|
||||
*/
|
||||
void st_base(void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* SIMULAT_TIMER_H */
|
||||
/*
|
||||
* simulat_timer.h - 实现一个模拟定时器
|
||||
*/
|
||||
|
||||
#ifndef SIMULAT_TIMER_H
|
||||
#define SIMULAT_TIMER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* 模拟定时器的数量
|
||||
*/
|
||||
#define SIMULAT_TIMER_NUM 5
|
||||
|
||||
|
||||
|
||||
typedef struct st_register_
|
||||
{
|
||||
uint32_t count; // 定时器计数
|
||||
uint32_t cmr; // 比较寄存器
|
||||
struct
|
||||
{
|
||||
uint8_t ten : 1; // 使能标志
|
||||
uint8_t tov : 1; // 溢出标志
|
||||
uint8_t tfc : 1; // 自由运行标志
|
||||
uint8_t tcf : 1; // 比较标志
|
||||
} flag;
|
||||
} st_register;
|
||||
|
||||
|
||||
typedef enum st_mode_
|
||||
{
|
||||
COMPARE = 0,
|
||||
NO_COMPARE
|
||||
} st_mode;
|
||||
|
||||
|
||||
void st_base_init(void);
|
||||
uint8_t st_init(uint8_t n, st_mode st_m, uint32_t cmr_v);
|
||||
void st_close(uint8_t n);
|
||||
uint8_t st_tcf(uint8_t n);
|
||||
uint8_t st_tov(uint8_t n);
|
||||
uint32_t st_count(uint8_t n);
|
||||
void st_base(void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* SIMULAT_TIMER_H */
|
||||
|
|
|
|||
|
|
@ -1,43 +1,42 @@
|
|||
/*
|
||||
* tft.h - tft½Ó¿Ú
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TFT_H
|
||||
#define TFT_H
|
||||
|
||||
|
||||
typedef struct input_limit_
|
||||
{
|
||||
int16_t max;
|
||||
int16_t min;
|
||||
} input_limit;
|
||||
|
||||
void tft_init(void);
|
||||
|
||||
void tft_send_cmd(const char *cmd);
|
||||
|
||||
void tft_left(void);
|
||||
|
||||
void tft_right(void);
|
||||
|
||||
void tft_up(void);
|
||||
|
||||
void tft_down(void);
|
||||
|
||||
void tft_ok(void);
|
||||
|
||||
void tft_ret(void);
|
||||
|
||||
void tft_page_refresh(void);
|
||||
|
||||
int16_t *get_value_of_kvp(char *name, uint8_t objn);
|
||||
|
||||
input_limit tft_input_limit(char *name);
|
||||
|
||||
//const kv_pair *get_plan_data(uint8_t objn)[][PLAN_DATA_NUM];
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* TFT_H */
|
||||
/*
|
||||
* tft.h - tft½Ó¿Ú
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TFT_H
|
||||
#define TFT_H
|
||||
|
||||
|
||||
typedef struct input_limit_
|
||||
{
|
||||
int16_t max;
|
||||
int16_t min;
|
||||
} input_limit;
|
||||
|
||||
void tft_init(void);
|
||||
|
||||
void tft_send_cmd(const char *cmd);
|
||||
|
||||
void tft_left(void);
|
||||
|
||||
void tft_right(void);
|
||||
|
||||
void tft_up(void);
|
||||
|
||||
void tft_down(void);
|
||||
|
||||
void tft_ok(void);
|
||||
|
||||
void tft_ret(void);
|
||||
|
||||
void tft_page_refresh(void);
|
||||
|
||||
int16_t *get_value_of_kvp(char *name, uint8_t objn);
|
||||
|
||||
input_limit tft_input_limit(char *name);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* TFT_H */
|
||||
|
|
|
|||
|
|
@ -1,41 +1,48 @@
|
|||
/*
|
||||
* 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;
|
||||
uint8_t cnt;
|
||||
} 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];
|
||||
|
||||
|
||||
|
||||
void tft_to_plan_input(uint8_t objn);
|
||||
/*
|
||||
* tft_handle_internal.h - tft和plan_handle模块共同使用部分的内部声明
|
||||
*
|
||||
* 这个文件只应包含在tft和plan_handle模块
|
||||
*/
|
||||
|
||||
#include "include/pm_time.h"
|
||||
|
||||
/*
|
||||
* plan_input - 表示计划输入的类型
|
||||
*
|
||||
*/
|
||||
typedef struct plan_input_
|
||||
{
|
||||
calendar_info bg_t; // 开始时间
|
||||
calendar_info ed_t; // 结束时间
|
||||
calendar_info pd_t; // 周期时长
|
||||
|
||||
uint8_t x_orient; // x方向值,未使用
|
||||
uint8_t y_orient; // y方向值,未使用
|
||||
uint8_t lg_r : 1; // 红灯
|
||||
uint8_t lg_b : 1; // 蓝灯
|
||||
uint8_t lg_uvb : 1; // uvb
|
||||
uint8_t water : 1; // 浇水,未使用
|
||||
uint8_t sw : 1; // 是否加入计划
|
||||
uint8_t cnt; // 完成次数
|
||||
} plan_input;
|
||||
|
||||
/*
|
||||
* kv_pair - 表示页面中的元素
|
||||
* key为存储元素ID的字符串,value为一个整形值,attr为元素属性
|
||||
*/
|
||||
typedef struct kv_pair_
|
||||
{
|
||||
char *key;
|
||||
int16_t value;
|
||||
int8_t attr;
|
||||
} kv_pair;
|
||||
|
||||
enum { PLAN_DATA_NUM = 19, OBJ_NUM = 8 };
|
||||
|
||||
extern plan_input plan_in[OBJ_NUM];
|
||||
|
||||
extern kv_pair kvp_obj_set[][PLAN_DATA_NUM];
|
||||
|
||||
|
||||
|
||||
void tft_to_plan_input(uint8_t objn);
|
||||
|
|
|
|||
|
|
@ -14,11 +14,7 @@
|
|||
|
||||
|
||||
void water_init(void);
|
||||
|
||||
|
||||
uint16_t get_moisture(void);
|
||||
|
||||
|
||||
void water_ctr(uint16_t sv_moist);
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue