1.合并睡眠仪修改

This commit is contained in:
helloyifa 2025-06-12 12:18:38 +08:00
commit f2c07eccd8
4 changed files with 48 additions and 21 deletions

View File

@ -97,13 +97,17 @@ static bk_err_t prvStartBatteryAdcOneTime()
{
// uint16_t value = 0;
uint16_t vol;
//int i1 = 0;
// 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);
@ -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);
//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");
}
}

View File

@ -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(){

View File

@ -329,6 +329,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;
@ -467,11 +473,10 @@ void sleep_helper_init(){
gpio_dev_unmap(GPIO_44);
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;

View File

@ -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(){
@ -335,7 +343,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);
@ -345,6 +357,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);