esphome 2024.10.3__py3-none-any.whl → 2024.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esphome/__main__.py +22 -4
- esphome/automation.py +29 -2
- esphome/components/animation/__init__.py +5 -8
- esphome/components/animation/animation.cpp +1 -1
- esphome/components/audio/__init__.py +9 -0
- esphome/components/audio/audio.h +21 -0
- esphome/components/axs15231/__init__.py +6 -0
- esphome/components/axs15231/touchscreen/__init__.py +36 -0
- esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp +64 -0
- esphome/components/axs15231/touchscreen/axs15231_touchscreen.h +27 -0
- esphome/components/bme68x_bsec2/__init__.py +1 -1
- esphome/components/bme68x_bsec2/bme68x_bsec2.cpp +50 -47
- esphome/components/bme68x_bsec2/bme68x_bsec2.h +0 -2
- esphome/components/bytebuffer/__init__.py +5 -0
- esphome/components/bytebuffer/bytebuffer.h +421 -0
- esphome/components/climate/__init__.py +14 -13
- esphome/components/datetime/__init__.py +3 -3
- esphome/components/debug/debug_esp32.cpp +16 -8
- esphome/components/dfplayer/dfplayer.cpp +132 -6
- esphome/components/dfplayer/dfplayer.h +19 -53
- esphome/components/display/display.cpp +142 -0
- esphome/components/display/display.h +7 -0
- esphome/components/es8311/__init__.py +0 -0
- esphome/components/es8311/audio_dac.py +70 -0
- esphome/components/es8311/es8311.cpp +227 -0
- esphome/components/es8311/es8311.h +135 -0
- esphome/components/es8311/es8311_const.h +195 -0
- esphome/components/esp32/boards.py +199 -1
- esphome/components/esp32/gpio.py +3 -1
- esphome/components/esp32_ble/const_esp32c6.h +7 -0
- esphome/components/esp32_ble_client/ble_client_base.h +1 -1
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +3 -0
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +2 -1
- esphome/components/esp32_rmt_led_strip/led_strip.cpp +2 -2
- esphome/components/esp32_rmt_led_strip/led_strip.h +2 -0
- esphome/components/esp32_rmt_led_strip/light.py +3 -1
- esphome/components/esp8266/gpio.py +7 -5
- esphome/components/ethernet/__init__.py +55 -1
- esphome/components/ethernet/ethernet_component.cpp +14 -1
- esphome/components/ethernet/ethernet_component.h +7 -1
- esphome/components/font/__init__.py +213 -108
- esphome/components/gp8403/output/__init__.py +1 -1
- esphome/components/host/gpio.py +6 -4
- esphome/components/http_request/__init__.py +12 -0
- esphome/components/http_request/http_request.h +65 -3
- esphome/components/http_request/http_request_arduino.cpp +4 -3
- esphome/components/http_request/http_request_idf.cpp +12 -14
- esphome/components/http_request/ota/ota_http_request.cpp +1 -1
- esphome/components/http_request/update/http_request_update.cpp +1 -1
- esphome/components/i2c_device/__init__.py +26 -0
- esphome/components/i2c_device/i2c_device.cpp +17 -0
- esphome/components/i2c_device/i2c_device.h +18 -0
- esphome/components/i2s_audio/__init__.py +1 -3
- esphome/components/i2s_audio/speaker/__init__.py +12 -4
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +426 -200
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +92 -33
- esphome/components/ili9xxx/display.py +5 -1
- esphome/components/image/__init__.py +5 -8
- esphome/components/image/image.cpp +14 -14
- esphome/components/image/image.h +20 -24
- esphome/components/internal_temperature/internal_temperature.cpp +51 -2
- esphome/components/internal_temperature/internal_temperature.h +1 -0
- esphome/components/ld2420/ld2420.cpp +1 -1
- esphome/components/libretiny/gpio.py +4 -2
- esphome/components/light/__init__.py +32 -1
- esphome/components/light/automation.py +39 -32
- esphome/components/light/effects.py +36 -36
- esphome/components/light/light_state.cpp +6 -16
- esphome/components/light/light_state.h +34 -0
- esphome/components/light/types.py +3 -1
- esphome/components/logger/logger_esp32.cpp +15 -0
- esphome/components/lvgl/__init__.py +202 -95
- esphome/components/lvgl/automation.py +42 -40
- esphome/components/lvgl/binary_sensor/__init__.py +8 -15
- esphome/components/lvgl/defines.py +14 -8
- esphome/components/lvgl/encoders.py +11 -8
- esphome/components/lvgl/keypads.py +77 -0
- esphome/components/lvgl/light/__init__.py +6 -8
- esphome/components/lvgl/lv_validation.py +2 -4
- esphome/components/lvgl/lvcode.py +3 -9
- esphome/components/lvgl/lvgl_esphome.cpp +210 -89
- esphome/components/lvgl/lvgl_esphome.h +113 -30
- esphome/components/lvgl/lvgl_proxy.h +17 -0
- esphome/components/lvgl/number/__init__.py +10 -15
- esphome/components/lvgl/schemas.py +4 -2
- esphome/components/lvgl/select/__init__.py +12 -37
- esphome/components/lvgl/select/lvgl_select.h +27 -33
- esphome/components/lvgl/sensor/__init__.py +8 -14
- esphome/components/lvgl/styles.py +3 -4
- esphome/components/lvgl/switch/__init__.py +8 -13
- esphome/components/lvgl/text/__init__.py +5 -6
- esphome/components/lvgl/text_sensor/__init__.py +15 -15
- esphome/components/lvgl/touchscreens.py +2 -3
- esphome/components/lvgl/trigger.py +7 -9
- esphome/components/lvgl/types.py +9 -3
- esphome/components/lvgl/widgets/__init__.py +32 -21
- esphome/components/lvgl/widgets/dropdown.py +22 -10
- esphome/components/lvgl/widgets/msgbox.py +6 -5
- esphome/components/lvgl/widgets/obj.py +4 -2
- esphome/components/lvgl/widgets/page.py +3 -2
- esphome/components/lvgl/widgets/qrcode.py +54 -0
- esphome/components/lvgl/widgets/roller.py +21 -14
- esphome/components/lvgl/widgets/tileview.py +2 -1
- esphome/components/max17043/__init__.py +1 -0
- esphome/components/max17043/automation.h +20 -0
- esphome/components/max17043/max17043.cpp +98 -0
- esphome/components/max17043/max17043.h +29 -0
- esphome/components/max17043/sensor.py +77 -0
- esphome/components/media_player/__init__.py +11 -0
- esphome/components/media_player/automation.h +10 -0
- esphome/components/media_player/media_player.cpp +4 -0
- esphome/components/midea/air_conditioner.cpp +17 -1
- esphome/components/mlx90393/sensor.py +1 -1
- esphome/components/modbus_controller/__init__.py +31 -1
- esphome/components/modbus_controller/automation.h +16 -0
- esphome/components/modbus_controller/const.py +2 -0
- esphome/components/modbus_controller/modbus_controller.cpp +14 -2
- esphome/components/modbus_controller/modbus_controller.h +9 -0
- esphome/components/mopeka_pro_check/mopeka_pro_check.cpp +40 -21
- esphome/components/mopeka_pro_check/mopeka_pro_check.h +9 -2
- esphome/components/mopeka_pro_check/sensor.py +41 -0
- esphome/components/mqtt/__init__.py +36 -0
- esphome/components/mqtt/mqtt_client.cpp +27 -3
- esphome/components/mqtt/mqtt_client.h +27 -2
- esphome/components/mqtt/mqtt_climate.cpp +4 -2
- esphome/components/mqtt/mqtt_component.cpp +6 -0
- esphome/components/mqtt/mqtt_component.h +4 -0
- esphome/components/mqtt/mqtt_const.h +6 -0
- esphome/components/online_image/online_image.cpp +2 -8
- esphome/components/online_image/online_image.h +2 -6
- esphome/components/opentherm/__init__.py +35 -9
- esphome/components/opentherm/binary_sensor/__init__.py +33 -0
- esphome/components/opentherm/const.py +11 -0
- esphome/components/opentherm/generate.py +142 -0
- esphome/components/opentherm/hub.cpp +130 -24
- esphome/components/opentherm/hub.h +62 -9
- esphome/components/opentherm/input.h +18 -0
- esphome/components/opentherm/input.py +51 -0
- esphome/components/opentherm/number/__init__.py +74 -0
- esphome/components/opentherm/number/number.cpp +40 -0
- esphome/components/opentherm/number/number.h +31 -0
- esphome/components/opentherm/opentherm.cpp +30 -0
- esphome/components/opentherm/opentherm.h +34 -2
- esphome/components/opentherm/opentherm_macros.h +151 -0
- esphome/components/opentherm/output/__init__.py +47 -0
- esphome/components/opentherm/output/output.cpp +18 -0
- esphome/components/opentherm/output/output.h +33 -0
- esphome/components/opentherm/schema.py +814 -0
- esphome/components/opentherm/sensor/__init__.py +51 -0
- esphome/components/opentherm/switch/__init__.py +43 -0
- esphome/components/opentherm/switch/switch.cpp +28 -0
- esphome/components/opentherm/switch/switch.h +20 -0
- esphome/components/opentherm/validate.py +31 -0
- esphome/components/pcd8544/display.py +8 -4
- esphome/components/prometheus/prometheus_handler.cpp +176 -14
- esphome/components/prometheus/prometheus_handler.h +25 -7
- esphome/components/qspi_amoled/display.py +1 -141
- esphome/components/qspi_dbi/display.py +185 -0
- esphome/components/qspi_dbi/models.py +64 -0
- esphome/components/{qspi_amoled/qspi_amoled.cpp → qspi_dbi/qspi_dbi.cpp} +95 -46
- esphome/components/{qspi_amoled/qspi_amoled.h → qspi_dbi/qspi_dbi.h} +26 -15
- esphome/components/rp2040/__init__.py +6 -3
- esphome/components/rp2040/gpio.py +5 -3
- esphome/components/rtttl/rtttl.cpp +4 -1
- esphome/components/rtttl/rtttl.h +1 -0
- esphome/components/sdl/sdl_esphome.cpp +22 -5
- esphome/components/sdl/sdl_esphome.h +1 -0
- esphome/components/sdm_meter/sdm_meter.cpp +1 -1
- esphome/components/sensor/__init__.py +18 -8
- esphome/components/sensor/filter.cpp +19 -18
- esphome/components/sensor/filter.h +9 -10
- esphome/components/sgp4x/sgp4x.cpp +40 -74
- esphome/components/sgp4x/sgp4x.h +5 -3
- esphome/components/speaker/__init__.py +51 -5
- esphome/components/speaker/automation.h +25 -0
- esphome/components/speaker/speaker.h +72 -1
- esphome/components/spi/__init__.py +15 -14
- esphome/components/spi_device/__init__.py +4 -15
- esphome/components/ssd1306_spi/display.py +6 -2
- esphome/components/ssd1322_spi/display.py +6 -2
- esphome/components/ssd1325_spi/display.py +6 -2
- esphome/components/ssd1327_spi/display.py +6 -2
- esphome/components/ssd1331_spi/display.py +6 -2
- esphome/components/ssd1351_spi/display.py +6 -2
- esphome/components/st7567_spi/display.py +6 -2
- esphome/components/st7701s/display.py +5 -1
- esphome/components/st7735/display.py +10 -5
- esphome/components/st7789v/display.py +12 -7
- esphome/components/statsd/statsd.cpp +2 -0
- esphome/components/statsd/statsd.h +2 -0
- esphome/components/sun/sun.h +3 -0
- esphome/components/tc74/__init__.py +1 -0
- esphome/components/tc74/sensor.py +32 -0
- esphome/components/tc74/tc74.cpp +68 -0
- esphome/components/tc74/tc74.h +28 -0
- esphome/components/touchscreen/__init__.py +41 -50
- esphome/components/touchscreen/touchscreen.h +4 -8
- esphome/components/tuya/fan/tuya_fan.cpp +1 -1
- esphome/components/udp/udp_component.cpp +6 -3
- esphome/components/udp/udp_component.h +4 -2
- esphome/components/waveshare_epaper/display.py +6 -2
- esphome/components/web_server/web_server.cpp +22 -0
- esphome/components/web_server/web_server.h +3 -0
- esphome/components/weikai/weikai.h +2 -2
- esphome/components/wifi/wifi_component.cpp +2 -2
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +4 -4
- esphome/components/wifi/wifi_component_esp8266.cpp +4 -4
- esphome/components/wifi/wifi_component_esp_idf.cpp +2 -2
- esphome/components/xpt2046/touchscreen/__init__.py +7 -32
- esphome/config_validation.py +3 -1
- esphome/const.py +9 -2
- esphome/core/defines.h +8 -2
- esphome/core/helpers.cpp +32 -17
- esphome/core/helpers.h +32 -16
- esphome/core/ring_buffer.cpp +2 -2
- esphome/core/ring_buffer.h +2 -2
- esphome/dashboard/core.py +25 -0
- esphome/dashboard/status/mdns.py +3 -4
- esphome/dashboard/web_server.py +54 -19
- esphome/espota2.py +36 -35
- esphome/helpers.py +68 -16
- esphome/mqtt.py +9 -2
- esphome/storage_json.py +4 -0
- esphome/writer.py +7 -18
- esphome/zeroconf.py +8 -6
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/METADATA +7 -5
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/RECORD +232 -186
- esphome/core/bytebuffer.cpp +0 -167
- esphome/core/bytebuffer.h +0 -144
- /esphome/components/{qspi_amoled → qspi_dbi}/__init__.py +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/LICENSE +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/WHEEL +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/entry_points.txt +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,104 @@ namespace dfplayer {
|
|
6
6
|
|
7
7
|
static const char *const TAG = "dfplayer";
|
8
8
|
|
9
|
+
void DFPlayer::next() {
|
10
|
+
this->ack_set_is_playing_ = true;
|
11
|
+
ESP_LOGD(TAG, "Playing next track");
|
12
|
+
this->send_cmd_(0x01);
|
13
|
+
}
|
14
|
+
|
15
|
+
void DFPlayer::previous() {
|
16
|
+
this->ack_set_is_playing_ = true;
|
17
|
+
ESP_LOGD(TAG, "Playing previous track");
|
18
|
+
this->send_cmd_(0x02);
|
19
|
+
}
|
20
|
+
void DFPlayer::play_mp3(uint16_t file) {
|
21
|
+
this->ack_set_is_playing_ = true;
|
22
|
+
ESP_LOGD(TAG, "Playing file %d in mp3 folder", file);
|
23
|
+
this->send_cmd_(0x12, file);
|
24
|
+
}
|
25
|
+
|
26
|
+
void DFPlayer::play_file(uint16_t file) {
|
27
|
+
this->ack_set_is_playing_ = true;
|
28
|
+
ESP_LOGD(TAG, "Playing file %d", file);
|
29
|
+
this->send_cmd_(0x03, file);
|
30
|
+
}
|
31
|
+
|
32
|
+
void DFPlayer::play_file_loop(uint16_t file) {
|
33
|
+
this->ack_set_is_playing_ = true;
|
34
|
+
ESP_LOGD(TAG, "Playing file %d in loop", file);
|
35
|
+
this->send_cmd_(0x08, file);
|
36
|
+
}
|
37
|
+
|
38
|
+
void DFPlayer::play_folder_loop(uint16_t folder) {
|
39
|
+
this->ack_set_is_playing_ = true;
|
40
|
+
ESP_LOGD(TAG, "Playing folder %d in loop", folder);
|
41
|
+
this->send_cmd_(0x17, folder);
|
42
|
+
}
|
43
|
+
|
44
|
+
void DFPlayer::volume_up() {
|
45
|
+
ESP_LOGD(TAG, "Increasing volume");
|
46
|
+
this->send_cmd_(0x04);
|
47
|
+
}
|
48
|
+
|
49
|
+
void DFPlayer::volume_down() {
|
50
|
+
ESP_LOGD(TAG, "Decreasing volume");
|
51
|
+
this->send_cmd_(0x05);
|
52
|
+
}
|
53
|
+
|
54
|
+
void DFPlayer::set_device(Device device) {
|
55
|
+
ESP_LOGD(TAG, "Setting device to %d", device);
|
56
|
+
this->send_cmd_(0x09, device);
|
57
|
+
}
|
58
|
+
|
59
|
+
void DFPlayer::set_volume(uint8_t volume) {
|
60
|
+
ESP_LOGD(TAG, "Setting volume to %d", volume);
|
61
|
+
this->send_cmd_(0x06, volume);
|
62
|
+
}
|
63
|
+
|
64
|
+
void DFPlayer::set_eq(EqPreset preset) {
|
65
|
+
ESP_LOGD(TAG, "Setting EQ to %d", preset);
|
66
|
+
this->send_cmd_(0x07, preset);
|
67
|
+
}
|
68
|
+
|
69
|
+
void DFPlayer::sleep() {
|
70
|
+
this->ack_reset_is_playing_ = true;
|
71
|
+
ESP_LOGD(TAG, "Putting DFPlayer to sleep");
|
72
|
+
this->send_cmd_(0x0A);
|
73
|
+
}
|
74
|
+
|
75
|
+
void DFPlayer::reset() {
|
76
|
+
this->ack_reset_is_playing_ = true;
|
77
|
+
ESP_LOGD(TAG, "Resetting DFPlayer");
|
78
|
+
this->send_cmd_(0x0C);
|
79
|
+
}
|
80
|
+
|
81
|
+
void DFPlayer::start() {
|
82
|
+
this->ack_set_is_playing_ = true;
|
83
|
+
ESP_LOGD(TAG, "Starting playback");
|
84
|
+
this->send_cmd_(0x0D);
|
85
|
+
}
|
86
|
+
|
87
|
+
void DFPlayer::pause() {
|
88
|
+
this->ack_reset_is_playing_ = true;
|
89
|
+
ESP_LOGD(TAG, "Pausing playback");
|
90
|
+
this->send_cmd_(0x0E);
|
91
|
+
}
|
92
|
+
|
93
|
+
void DFPlayer::stop() {
|
94
|
+
this->ack_reset_is_playing_ = true;
|
95
|
+
ESP_LOGD(TAG, "Stopping playback");
|
96
|
+
this->send_cmd_(0x16);
|
97
|
+
}
|
98
|
+
|
99
|
+
void DFPlayer::random() {
|
100
|
+
this->ack_set_is_playing_ = true;
|
101
|
+
ESP_LOGD(TAG, "Playing random file");
|
102
|
+
this->send_cmd_(0x18);
|
103
|
+
}
|
104
|
+
|
9
105
|
void DFPlayer::play_folder(uint16_t folder, uint16_t file) {
|
106
|
+
ESP_LOGD(TAG, "Playing file %d in folder %d", file, folder);
|
10
107
|
if (folder < 100 && file < 256) {
|
11
108
|
this->ack_set_is_playing_ = true;
|
12
109
|
this->send_cmd_(0x0F, (uint8_t) folder, (uint8_t) file);
|
@@ -29,7 +126,7 @@ void DFPlayer::send_cmd_(uint8_t cmd, uint16_t argument) {
|
|
29
126
|
|
30
127
|
this->sent_cmd_ = cmd;
|
31
128
|
|
32
|
-
|
129
|
+
ESP_LOGV(TAG, "Send Command %#02x arg %#04x", cmd, argument);
|
33
130
|
this->write_array(buffer, 10);
|
34
131
|
}
|
35
132
|
|
@@ -101,9 +198,37 @@ void DFPlayer::loop() {
|
|
101
198
|
ESP_LOGV(TAG, "Nack");
|
102
199
|
this->ack_set_is_playing_ = false;
|
103
200
|
this->ack_reset_is_playing_ = false;
|
104
|
-
|
105
|
-
|
106
|
-
|
201
|
+
switch (argument) {
|
202
|
+
case 0x01:
|
203
|
+
ESP_LOGE(TAG, "Module is busy or uninitialized");
|
204
|
+
break;
|
205
|
+
case 0x02:
|
206
|
+
ESP_LOGE(TAG, "Module is in sleep mode");
|
207
|
+
break;
|
208
|
+
case 0x03:
|
209
|
+
ESP_LOGE(TAG, "Serial receive error");
|
210
|
+
break;
|
211
|
+
case 0x04:
|
212
|
+
ESP_LOGE(TAG, "Checksum incorrect");
|
213
|
+
break;
|
214
|
+
case 0x05:
|
215
|
+
ESP_LOGE(TAG, "Specified track is out of current track scope");
|
216
|
+
this->is_playing_ = false;
|
217
|
+
break;
|
218
|
+
case 0x06:
|
219
|
+
ESP_LOGE(TAG, "Specified track is not found");
|
220
|
+
this->is_playing_ = false;
|
221
|
+
break;
|
222
|
+
case 0x07:
|
223
|
+
ESP_LOGE(TAG, "Insertion error (an inserting operation only can be done when a track is being played)");
|
224
|
+
break;
|
225
|
+
case 0x08:
|
226
|
+
ESP_LOGE(TAG, "SD card reading failed (SD card pulled out or damaged)");
|
227
|
+
break;
|
228
|
+
case 0x09:
|
229
|
+
ESP_LOGE(TAG, "Entered into sleep mode");
|
230
|
+
this->is_playing_ = false;
|
231
|
+
break;
|
107
232
|
}
|
108
233
|
break;
|
109
234
|
case 0x41:
|
@@ -113,12 +238,13 @@ void DFPlayer::loop() {
|
|
113
238
|
this->ack_set_is_playing_ = false;
|
114
239
|
this->ack_reset_is_playing_ = false;
|
115
240
|
break;
|
116
|
-
case 0x3D:
|
241
|
+
case 0x3D:
|
242
|
+
ESP_LOGV(TAG, "Playback finished");
|
117
243
|
this->is_playing_ = false;
|
118
244
|
this->on_finished_playback_callback_.call();
|
119
245
|
break;
|
120
246
|
default:
|
121
|
-
|
247
|
+
ESP_LOGV(TAG, "Received unknown cmd %#02x arg %#04x", cmd, argument);
|
122
248
|
}
|
123
249
|
this->sent_cmd_ = 0;
|
124
250
|
this->read_pos_ = 0;
|
@@ -23,64 +23,30 @@ enum Device {
|
|
23
23
|
TF_CARD = 2,
|
24
24
|
};
|
25
25
|
|
26
|
+
// See the datasheet here:
|
27
|
+
// https://github.com/DFRobot/DFRobotDFPlayerMini/blob/master/doc/FN-M16P%2BEmbedded%2BMP3%2BAudio%2BModule%2BDatasheet.pdf
|
26
28
|
class DFPlayer : public uart::UARTDevice, public Component {
|
27
29
|
public:
|
28
30
|
void loop() override;
|
29
31
|
|
30
|
-
void next()
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
void
|
35
|
-
this->ack_set_is_playing_ = true;
|
36
|
-
this->send_cmd_(0x02);
|
37
|
-
}
|
38
|
-
void play_mp3(uint16_t file) {
|
39
|
-
this->ack_set_is_playing_ = true;
|
40
|
-
this->send_cmd_(0x12, file);
|
41
|
-
}
|
42
|
-
void play_file(uint16_t file) {
|
43
|
-
this->ack_set_is_playing_ = true;
|
44
|
-
this->send_cmd_(0x03, file);
|
45
|
-
}
|
46
|
-
void play_file_loop(uint16_t file) {
|
47
|
-
this->ack_set_is_playing_ = true;
|
48
|
-
this->send_cmd_(0x08, file);
|
49
|
-
}
|
32
|
+
void next();
|
33
|
+
void previous();
|
34
|
+
void play_mp3(uint16_t file);
|
35
|
+
void play_file(uint16_t file);
|
36
|
+
void play_file_loop(uint16_t file);
|
50
37
|
void play_folder(uint16_t folder, uint16_t file);
|
51
|
-
void play_folder_loop(uint16_t folder)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
void
|
56
|
-
void
|
57
|
-
void
|
58
|
-
void
|
59
|
-
void
|
60
|
-
void
|
61
|
-
|
62
|
-
|
63
|
-
}
|
64
|
-
void reset() {
|
65
|
-
this->ack_reset_is_playing_ = true;
|
66
|
-
this->send_cmd_(0x0C);
|
67
|
-
}
|
68
|
-
void start() {
|
69
|
-
this->ack_set_is_playing_ = true;
|
70
|
-
this->send_cmd_(0x0D);
|
71
|
-
}
|
72
|
-
void pause() {
|
73
|
-
this->ack_reset_is_playing_ = true;
|
74
|
-
this->send_cmd_(0x0E);
|
75
|
-
}
|
76
|
-
void stop() {
|
77
|
-
this->ack_reset_is_playing_ = true;
|
78
|
-
this->send_cmd_(0x16);
|
79
|
-
}
|
80
|
-
void random() {
|
81
|
-
this->ack_set_is_playing_ = true;
|
82
|
-
this->send_cmd_(0x18);
|
83
|
-
}
|
38
|
+
void play_folder_loop(uint16_t folder);
|
39
|
+
void volume_up();
|
40
|
+
void volume_down();
|
41
|
+
void set_device(Device device);
|
42
|
+
void set_volume(uint8_t volume);
|
43
|
+
void set_eq(EqPreset preset);
|
44
|
+
void sleep();
|
45
|
+
void reset();
|
46
|
+
void start();
|
47
|
+
void pause();
|
48
|
+
void stop();
|
49
|
+
void random();
|
84
50
|
|
85
51
|
bool is_playing() { return is_playing_; }
|
86
52
|
void dump_config() override;
|
@@ -156,6 +156,148 @@ void Display::filled_circle(int center_x, int center_y, int radius, Color color)
|
|
156
156
|
}
|
157
157
|
} while (dx <= 0);
|
158
158
|
}
|
159
|
+
void Display::filled_ring(int center_x, int center_y, int radius1, int radius2, Color color) {
|
160
|
+
int rmax = radius1 > radius2 ? radius1 : radius2;
|
161
|
+
int rmin = radius1 < radius2 ? radius1 : radius2;
|
162
|
+
int dxmax = -int32_t(rmax), dxmin = -int32_t(rmin);
|
163
|
+
int dymax = 0, dymin = 0;
|
164
|
+
int errmax = 2 - 2 * rmax, errmin = 2 - 2 * rmin;
|
165
|
+
int e2max, e2min;
|
166
|
+
do {
|
167
|
+
// 8 dots for borders
|
168
|
+
this->draw_pixel_at(center_x - dxmax, center_y + dymax, color);
|
169
|
+
this->draw_pixel_at(center_x + dxmax, center_y + dymax, color);
|
170
|
+
this->draw_pixel_at(center_x - dxmin, center_y + dymin, color);
|
171
|
+
this->draw_pixel_at(center_x + dxmin, center_y + dymin, color);
|
172
|
+
this->draw_pixel_at(center_x + dxmax, center_y - dymax, color);
|
173
|
+
this->draw_pixel_at(center_x - dxmax, center_y - dymax, color);
|
174
|
+
this->draw_pixel_at(center_x + dxmin, center_y - dymin, color);
|
175
|
+
this->draw_pixel_at(center_x - dxmin, center_y - dymin, color);
|
176
|
+
if (dymin < rmin) {
|
177
|
+
// two parts - four lines
|
178
|
+
int hline_width = -(dxmax - dxmin) + 1;
|
179
|
+
this->horizontal_line(center_x + dxmax, center_y + dymax, hline_width, color);
|
180
|
+
this->horizontal_line(center_x - dxmin, center_y + dymax, hline_width, color);
|
181
|
+
this->horizontal_line(center_x + dxmax, center_y - dymax, hline_width, color);
|
182
|
+
this->horizontal_line(center_x - dxmin, center_y - dymax, hline_width, color);
|
183
|
+
} else {
|
184
|
+
// one part - top and bottom
|
185
|
+
int hline_width = 2 * (-dxmax) + 1;
|
186
|
+
this->horizontal_line(center_x + dxmax, center_y + dymax, hline_width, color);
|
187
|
+
this->horizontal_line(center_x + dxmax, center_y - dymax, hline_width, color);
|
188
|
+
}
|
189
|
+
e2max = errmax;
|
190
|
+
// tune external
|
191
|
+
if (e2max < dymax) {
|
192
|
+
errmax += ++dymax * 2 + 1;
|
193
|
+
if (-dxmax == dymax && e2max <= dxmax) {
|
194
|
+
e2max = 0;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
if (e2max > dxmax) {
|
198
|
+
errmax += ++dxmax * 2 + 1;
|
199
|
+
}
|
200
|
+
// tune internal
|
201
|
+
while (dymin < dymax && dymin < rmin) {
|
202
|
+
e2min = errmin;
|
203
|
+
if (e2min < dymin) {
|
204
|
+
errmin += ++dymin * 2 + 1;
|
205
|
+
if (-dxmin == dymin && e2min <= dxmin) {
|
206
|
+
e2min = 0;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
if (e2min > dxmin) {
|
210
|
+
errmin += ++dxmin * 2 + 1;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
} while (dxmax <= 0);
|
214
|
+
}
|
215
|
+
void Display::filled_gauge(int center_x, int center_y, int radius1, int radius2, int progress, Color color) {
|
216
|
+
int rmax = radius1 > radius2 ? radius1 : radius2;
|
217
|
+
int rmin = radius1 < radius2 ? radius1 : radius2;
|
218
|
+
int dxmax = -int32_t(rmax), dxmin = -int32_t(rmin), upd_dxmax, upd_dxmin;
|
219
|
+
int dymax = 0, dymin = 0;
|
220
|
+
int errmax = 2 - 2 * rmax, errmin = 2 - 2 * rmin;
|
221
|
+
int e2max, e2min;
|
222
|
+
progress = std::max(0, std::min(progress, 100)); // 0..100
|
223
|
+
int draw_progress = progress > 50 ? (100 - progress) : progress;
|
224
|
+
float tan_a = (progress == 50) ? 65535 : tan(float(draw_progress) * M_PI / 100); // slope
|
225
|
+
|
226
|
+
do {
|
227
|
+
// outer dots
|
228
|
+
this->draw_pixel_at(center_x + dxmax, center_y - dymax, color);
|
229
|
+
this->draw_pixel_at(center_x - dxmax, center_y - dymax, color);
|
230
|
+
if (dymin < rmin) { // side parts
|
231
|
+
int lhline_width = -(dxmax - dxmin) + 1;
|
232
|
+
if (progress >= 50) {
|
233
|
+
if (float(dymax) < float(-dxmax) * tan_a) {
|
234
|
+
upd_dxmax = ceil(float(dymax) / tan_a);
|
235
|
+
} else {
|
236
|
+
upd_dxmax = -dxmax;
|
237
|
+
}
|
238
|
+
this->horizontal_line(center_x + dxmax, center_y - dymax, lhline_width, color); // left
|
239
|
+
if (!dymax)
|
240
|
+
this->horizontal_line(center_x - dxmin, center_y, lhline_width, color); // right horizontal border
|
241
|
+
if (upd_dxmax > -dxmin) { // right
|
242
|
+
int rhline_width = (upd_dxmax + dxmin) + 1;
|
243
|
+
this->horizontal_line(center_x - dxmin, center_y - dymax,
|
244
|
+
rhline_width > lhline_width ? lhline_width : rhline_width, color);
|
245
|
+
}
|
246
|
+
} else {
|
247
|
+
if (float(dymin) > float(-dxmin) * tan_a) {
|
248
|
+
upd_dxmin = ceil(float(dymin) / tan_a);
|
249
|
+
} else {
|
250
|
+
upd_dxmin = -dxmin;
|
251
|
+
}
|
252
|
+
lhline_width = -(dxmax + upd_dxmin) + 1;
|
253
|
+
if (!dymax)
|
254
|
+
this->horizontal_line(center_x - dxmin, center_y, lhline_width, color); // right horizontal border
|
255
|
+
if (lhline_width > 0)
|
256
|
+
this->horizontal_line(center_x + dxmax, center_y - dymax, lhline_width, color);
|
257
|
+
}
|
258
|
+
} else { // top part
|
259
|
+
int hline_width = 2 * (-dxmax) + 1;
|
260
|
+
if (progress >= 50) {
|
261
|
+
if (dymax < float(-dxmax) * tan_a) {
|
262
|
+
upd_dxmax = ceil(float(dymax) / tan_a);
|
263
|
+
hline_width = -dxmax + upd_dxmax + 1;
|
264
|
+
}
|
265
|
+
} else {
|
266
|
+
if (dymax < float(-dxmax) * tan_a) {
|
267
|
+
upd_dxmax = ceil(float(dymax) / tan_a);
|
268
|
+
hline_width = -dxmax - upd_dxmax + 1;
|
269
|
+
} else
|
270
|
+
hline_width = 0;
|
271
|
+
}
|
272
|
+
if (hline_width > 0)
|
273
|
+
this->horizontal_line(center_x + dxmax, center_y - dymax, hline_width, color);
|
274
|
+
}
|
275
|
+
e2max = errmax;
|
276
|
+
if (e2max < dymax) {
|
277
|
+
errmax += ++dymax * 2 + 1;
|
278
|
+
if (-dxmax == dymax && e2max <= dxmax) {
|
279
|
+
e2max = 0;
|
280
|
+
}
|
281
|
+
}
|
282
|
+
if (e2max > dxmax) {
|
283
|
+
errmax += ++dxmax * 2 + 1;
|
284
|
+
}
|
285
|
+
while (dymin <= dymax && dymin <= rmin && dxmin <= 0) {
|
286
|
+
this->draw_pixel_at(center_x + dxmin, center_y - dymin, color);
|
287
|
+
this->draw_pixel_at(center_x - dxmin, center_y - dymin, color);
|
288
|
+
e2min = errmin;
|
289
|
+
if (e2min < dymin) {
|
290
|
+
errmin += ++dymin * 2 + 1;
|
291
|
+
if (-dxmin == dymin && e2min <= dxmin) {
|
292
|
+
e2min = 0;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
if (e2min > dxmin) {
|
296
|
+
errmin += ++dxmin * 2 + 1;
|
297
|
+
}
|
298
|
+
}
|
299
|
+
} while (dxmax <= 0);
|
300
|
+
}
|
159
301
|
void HOT Display::triangle(int x1, int y1, int x2, int y2, int x3, int y3, Color color) {
|
160
302
|
this->line(x1, y1, x2, y2, color);
|
161
303
|
this->line(x1, y1, x3, y3, color);
|
@@ -285,6 +285,13 @@ class Display : public PollingComponent {
|
|
285
285
|
/// Fill a circle centered around [center_x,center_y] with the radius radius with the given color.
|
286
286
|
void filled_circle(int center_x, int center_y, int radius, Color color = COLOR_ON);
|
287
287
|
|
288
|
+
/// Fill a ring centered around [center_x,center_y] between two circles with the radius1 and radius2 with the given
|
289
|
+
/// color.
|
290
|
+
void filled_ring(int center_x, int center_y, int radius1, int radius2, Color color = COLOR_ON);
|
291
|
+
/// Fill a half-ring "gauge" centered around [center_x,center_y] between two circles with the radius1 and radius2
|
292
|
+
/// with he given color and filled up to 'progress' percent
|
293
|
+
void filled_gauge(int center_x, int center_y, int radius1, int radius2, int progress, Color color = COLOR_ON);
|
294
|
+
|
288
295
|
/// Draw the outline of a triangle contained between the points [x1,y1], [x2,y2] and [x3,y3] with the given color.
|
289
296
|
void triangle(int x1, int y1, int x2, int y2, int x3, int y3, Color color = COLOR_ON);
|
290
297
|
|
File without changes
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
from esphome.components import i2c
|
3
|
+
from esphome.components.audio_dac import AudioDac
|
4
|
+
import esphome.config_validation as cv
|
5
|
+
from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_SAMPLE_RATE
|
6
|
+
|
7
|
+
CODEOWNERS = ["@kroimon", "@kahrendt"]
|
8
|
+
DEPENDENCIES = ["i2c"]
|
9
|
+
|
10
|
+
es8311_ns = cg.esphome_ns.namespace("es8311")
|
11
|
+
ES8311 = es8311_ns.class_("ES8311", AudioDac, cg.Component, i2c.I2CDevice)
|
12
|
+
|
13
|
+
CONF_MIC_GAIN = "mic_gain"
|
14
|
+
CONF_USE_MCLK = "use_mclk"
|
15
|
+
CONF_USE_MICROPHONE = "use_microphone"
|
16
|
+
|
17
|
+
es8311_resolution = es8311_ns.enum("ES8311Resolution")
|
18
|
+
ES8311_BITS_PER_SAMPLE_ENUM = {
|
19
|
+
16: es8311_resolution.ES8311_RESOLUTION_16,
|
20
|
+
24: es8311_resolution.ES8311_RESOLUTION_24,
|
21
|
+
32: es8311_resolution.ES8311_RESOLUTION_32,
|
22
|
+
}
|
23
|
+
|
24
|
+
es8311_mic_gain = es8311_ns.enum("ES8311MicGain")
|
25
|
+
ES8311_MIC_GAIN_ENUM = {
|
26
|
+
"MIN": es8311_mic_gain.ES8311_MIC_GAIN_MIN,
|
27
|
+
"0DB": es8311_mic_gain.ES8311_MIC_GAIN_0DB,
|
28
|
+
"6DB": es8311_mic_gain.ES8311_MIC_GAIN_6DB,
|
29
|
+
"12DB": es8311_mic_gain.ES8311_MIC_GAIN_12DB,
|
30
|
+
"18DB": es8311_mic_gain.ES8311_MIC_GAIN_18DB,
|
31
|
+
"24DB": es8311_mic_gain.ES8311_MIC_GAIN_24DB,
|
32
|
+
"30DB": es8311_mic_gain.ES8311_MIC_GAIN_30DB,
|
33
|
+
"36DB": es8311_mic_gain.ES8311_MIC_GAIN_36DB,
|
34
|
+
"42DB": es8311_mic_gain.ES8311_MIC_GAIN_42DB,
|
35
|
+
"MAX": es8311_mic_gain.ES8311_MIC_GAIN_MAX,
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
_validate_bits = cv.float_with_unit("bits", "bit")
|
40
|
+
|
41
|
+
CONFIG_SCHEMA = (
|
42
|
+
cv.Schema(
|
43
|
+
{
|
44
|
+
cv.GenerateID(): cv.declare_id(ES8311),
|
45
|
+
cv.Optional(CONF_BITS_PER_SAMPLE, default="16bit"): cv.All(
|
46
|
+
_validate_bits, cv.enum(ES8311_BITS_PER_SAMPLE_ENUM)
|
47
|
+
),
|
48
|
+
cv.Optional(CONF_MIC_GAIN, default="42DB"): cv.enum(
|
49
|
+
ES8311_MIC_GAIN_ENUM, upper=True
|
50
|
+
),
|
51
|
+
cv.Optional(CONF_SAMPLE_RATE, default=16000): cv.int_range(min=1),
|
52
|
+
cv.Optional(CONF_USE_MCLK, default=True): cv.boolean,
|
53
|
+
cv.Optional(CONF_USE_MICROPHONE, default=False): cv.boolean,
|
54
|
+
}
|
55
|
+
)
|
56
|
+
.extend(cv.COMPONENT_SCHEMA)
|
57
|
+
.extend(i2c.i2c_device_schema(0x18))
|
58
|
+
)
|
59
|
+
|
60
|
+
|
61
|
+
async def to_code(config):
|
62
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
63
|
+
await cg.register_component(var, config)
|
64
|
+
await i2c.register_i2c_device(var, config)
|
65
|
+
|
66
|
+
cg.add(var.set_bits_per_sample(config[CONF_BITS_PER_SAMPLE]))
|
67
|
+
cg.add(var.set_mic_gain(config[CONF_MIC_GAIN]))
|
68
|
+
cg.add(var.set_sample_frequency(config[CONF_SAMPLE_RATE]))
|
69
|
+
cg.add(var.set_use_mclk(config[CONF_USE_MCLK]))
|
70
|
+
cg.add(var.set_use_mic(config[CONF_USE_MICROPHONE]))
|