增加 BLE MAC 地址管理功能,添加电量灯颜色设置,优化调度器挂起和恢复逻辑
This commit is contained in:
@@ -526,6 +526,25 @@ int app_cfg_set_mac_tab(uint8_t mac[6])
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_cfg_set_ble_mac_tab(uint8_t mac[6])
|
||||
{
|
||||
for (int i = 0; i < __ARRAY_SIZE(s_cfg_app.ble_mac_tab); i++)
|
||||
{
|
||||
if (memcmp(mac, s_cfg_app.ble_mac_tab[i], 6) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (++s_cfg_app.ble_mac_index >= __ARRAY_SIZE(s_cfg_app.ble_mac_tab))
|
||||
{
|
||||
s_cfg_app.ble_mac_index = 0;
|
||||
}
|
||||
memcpy(s_cfg_app.ble_mac_tab[s_cfg_app.ble_mac_index], mac, sizeof(s_cfg_app.ble_mac_tab[0]));
|
||||
app_cfg_do_save(1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_cfg_set_temp_log_on(bool sw)
|
||||
{
|
||||
// SYS_LOG_INF("set temp log on: %d", sw);
|
||||
@@ -552,3 +571,15 @@ int app_cfg_set_gyro_heat_value(uint8_t value)
|
||||
app_cfg_do_save(100);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_cfg_set_bat_led_color(uint32_t color)
|
||||
{
|
||||
if (color > 0xFFFFFF)
|
||||
{
|
||||
SYS_LOG_WRN("error color: %d", color);
|
||||
return -1;
|
||||
}
|
||||
s_cfg_app.ws2812_bat_led_color = color & 0xFFFFFF;
|
||||
app_cfg_do_save(100);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ typedef struct // 设备配置统一数据结构
|
||||
bool strip_pwrup : 1; // 使用灯带上电效果
|
||||
bool strip_show_rf : 1; // 在灯带中用一个灯来显示射频数据接口状态的灯效图层
|
||||
bool strip_link_fc : 1; // 开启灯带联动飞控:用于飞控状态监控(MSP)
|
||||
char ws2812_bat_led_mode : 2; // 电量灯效, 0: 关闭, 1: 普通飞控, 2: 竞速飞控
|
||||
char ws2812_bat_led_mode : 3; // 电量灯效, 0: 关闭, 1: 普通飞控, 2: 竞速飞控, 3: 固定翼飞控
|
||||
|
||||
uint32_t reserve : 21; // 预留占位(原来是24个uint32)
|
||||
} capacity;
|
||||
@@ -132,8 +132,12 @@ typedef struct // 设备配置统一数据结构
|
||||
} temperature_log;
|
||||
|
||||
bool ws2812_bat_led_direction; // 0: 正向,1: 反向(正反向是指灯珠的连接方式,正向是指从第一个灯珠开始,反向是指从最后一个灯珠开始)
|
||||
uint32_t ws2812_bat_led_color; // 电量灯颜色, RGB颜色值,如 0xFFFFFF 代表白色(默认)
|
||||
|
||||
uint32_t reserve[36]; // 预留占位,下次更改时保证参数总长度不变,如超过预留长度后则当作新数据处理,sizeof(cfg_app_t) = 484UL
|
||||
uint8_t ble_mac_index; // 记录当前通过 BLE 连接过的 APP 的 MAC 地址的序号
|
||||
uint8_t ble_mac_tab[6][6]; // 记录当前通过 BLE 连接过的 APP 的 MAC 地址, 6 个 MAC 地址,每个 MAC 地址 6 字节,判断是否 APP 设备连接,用于决定是否停止对飞控状态监测
|
||||
|
||||
uint32_t reserve[25]; // 预留占位,下次更改时保证参数总长度不变,如超过预留长度后则当作新数据处理,sizeof(cfg_app_t) = 484UL
|
||||
|
||||
uint32_t crc32; // 校验数据(可放于任何位置)
|
||||
} cfg_app_t;
|
||||
@@ -182,8 +186,11 @@ int app_cfg_set_wifi_sta_ssid(const void *ssid);
|
||||
int app_cfg_set_wifi_sta_password(const void *password);
|
||||
|
||||
int app_cfg_set_mac_tab(uint8_t mac[6]);
|
||||
int app_cfg_set_ble_mac_tab(uint8_t mac[6]);
|
||||
|
||||
int app_cfg_set_temp_log_on(bool sw);
|
||||
int app_cfg_set_temp_log_index(uint8_t index);
|
||||
|
||||
int app_cfg_set_gyro_heat_value(uint8_t value);
|
||||
|
||||
int app_cfg_set_bat_led_color(uint32_t color);
|
||||
|
||||
@@ -54,9 +54,10 @@ static cfg_app_t const s_cfg_app_default = {
|
||||
.strip_pwrup = 0, // 使用灯带上电效果
|
||||
.strip_show_rf = 0, // 在灯带中用一个灯来显示射频数据接口状态的灯效图层
|
||||
.strip_link_fc = 0, // 开启灯带联动飞控
|
||||
.ws2812_bat_led_mode = 1, // 电量灯效, 0: 关闭, 1: 普通飞控, 2: 竞速飞控
|
||||
.ws2812_bat_led_mode = 1, // 电量灯效, 0: 关闭, 1: 普通飞控, 2: 竞速飞控, 3: 固定翼飞控
|
||||
},
|
||||
.ws2812_bat_led_direction = 0, // 0: 正向,1: 反向(正反向是指灯珠的连接方式,正向是指从第一个灯珠开始,反向是指从最后一个灯珠开始)
|
||||
.ws2812_bat_led_direction = 0, // 0: 正向,1: 反向(正反向是指灯珠的连接方式,正向是指从第一个灯珠开始,反向是指从最后一个灯珠开始)
|
||||
.ws2812_bat_led_color = 0xFFFFFF, // 电量灯颜色, RGB颜色值,如 0xFFFFFF 代表白色(默认)
|
||||
.temperature_log = {
|
||||
.temp_log_on = 0, // 温度日志开关
|
||||
.temp_log_index = 0, // 温度日志最新索引
|
||||
|
||||
@@ -50,9 +50,21 @@ static cfg_app_t const s_cfg_app_default = {
|
||||
.ble = 1, // 使用 BLE
|
||||
.ap = 0, // 使用 WIFI AP 模式
|
||||
.sta = 0, // 使用 WIFI STA 模式
|
||||
|
||||
.strip_pwrup = 0, // 使用灯带上电效果
|
||||
.strip_show_rf = 0, // 在灯带中用一个灯来显示射频数据接口状态的灯效图层
|
||||
.strip_link_fc = 0, // 开启灯带联动飞控
|
||||
.ws2812_bat_led_mode = 0, // 电量灯效, 0: 关闭, 1: 普通飞控, 2: 竞速飞控, 3: 固定翼飞控
|
||||
},
|
||||
.armed2close_rf_sw = 1, // 解锁后自动关闭射频功能的开关,0:关, 1:开
|
||||
.ws2812_bat_led_direction = 0, // 0: 正向,1: 反向(正反向是指灯珠的连接方式,正向是指从第一个灯珠开始,反向是指从最后一个灯珠开始)
|
||||
.ws2812_bat_led_color = 0xFFFFFF, // 电量灯颜色, RGB颜色值,如 0xFFFFFF 代表白色(默认)
|
||||
.temperature_log = {
|
||||
.temp_log_on = 0, // 温度日志开关
|
||||
.temp_log_index = 0, // 温度日志最新索引
|
||||
},
|
||||
.armed2close_rf_sw = 0, // 解锁后自动关闭射频功能的开关,0:关, 1:开
|
||||
.product_id = PRODUCT_ID, // 产品 ID
|
||||
.gyro_heat_value = 0, // 陀螺仪加热值,单位温度,0为关闭,最大值为80℃
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user