Browse Source

update filterbox

master
zhaohe 4 years ago
parent
commit
81e4ce3c88
  1. 24
      README.md
  2. 29
      src/main_app.c

24
README.md

@ -1 +1,25 @@
FilterBox FilterBox
AT指令说明
[toc]
## 调整消抖延时
### 设置指令
AT+FILTER_TIME_MS=10
### 查询指令
AT+FILTER_TIME_MS?
## 调整输入输出是否镜像
### 设置指令
AT+IO_MIRROR=0
AT+IO_MIRROR=1
### 查询指令
AT+IO_MIRROR?
## 保存配置到FLASH中
AT+SAVE

29
src/main_app.c

@ -16,7 +16,10 @@
* @return int * @return int
*/ */
#define LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
#define LOG(fmt, ...) \
{ \
if (s_config.log) printf(fmt "\n", ##__VA_ARGS__); \
}
static uint32_t prvhasPassedMs(uint32_t last) { static uint32_t prvhasPassedMs(uint32_t last) {
uint32_t now = HAL_GetTick(); uint32_t now = HAL_GetTick();
@ -36,8 +39,10 @@ typedef struct {
uint32_t filterTime; uint32_t filterTime;
bool echo; bool echo;
bool mirror; bool mirror;
bool log;
} Config_t; } Config_t;
static Config_t s_config = {.filterTime = 1, .echo = true, .mirror = false};
static Config_t s_config = {
.filterTime = 1, .echo = true, .mirror = false, .log = false};
uint32_t prv_get_filter_time() { return s_config.filterTime; } uint32_t prv_get_filter_time() { return s_config.filterTime; }
void prv_set_filter_time(uint32_t filtertime) { void prv_set_filter_time(uint32_t filtertime) {
s_config.filterTime = filtertime; s_config.filterTime = filtertime;
@ -146,6 +151,24 @@ bool processIOMirrorOrder(at_ordertype_t type, const char* order_name,
} }
return false; return false;
} }
bool processLOGOrder(at_ordertype_t type, const char* order_name,
const char* order_val) {
if (type == kat_order) {
return false;
} else if (type == kat_showinfo) {
printf("%d\r\n", s_config.log);
return true;
} else if (type == kat_set) {
if (order_val == NULL) return false;
int orderval = atoi(order_val);
if (orderval > 0)
s_config.log = 1;
else
s_config.log = 0;
return true;
}
return false;
}
bool processSaveOrder(at_ordertype_t type, const char* order_name, bool processSaveOrder(at_ordertype_t type, const char* order_name,
const char* order_val) { const char* order_val) {
if (type == kat_order) { if (type == kat_order) {
@ -196,6 +219,8 @@ void processOrder(char* atorder, int num) {
success = processIOMirrorOrder(type, order_name, order_val); success = processIOMirrorOrder(type, order_name, order_val);
} else if (str_is_eq("SAVE", order_name)) { } else if (str_is_eq("SAVE", order_name)) {
success = processSaveOrder(type, order_name, order_val); success = processSaveOrder(type, order_name, order_val);
} else if (str_is_eq("LOG", order_name)) {
success = processLOGOrder(type, order_name, order_val);
} else { } else {
success = false; success = false;
} }

Loading…
Cancel
Save