From 4b2b74f75a82e00cd2ab0feacc3b37515c726cee Mon Sep 17 00:00:00 2001 From: dianke3yu <343528259@qq.com> Date: Thu, 12 Jun 2025 11:56:20 +0800 Subject: [PATCH] =?UTF-8?q?(1=EF=BC=89ota=E7=89=88=E6=9C=AC=E6=94=B9?= =?UTF-8?q?=E6=88=901.0.5(2=EF=BC=89=E6=8F=92=E5=85=A5=E5=8A=A9=E7=9C=A0?= =?UTF-8?q?=E4=BB=AA=E6=B7=BB=E5=8A=A0=E6=A3=80=E6=B5=8B=E5=BB=B6=E6=97=B6?= =?UTF-8?q?1s(3)=E4=BD=8E=E7=94=B5=E6=B7=BB=E5=8A=A0=E6=8F=92=E5=85=A5usb?= =?UTF-8?q?=E6=A3=80=E6=B5=8B,=E6=8F=92=E5=85=A5=E5=B0=B1=E4=B8=8D?= =?UTF-8?q?=E6=8A=A5,=E6=9A=82=E6=97=B6=E6=B3=A8=E9=87=8A=E6=8E=89?= =?UTF-8?q?=E6=8A=A5=E4=BD=8E=E7=94=B5,=E7=A1=AC=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=94=B9.(4)=E5=85=B3=E6=9C=BA=E6=8F=92usb=E9=9D=9E=E6=8C=89?= =?UTF-8?q?=E9=94=AE=E5=BC=80=E6=9C=BA=E4=B8=8D=E5=85=81=E8=AE=B8=E5=BC=80?= =?UTF-8?q?=E7=81=AF(5)=E4=B8=89=E8=BD=B4led=E9=97=AA=E5=8A=A0=E9=83=BD?= =?UTF-8?q?=E4=B8=AA=E7=81=AD=E7=81=AF=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/beken_wss_paopao/main/bat_main.c | 33 +++++++++++-------- .../beken_wss_paopao/main/iot/iot_lamp.c | 2 +- .../main/iot/iot_sleep_helper.c | 14 +++++--- .../projects/beken_wss_paopao/main/spi_led.c | 19 +++++++++-- 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/bk_aidk/projects/beken_wss_paopao/main/bat_main.c b/bk_aidk/projects/beken_wss_paopao/main/bat_main.c index 77677a94..4eda186d 100755 --- a/bk_aidk/projects/beken_wss_paopao/main/bat_main.c +++ b/bk_aidk/projects/beken_wss_paopao/main/bat_main.c @@ -97,13 +97,17 @@ static bk_err_t prvStartBatteryAdcOneTime() { // uint16_t value = 0; uint16_t vol; - //int i1 = 0; - // if (vol == NULL) { - // BAT_MONITOR_WPRT("Error: vol pointer is NULL\r\n"); - // return BK_FAIL; - // } + // int i1 = 0; + // if (vol == NULL) { + // BAT_MONITOR_WPRT("Error: vol pointer is NULL\r\n"); + // return BK_FAIL; + // } gpio_dev_unmap(GPIO_13); + + + // bk_gpio_enable_pull(GPIO_50); + // bk_gpio_pull_up(GPIO_50); // bk_gpio_disable_input(GPIO_0); // bk_gpio_enable_input(GPIO_13); // bk_gpio_enable_pull(GPIO_13); @@ -142,7 +146,7 @@ static bk_err_t prvStartBatteryAdcOneTime() bk_err_t ret = bk_adc_read_raw(s_raw_voltage_data, 10, ADC_READ_SEMAPHORE_WAIT_TIME); - + if (ret != BK_OK) { bk_printf("Failed to read ADC data, err: %d\r\n", ret); @@ -155,13 +159,18 @@ static bk_err_t prvStartBatteryAdcOneTime() vol = prvCalculateVoltage(); // BAT_MONITOR_PRT("ADC VALUE: %d .\r\n", *vol); + gpio_dev_unmap(GPIO_50); + bk_gpio_enable_input(GPIO_50); + rtos_delay_milliseconds(100); + uint8_t insert_value = bk_gpio_get_input(GPIO_50); + bk_printf("Charging insert_value %d \n", insert_value); bk_printf("ADC bat_value: %d mv\r\n", vol); if (vol < 3500) { - if (s_battery_main_event_callback) + if (s_battery_main_event_callback && insert_value == 0) { - bk_printf("ADC bat_value < 3500\r\n"); - s_battery_main_event_callback(EVT_BATTERY_MAIN_LOW_VOLTAGE); + bk_printf("ADC bat_value < 3500\r\n"); + //s_battery_main_event_callback(EVT_BATTERY_MAIN_LOW_VOLTAGE); } } @@ -183,7 +192,7 @@ beken_timer_t g_adc_bat; static void adc_bat_ticks(void *param) { - //bk_printf("adc_bat_ticks\n"); + // bk_printf("adc_bat_ticks\n"); prvStartBatteryAdcOneTime(); } void init_bat_timer() @@ -194,7 +203,7 @@ void init_bat_timer() bk_printf("init_bat_timer\n"); result = rtos_init_timer(&g_adc_bat, - 10000, + 60000, adc_bat_ticks, (void *)0); @@ -208,6 +217,4 @@ void init_bat_timer() { bk_printf("rtos_start_bat_timer fail\r\n"); } - - } diff --git a/bk_aidk/projects/beken_wss_paopao/main/iot/iot_lamp.c b/bk_aidk/projects/beken_wss_paopao/main/iot/iot_lamp.c index 6821920c..6452d4d7 100755 --- a/bk_aidk/projects/beken_wss_paopao/main/iot/iot_lamp.c +++ b/bk_aidk/projects/beken_wss_paopao/main/iot/iot_lamp.c @@ -28,7 +28,7 @@ #define IOT_LAMP_DEVICE_GET_BATTERY "GetBattery" #define IOT_LAMP_DEVICE_OTA "ota" -#define IOT_LAMP_DEVICE_VERSION "1.0.4" +#define IOT_LAMP_DEVICE_VERSION "1.0.5" #define IOT_LAMP_DEVICE_OTA_CHECK_URL "http://106.52.233.130:8888/ir58/ir58.json" void lamp_init(){ diff --git a/bk_aidk/projects/beken_wss_paopao/main/iot/iot_sleep_helper.c b/bk_aidk/projects/beken_wss_paopao/main/iot/iot_sleep_helper.c index 41f29ed1..368fa3c4 100755 --- a/bk_aidk/projects/beken_wss_paopao/main/iot/iot_sleep_helper.c +++ b/bk_aidk/projects/beken_wss_paopao/main/iot/iot_sleep_helper.c @@ -258,10 +258,10 @@ void sleep_helper_init(){ gpio_dev_unmap(GPIO_45); - gpio_dev_unmap(GPIO_50); - bk_gpio_enable_input(GPIO_50); - bk_gpio_enable_pull(GPIO_50); - bk_gpio_pull_up(GPIO_50); + // gpio_dev_unmap(GPIO_50); + // bk_gpio_enable_input(GPIO_50); + // bk_gpio_enable_pull(GPIO_50); + // bk_gpio_pull_up(GPIO_50); pwm_init_config_t config = {0}; config.period_cycle = 100; @@ -320,6 +320,12 @@ void sleep_helper_open(){ LOGE("sleep_helper_open\n"); bk_gpio_enable_output(44); bk_gpio_enable_output(45); + gpio_dev_unmap(GPIO_50); + bk_gpio_enable_input(GPIO_50); + bk_gpio_enable_pull(GPIO_50); + bk_gpio_pull_up(GPIO_50); + + rtos_delay_milliseconds(1000); uint8_t insert_value = bk_gpio_get_input(GPIO_50); LOGE("sleep_helper insert_value %d \n",insert_value); socket_insert = insert_value; diff --git a/bk_aidk/projects/beken_wss_paopao/main/spi_led.c b/bk_aidk/projects/beken_wss_paopao/main/spi_led.c index fb9cf2bf..c4d9199c 100755 --- a/bk_aidk/projects/beken_wss_paopao/main/spi_led.c +++ b/bk_aidk/projects/beken_wss_paopao/main/spi_led.c @@ -51,6 +51,7 @@ const int RED = 0x00FF00; const int BLUE = 0x0000FF; const int GREEN = 0xFF0000; const int WHITE = 0xFFFFF; +const int TRUN_OFF = 0x00000; const int TEST_1 = 0xFF0000;//GRB const int TEST_2 = 0x00FF00; @@ -125,7 +126,7 @@ typedef struct static spi_data_test_config_t s_spi_test; static int colorIndex = 0; -static int colors[] = {RED, GREEN, WHITE}; +static int colors[] = {RED, GREEN, WHITE,TRUN_OFF}; static int current_color = RED; static float current_brightness = 100; static beken_queue_t spi_led_msg_que = NULL; @@ -297,14 +298,21 @@ void ws2812_deinit(){ bk_dma_free(DMA_DEV_DTCM, s_spi_test.spi_rx_dma_chan); } +extern int ispoweron; void ws2812_led_wifi_disconnect(){ //bk_printf("hi ws2812_led_wifi_disconnect777777\n"); //open_dmaspi(RED, 1); + if(ispoweron == 0){ + return; + } ws2812_set_all_led(RED,current_brightness); } void ws2812_led_wifi_connected(){ //bk_printf("hi ws2812_led_wifi_connected22\n"); //open_dmaspi(WHITE, 1); + if(ispoweron == 0){ + return; + } ws2812_set_all_led(WHITE,current_brightness); } void ws2812_led_asr_wakeup(){ @@ -336,7 +344,11 @@ void ws2812_set_all_led_color(int color){ void spi_led_init_gsensor() { - colorIndex = (colorIndex + 1) % 3; + + if(ispoweron == 0){ + return; + } + colorIndex = (colorIndex + 1) % 4; //int colorIndex = colors[colorIndex]; // 调用设置颜色的函数 ws2812_set_all_led(colors[colorIndex], current_brightness); @@ -346,6 +358,9 @@ void spi_led_init_gsensor() } void ws2812_led_change_color(){ + if(ispoweron == 0){ + return; + } ws2812_msg_t msg; msg.type = TYPE_CHANGE_COLOR; rtos_push_to_queue(&spi_led_msg_que, &msg, BEKEN_NO_WAIT);