mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 20:47:08 +03:00
add battery for muse
This commit is contained in:
@@ -20,8 +20,7 @@ CONFIG_SPI_CONFIG="mosi=15,miso=2,clk=14"
|
||||
CONFIG_SET_GPIO=""
|
||||
CONFIG_GPIO_EXP_CONFIG=""
|
||||
CONFIG_ROTARY_ENCODER=""
|
||||
CONFIG_LED_GREEN_GPIO=22
|
||||
CONFIG_LED_GREEN_GPIO_LEVEL=0
|
||||
CONFIG_LED_GREEN_GPIO=-1
|
||||
CONFIG_LED_RED_GPIO=-1
|
||||
CONFIG_JACK_GPIO=34
|
||||
CONFIG_JACK_GPIO_LEVEL=0
|
||||
|
||||
@@ -52,51 +52,27 @@ const struct target_s target_muse = { "muse", init };
|
||||
static bool init(void) {
|
||||
battery_handler_chain = battery_handler_svc;
|
||||
battery_handler_svc = battery_svc;
|
||||
ws2812_control_init();
|
||||
ESP_LOGI(TAG, "Initializing for Muse");
|
||||
return true;
|
||||
}
|
||||
|
||||
static void battery_svc(float value) {
|
||||
ESP_LOGI(TAG, "Called for battery service with %f", value);
|
||||
// put here your code for LED according to value
|
||||
if (battery_handler_chain) battery_handler_chain(value);
|
||||
}
|
||||
#define VGREEN 4.0
|
||||
#define VRED 3.6
|
||||
|
||||
static void battery_svc(float value) {
|
||||
struct led_state new_state;
|
||||
|
||||
ESP_LOGI(TAG, "Called for battery service with %f", value);
|
||||
|
||||
if (value > VGREEN) new_state.leds[0] = GREEN;
|
||||
else if (value < VRED) new_state.leds[0] = RED;
|
||||
else new_state.leds[0] = YELLOW;
|
||||
|
||||
// Battery monitoring
|
||||
/*
|
||||
static void battery(void *data)
|
||||
{
|
||||
#define VGREEN 2300
|
||||
#define VRED 2000
|
||||
#define NM 10
|
||||
static int val;
|
||||
static int V[NM];
|
||||
static int I=0;
|
||||
int S;
|
||||
for(int i=0;i<NM;i++)V[i]=VGREEN;
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
struct led_state new_state;
|
||||
ws2812_control_init();
|
||||
// init ADC interface for battery survey
|
||||
adc1_config_width(ADC_WIDTH_BIT_12);
|
||||
adc1_config_channel_atten(ADC1_GPIO33_CHANNEL, ADC_ATTEN_DB_11);
|
||||
while(true)
|
||||
{
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
V[I++] = adc1_get_raw(ADC1_GPIO33_CHANNEL);
|
||||
if(I >= NM)I = 0;
|
||||
S = 0;
|
||||
for(int i=0;i<NM;i++)S = S + V[i];
|
||||
val = S / NM;
|
||||
new_state.leds[0] = YELLOW;
|
||||
if(val > VGREEN) new_state.leds[0] = GREEN;
|
||||
if(val < VRED) new_state.leds[0] = RED;
|
||||
printf("====> %d %6x\n", val, new_state.leds[0]);
|
||||
ws2812_write_leds(new_state);
|
||||
|
||||
}
|
||||
if (battery_handler_chain) battery_handler_chain(value);
|
||||
}
|
||||
*/
|
||||
|
||||
// This is the buffer which the hw peripheral will access while pulsing the output pin
|
||||
rmt_item32_t led_data_buffer[LED_BUFFER_ITEMS];
|
||||
@@ -139,5 +115,5 @@ void setup_rmt_data_buffer(struct led_state new_state)
|
||||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +334,6 @@ menu "Squeezelite-ESP32"
|
||||
config LED_GREEN_GPIO
|
||||
int "Green led GPIO"
|
||||
default 12 if SQUEEZEAMP
|
||||
default 22 if MUSE
|
||||
default -1
|
||||
help
|
||||
Set to -1 for no LED
|
||||
|
||||
Reference in New Issue
Block a user