1.合并睡眠仪修改
This commit is contained in:
commit
f2c07eccd8
@ -97,13 +97,17 @@ static bk_err_t prvStartBatteryAdcOneTime()
|
|||||||
{
|
{
|
||||||
// uint16_t value = 0;
|
// uint16_t value = 0;
|
||||||
uint16_t vol;
|
uint16_t vol;
|
||||||
//int i1 = 0;
|
// int i1 = 0;
|
||||||
// if (vol == NULL) {
|
// if (vol == NULL) {
|
||||||
// BAT_MONITOR_WPRT("Error: vol pointer is NULL\r\n");
|
// BAT_MONITOR_WPRT("Error: vol pointer is NULL\r\n");
|
||||||
// return BK_FAIL;
|
// return BK_FAIL;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
gpio_dev_unmap(GPIO_13);
|
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_disable_input(GPIO_0);
|
||||||
// bk_gpio_enable_input(GPIO_13);
|
// bk_gpio_enable_input(GPIO_13);
|
||||||
// bk_gpio_enable_pull(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,
|
bk_err_t ret = bk_adc_read_raw(s_raw_voltage_data,
|
||||||
10,
|
10,
|
||||||
ADC_READ_SEMAPHORE_WAIT_TIME);
|
ADC_READ_SEMAPHORE_WAIT_TIME);
|
||||||
|
|
||||||
if (ret != BK_OK)
|
if (ret != BK_OK)
|
||||||
{
|
{
|
||||||
bk_printf("Failed to read ADC data, err: %d\r\n", ret);
|
bk_printf("Failed to read ADC data, err: %d\r\n", ret);
|
||||||
@ -155,13 +159,18 @@ static bk_err_t prvStartBatteryAdcOneTime()
|
|||||||
|
|
||||||
vol = prvCalculateVoltage();
|
vol = prvCalculateVoltage();
|
||||||
// BAT_MONITOR_PRT("ADC VALUE: %d .\r\n", *vol);
|
// 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);
|
bk_printf("ADC bat_value: %d mv\r\n", vol);
|
||||||
if (vol < 3500)
|
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");
|
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)
|
static void adc_bat_ticks(void *param)
|
||||||
{
|
{
|
||||||
|
|
||||||
//bk_printf("adc_bat_ticks\n");
|
// bk_printf("adc_bat_ticks\n");
|
||||||
prvStartBatteryAdcOneTime();
|
prvStartBatteryAdcOneTime();
|
||||||
}
|
}
|
||||||
void init_bat_timer()
|
void init_bat_timer()
|
||||||
@ -194,7 +203,7 @@ void init_bat_timer()
|
|||||||
bk_printf("init_bat_timer\n");
|
bk_printf("init_bat_timer\n");
|
||||||
|
|
||||||
result = rtos_init_timer(&g_adc_bat,
|
result = rtos_init_timer(&g_adc_bat,
|
||||||
10000,
|
60000,
|
||||||
adc_bat_ticks,
|
adc_bat_ticks,
|
||||||
(void *)0);
|
(void *)0);
|
||||||
|
|
||||||
@ -208,6 +217,4 @@ void init_bat_timer()
|
|||||||
{
|
{
|
||||||
bk_printf("rtos_start_bat_timer fail\r\n");
|
bk_printf("rtos_start_bat_timer fail\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#define IOT_LAMP_DEVICE_GET_BATTERY "GetBattery"
|
#define IOT_LAMP_DEVICE_GET_BATTERY "GetBattery"
|
||||||
#define IOT_LAMP_DEVICE_OTA "ota"
|
#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"
|
#define IOT_LAMP_DEVICE_OTA_CHECK_URL "http://106.52.233.130:8888/ir58/ir58.json"
|
||||||
|
|
||||||
void lamp_init(){
|
void lamp_init(){
|
||||||
|
@ -329,6 +329,12 @@ void sleep_helper_open(){
|
|||||||
LOGE("sleep_helper_open\n");
|
LOGE("sleep_helper_open\n");
|
||||||
bk_gpio_enable_output(44);
|
bk_gpio_enable_output(44);
|
||||||
bk_gpio_enable_output(45);
|
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);
|
uint8_t insert_value = bk_gpio_get_input(GPIO_50);
|
||||||
LOGE("sleep_helper insert_value %d \n",insert_value);
|
LOGE("sleep_helper insert_value %d \n",insert_value);
|
||||||
socket_insert = insert_value;
|
socket_insert = insert_value;
|
||||||
@ -467,11 +473,10 @@ void sleep_helper_init(){
|
|||||||
gpio_dev_unmap(GPIO_44);
|
gpio_dev_unmap(GPIO_44);
|
||||||
gpio_dev_unmap(GPIO_45);
|
gpio_dev_unmap(GPIO_45);
|
||||||
|
|
||||||
|
// gpio_dev_unmap(GPIO_50);
|
||||||
gpio_dev_unmap(GPIO_50);
|
// bk_gpio_enable_input(GPIO_50);
|
||||||
bk_gpio_enable_input(GPIO_50);
|
// bk_gpio_enable_pull(GPIO_50);
|
||||||
bk_gpio_enable_pull(GPIO_50);
|
// bk_gpio_pull_up(GPIO_50);
|
||||||
bk_gpio_pull_up(GPIO_50);
|
|
||||||
|
|
||||||
pwm_init_config_t config = {0};
|
pwm_init_config_t config = {0};
|
||||||
//config.period_cycle = 100;
|
//config.period_cycle = 100;
|
||||||
|
@ -51,6 +51,7 @@ const int RED = 0x00FF00;
|
|||||||
const int BLUE = 0x0000FF;
|
const int BLUE = 0x0000FF;
|
||||||
const int GREEN = 0xFF0000;
|
const int GREEN = 0xFF0000;
|
||||||
const int WHITE = 0xFFFFF;
|
const int WHITE = 0xFFFFF;
|
||||||
|
const int TRUN_OFF = 0x00000;
|
||||||
|
|
||||||
const int TEST_1 = 0xFF0000;//GRB
|
const int TEST_1 = 0xFF0000;//GRB
|
||||||
const int TEST_2 = 0x00FF00;
|
const int TEST_2 = 0x00FF00;
|
||||||
@ -125,7 +126,7 @@ typedef struct
|
|||||||
static spi_data_test_config_t s_spi_test;
|
static spi_data_test_config_t s_spi_test;
|
||||||
|
|
||||||
static int colorIndex = 0;
|
static int colorIndex = 0;
|
||||||
static int colors[] = {RED, GREEN, WHITE};
|
static int colors[] = {RED, GREEN, WHITE,TRUN_OFF};
|
||||||
static int current_color = RED;
|
static int current_color = RED;
|
||||||
static float current_brightness = 100;
|
static float current_brightness = 100;
|
||||||
static beken_queue_t spi_led_msg_que = NULL;
|
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);
|
bk_dma_free(DMA_DEV_DTCM, s_spi_test.spi_rx_dma_chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int ispoweron;
|
||||||
void ws2812_led_wifi_disconnect(){
|
void ws2812_led_wifi_disconnect(){
|
||||||
//bk_printf("hi ws2812_led_wifi_disconnect777777\n");
|
//bk_printf("hi ws2812_led_wifi_disconnect777777\n");
|
||||||
//open_dmaspi(RED, 1);
|
//open_dmaspi(RED, 1);
|
||||||
|
if(ispoweron == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
ws2812_set_all_led(RED,current_brightness);
|
ws2812_set_all_led(RED,current_brightness);
|
||||||
}
|
}
|
||||||
void ws2812_led_wifi_connected(){
|
void ws2812_led_wifi_connected(){
|
||||||
//bk_printf("hi ws2812_led_wifi_connected22\n");
|
//bk_printf("hi ws2812_led_wifi_connected22\n");
|
||||||
//open_dmaspi(WHITE, 1);
|
//open_dmaspi(WHITE, 1);
|
||||||
|
if(ispoweron == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
ws2812_set_all_led(WHITE,current_brightness);
|
ws2812_set_all_led(WHITE,current_brightness);
|
||||||
}
|
}
|
||||||
void ws2812_led_asr_wakeup(){
|
void ws2812_led_asr_wakeup(){
|
||||||
@ -335,7 +343,11 @@ void ws2812_set_all_led_color(int color){
|
|||||||
|
|
||||||
void spi_led_init_gsensor()
|
void spi_led_init_gsensor()
|
||||||
{
|
{
|
||||||
colorIndex = (colorIndex + 1) % 3;
|
|
||||||
|
if(ispoweron == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
colorIndex = (colorIndex + 1) % 4;
|
||||||
//int colorIndex = colors[colorIndex];
|
//int colorIndex = colors[colorIndex];
|
||||||
// 调用设置颜色的函数
|
// 调用设置颜色的函数
|
||||||
ws2812_set_all_led(colors[colorIndex], current_brightness);
|
ws2812_set_all_led(colors[colorIndex], current_brightness);
|
||||||
@ -345,6 +357,9 @@ void spi_led_init_gsensor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ws2812_led_change_color(){
|
void ws2812_led_change_color(){
|
||||||
|
if(ispoweron == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
ws2812_msg_t msg;
|
ws2812_msg_t msg;
|
||||||
msg.type = TYPE_CHANGE_COLOR;
|
msg.type = TYPE_CHANGE_COLOR;
|
||||||
rtos_push_to_queue(&spi_led_msg_que, &msg, BEKEN_NO_WAIT);
|
rtos_push_to_queue(&spi_led_msg_que, &msg, BEKEN_NO_WAIT);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user