mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 20:17:04 +03:00
Rotary encoder + simplify
- GPIO expander works with rotary encoder - Much better mimic real GPIO, including ISR, to minimize impact on clients
This commit is contained in:
@@ -132,10 +132,10 @@ static bool handler(u8_t *data, int len){
|
||||
|
||||
if (jack_mutes_amp && jack_inserted_svc()) {
|
||||
adac->speaker(false);
|
||||
if (amp_control.gpio != -1) gpio_set_level_u(amp_control.gpio, !amp_control.active);
|
||||
if (amp_control.gpio != -1) gpio_set_level_x(amp_control.gpio, !amp_control.active);
|
||||
} else {
|
||||
adac->speaker(true);
|
||||
if (amp_control.gpio != -1) gpio_set_level_u(amp_control.gpio, amp_control.active);
|
||||
if (amp_control.gpio != -1) gpio_set_level_x(amp_control.gpio, amp_control.active);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ static void jack_handler(bool inserted) {
|
||||
if (jack_mutes_amp) {
|
||||
LOG_INFO("switching amplifier %s", inserted ? "OFF" : "ON");
|
||||
adac->speaker(!inserted);
|
||||
if (amp_control.gpio != -1) gpio_set_level_u(amp_control.gpio, inserted ? !amp_control.active : amp_control.active);
|
||||
if (amp_control.gpio != -1) gpio_set_level_x(amp_control.gpio, inserted ? !amp_control.active : amp_control.active);
|
||||
}
|
||||
|
||||
// activate headset
|
||||
@@ -178,9 +178,9 @@ static void set_amp_gpio(int gpio, char *value) {
|
||||
amp_control.gpio = gpio;
|
||||
if ((p = strchr(value, ':')) != NULL) amp_control.active = atoi(p + 1);
|
||||
|
||||
if (amp_control.gpio < GPIO_NUM_MAX) gpio_pad_select_gpio(amp_control.gpio);
|
||||
gpio_set_direction_u(amp_control.gpio, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level_u(amp_control.gpio, !amp_control.active);
|
||||
gpio_pad_select_gpio_x(amp_control.gpio);
|
||||
gpio_set_direction_x(amp_control.gpio, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level_x(amp_control.gpio, !amp_control.active);
|
||||
|
||||
LOG_INFO("setting amplifier GPIO %d (active:%d)", amp_control.gpio, amp_control.active);
|
||||
}
|
||||
@@ -456,14 +456,14 @@ static void output_thread_i2s(void *arg) {
|
||||
LOG_INFO("Output state is %d", output.state);
|
||||
if (output.state == OUTPUT_OFF) {
|
||||
led_blink(LED_GREEN, 100, 2500);
|
||||
if (amp_control.gpio != -1) gpio_set_level_u(amp_control.gpio, !amp_control.active);
|
||||
if (amp_control.gpio != -1) gpio_set_level_x(amp_control.gpio, !amp_control.active);
|
||||
LOG_INFO("switching off amp GPIO %d", amp_control.gpio);
|
||||
} else if (output.state == OUTPUT_STOPPED) {
|
||||
adac->speaker(false);
|
||||
led_blink(LED_GREEN, 200, 1000);
|
||||
} else if (output.state == OUTPUT_RUNNING) {
|
||||
if (!jack_mutes_amp || !jack_inserted_svc()) {
|
||||
if (amp_control.gpio != -1) gpio_set_level_u(amp_control.gpio, amp_control.active);
|
||||
if (amp_control.gpio != -1) gpio_set_level_x(amp_control.gpio, amp_control.active);
|
||||
adac->speaker(true);
|
||||
}
|
||||
led_on(LED_GREEN);
|
||||
@@ -493,7 +493,20 @@ static void output_thread_i2s(void *arg) {
|
||||
_output_frames( iframes );
|
||||
// oframes must be a global updated by the write callback
|
||||
output.frames_in_process = oframes;
|
||||
|
||||
|
||||
/*
|
||||
{
|
||||
ISAMPLE_T *ptr = (ISAMPLE_T*) obuf;
|
||||
for (int i = 0; i < oframes; i++) {
|
||||
*ptr++ = 0; // L
|
||||
#if BYTES_PER_FRAME == 8
|
||||
*ptr++ = rand() >> 4; // R
|
||||
#else
|
||||
*ptr++ = (rand() % 65536) >> 4; // R
|
||||
#endif
|
||||
}
|
||||
}
|
||||
*/
|
||||
SET_MIN_MAX_SIZED(oframes,rec,iframes);
|
||||
SET_MIN_MAX_SIZED(_buf_used(outputbuf),o,outputbuf->size);
|
||||
SET_MIN_MAX_SIZED(_buf_used(streambuf),s,streambuf->size);
|
||||
|
||||
Reference in New Issue
Block a user