支持按键开关rf射频功能
This commit is contained in:
@@ -60,6 +60,7 @@ typedef struct
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RC_OFF_NONE,
|
||||
WIFI_NETIF_MODE_AP,
|
||||
WIFI_NETIF_MODE_STA,
|
||||
} wifi_netif_mode_t;
|
||||
|
||||
@@ -19,6 +19,7 @@ uint16_t toggle_cycle = 1000;
|
||||
bool toggle_flag[EXAMPLE_LED_NUMBERS] = {true,true};
|
||||
bool toggle_flag_lat[EXAMPLE_LED_NUMBERS] = {true,true};
|
||||
|
||||
rgb_color_t rgb_color_none = {0,0,0,0,0,1,0,RGB_COLOR_NONE};
|
||||
rgb_color_t rgb_color_rad = {0,255,0,0,0,1,0,RGB_COLOR_RAD};
|
||||
rgb_color_t rgb_color_orange = {0,255,80,0,0,1,0,RGB_COLOR_ORANGE};
|
||||
rgb_color_t rgb_color_green = {0,0,255,0,0,1,0,RGB_COLOR_GREEN};
|
||||
@@ -104,6 +105,9 @@ void rgb_color_change(uint8_t index, uint8_t color)
|
||||
{
|
||||
switch(color)
|
||||
{
|
||||
case RGB_COLOR_NONE:
|
||||
memcpy(&expression[index], &rgb_color_none, sizeof(rgb_color_none));
|
||||
break;
|
||||
case RGB_COLOR_RAD:
|
||||
memcpy(&expression[index], &rgb_color_rad, sizeof(rgb_color_rad));
|
||||
break;
|
||||
|
||||
@@ -282,27 +282,38 @@ uint8_t wifi_init(init_device_t *port)
|
||||
void wifi_mode_switch(init_device_t *port)
|
||||
{
|
||||
static init_device_t* port_lat = NULL;
|
||||
static bool wifi_mode_flag = false;
|
||||
static uint8_t wifi_mode_flag = 0;
|
||||
|
||||
if(port_lat == NULL && port != NULL)
|
||||
{
|
||||
port_lat = port;
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_AP;
|
||||
return;
|
||||
}
|
||||
|
||||
if (wifi_mode_flag)
|
||||
switch(wifi_mode_flag)
|
||||
{
|
||||
wifi_mode_flag = false;
|
||||
wifi_set_mode(WIFI_NETIF_MODE_AP);
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_AP;
|
||||
SYS_LOG_INF("wifi mode switch to ap");
|
||||
}
|
||||
else
|
||||
{
|
||||
wifi_mode_flag = true;
|
||||
wifi_set_mode(WIFI_NETIF_MODE_STA);
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_STA;
|
||||
SYS_LOG_INF("wifi mode switch to sta");
|
||||
case 0:
|
||||
wifi_mode_flag = 1;
|
||||
wifi_set_mode(WIFI_NETIF_MODE_STA);
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_STA;
|
||||
SYS_LOG_INF("wifi mode switch to sta");
|
||||
break;
|
||||
case 1:
|
||||
wifi_mode_flag = 2;
|
||||
SYS_LOG_INF("wifi mode switch to off");
|
||||
port_lat->wifi_mode = RC_OFF_NONE;
|
||||
rf_stop(device_inside);
|
||||
break;
|
||||
case 2:
|
||||
rf_start(device_inside);
|
||||
wifi_mode_flag = 0;
|
||||
wifi_set_mode(WIFI_NETIF_MODE_AP);
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_AP;
|
||||
SYS_LOG_INF("wifi mode switch to ap");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
wifi_start();
|
||||
}
|
||||
|
||||
@@ -354,37 +354,40 @@ void pc_link_rgb_color(device_t* device)
|
||||
case DISCONNECT:
|
||||
{
|
||||
if(device->init_device.wifi_mode == WIFI_NETIF_MODE_AP)
|
||||
new_color = RGB_COLOR_GREEN_WHITE;
|
||||
else
|
||||
new_color = RGB_COLOR_GREEN_PURPLE;
|
||||
new_color = NO_CONNECT_COLOR_BLE_AP;
|
||||
else if(device->init_device.wifi_mode == WIFI_NETIF_MODE_STA)
|
||||
new_color = NO_CONNECT_COLOR_BLE_STA;
|
||||
else if(device->init_device.wifi_mode == RC_OFF_NONE)
|
||||
new_color = RF_OFF_COLOR;
|
||||
break;
|
||||
}
|
||||
case CONNECT_WIFI_TCP:
|
||||
{
|
||||
if(device->init_device.wifi_mode == WIFI_NETIF_MODE_AP)
|
||||
new_color = RGB_COLOR_WHITE;
|
||||
else
|
||||
new_color = RGB_COLOR_PURPLE;
|
||||
|
||||
new_color = WIFI_AP_COLOR;
|
||||
else if(device->init_device.wifi_mode == WIFI_NETIF_MODE_STA)
|
||||
new_color = WIFI_STA_COLOR;
|
||||
else if(device->init_device.wifi_mode == RC_OFF_NONE)
|
||||
new_color = RF_OFF_COLOR;
|
||||
break;
|
||||
}
|
||||
case CONNECT_WIFI_UDP:
|
||||
{
|
||||
if(device->init_device.wifi_mode == WIFI_NETIF_MODE_AP)
|
||||
new_color = RGB_COLOR_WHITE;
|
||||
new_color = WIFI_AP_COLOR;
|
||||
else
|
||||
new_color = RGB_COLOR_PURPLE;
|
||||
new_color = WIFI_STA_COLOR;
|
||||
|
||||
break;
|
||||
}
|
||||
case CONNECT_BLE:
|
||||
{
|
||||
new_color = RGB_COLOR_GREEN;
|
||||
new_color = BLE_COLOR;
|
||||
}
|
||||
break;
|
||||
case CONNECT_RF_OFF:
|
||||
{
|
||||
new_color = RGB_COLOR_BLUE;
|
||||
new_color = RF_OFF_COLOR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
|
||||
#define FC_ADDRESS "0x08000000"
|
||||
#define DATA_HANDLE_BUFFER_SIZE 4096
|
||||
|
||||
#define RF_OFF_COLOR RGB_COLOR_NONE //关闭射频灯的颜色指示
|
||||
#define WIFI_AP_COLOR RGB_COLOR_WHITE //连接WIFI AP模式指示
|
||||
#define WIFI_STA_COLOR RGB_COLOR_PURPLE //连接WIFI STA模式指示
|
||||
#define BLE_COLOR RGB_COLOR_GREEN //连接BLE模式指示
|
||||
#define NO_CONNECT_COLOR_BLE_AP RGB_COLOR_GREEN_WHITE //未连接模式指示BLE+AP
|
||||
#define NO_CONNECT_COLOR_BLE_STA RGB_COLOR_GREEN_PURPLE //未连接模式指示BLE+STA
|
||||
typedef enum
|
||||
{
|
||||
DATA_HANDLE_IDLE = 0,
|
||||
@@ -135,4 +142,6 @@ void data_handle_thread(void* arg);
|
||||
*/
|
||||
void pc_link_rgb_color(device_t* device);
|
||||
|
||||
int app_send_error_code(uint8_t error_code);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user