mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
Merge pull request #7297 from esphome/bump-2024.8.0b2
Some checks failed
CI / Create common environment (push) Has been cancelled
CI / Check black (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Check pyupgrade (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.10) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.12) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.9) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / list-components (push) Has been cancelled
CI / Component test ${{ matrix.file }} (push) Has been cancelled
CI / Split components for testing into 20 groups maximum (push) Has been cancelled
CI / Test split components (push) Has been cancelled
CI / CI Status (push) Has been cancelled
YAML lint / yamllint (push) Has been cancelled
Some checks failed
CI / Create common environment (push) Has been cancelled
CI / Check black (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Check pyupgrade (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.10) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.12) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.9) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / list-components (push) Has been cancelled
CI / Component test ${{ matrix.file }} (push) Has been cancelled
CI / Split components for testing into 20 groups maximum (push) Has been cancelled
CI / Test split components (push) Has been cancelled
CI / CI Status (push) Has been cancelled
YAML lint / yamllint (push) Has been cancelled
2024.8.0b2
This commit is contained in:
commit
28bb0ddfeb
19 changed files with 187 additions and 55 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -397,7 +397,7 @@ jobs:
|
||||||
file: ${{ fromJson(needs.list-components.outputs.components) }}
|
file: ${{ fromJson(needs.list-components.outputs.components) }}
|
||||||
steps:
|
steps:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt-get install libsodium-dev libsdl2-dev
|
run: sudo apt-get install libsdl2-dev
|
||||||
|
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v4.1.7
|
uses: actions/checkout@v4.1.7
|
||||||
|
@ -451,7 +451,7 @@ jobs:
|
||||||
run: echo ${{ matrix.components }}
|
run: echo ${{ matrix.components }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt-get install libsodium-dev libsdl2-dev
|
run: sudo apt-get install libsdl2-dev
|
||||||
|
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v4.1.7
|
uses: actions/checkout@v4.1.7
|
||||||
|
|
|
@ -155,7 +155,7 @@ async def to_code(config):
|
||||||
decoded = base64.b64decode(encryption_config[CONF_KEY])
|
decoded = base64.b64decode(encryption_config[CONF_KEY])
|
||||||
cg.add(var.set_noise_psk(list(decoded)))
|
cg.add(var.set_noise_psk(list(decoded)))
|
||||||
cg.add_define("USE_API_NOISE")
|
cg.add_define("USE_API_NOISE")
|
||||||
cg.add_library("esphome/noise-c", "0.1.4")
|
cg.add_library("esphome/noise-c", "0.1.6")
|
||||||
else:
|
else:
|
||||||
cg.add_define("USE_API_PLAINTEXT")
|
cg.add_define("USE_API_PLAINTEXT")
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
|
import esphome.codegen as cg
|
||||||
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
|
CONF_MAC_ADDRESS,
|
||||||
KEY_CORE,
|
KEY_CORE,
|
||||||
KEY_FRAMEWORK_VERSION,
|
KEY_FRAMEWORK_VERSION,
|
||||||
KEY_TARGET_FRAMEWORK,
|
KEY_TARGET_FRAMEWORK,
|
||||||
KEY_TARGET_PLATFORM,
|
KEY_TARGET_PLATFORM,
|
||||||
PLATFORM_HOST,
|
PLATFORM_HOST,
|
||||||
CONF_MAC_ADDRESS,
|
|
||||||
)
|
)
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
from esphome.helpers import IS_MACOS
|
|
||||||
import esphome.config_validation as cv
|
|
||||||
import esphome.codegen as cg
|
|
||||||
|
|
||||||
from .const import KEY_HOST
|
from .const import KEY_HOST
|
||||||
|
|
||||||
|
@ -42,8 +41,5 @@ async def to_code(config):
|
||||||
cg.add_build_flag("-DUSE_HOST")
|
cg.add_build_flag("-DUSE_HOST")
|
||||||
cg.add_define("USE_ESPHOME_HOST_MAC_ADDRESS", config[CONF_MAC_ADDRESS].parts)
|
cg.add_define("USE_ESPHOME_HOST_MAC_ADDRESS", config[CONF_MAC_ADDRESS].parts)
|
||||||
cg.add_build_flag("-std=c++17")
|
cg.add_build_flag("-std=c++17")
|
||||||
cg.add_build_flag("-lsodium")
|
|
||||||
if IS_MACOS:
|
|
||||||
cg.add_build_flag("-L/opt/homebrew/lib")
|
|
||||||
cg.add_define("ESPHOME_BOARD", "host")
|
cg.add_define("ESPHOME_BOARD", "host")
|
||||||
cg.add_platformio_option("platform", "platformio/native")
|
cg.add_platformio_option("platform", "platformio/native")
|
||||||
|
|
|
@ -41,29 +41,29 @@ class ESPColorCorrection {
|
||||||
if (this->max_brightness_.red == 0 || this->local_brightness_ == 0)
|
if (this->max_brightness_.red == 0 || this->local_brightness_ == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint16_t uncorrected = this->gamma_reverse_table_[red] * 255UL;
|
uint16_t uncorrected = this->gamma_reverse_table_[red] * 255UL;
|
||||||
uint8_t res = ((uncorrected / this->max_brightness_.red) * 255UL) / this->local_brightness_;
|
uint16_t res = ((uncorrected / this->max_brightness_.red) * 255UL) / this->local_brightness_;
|
||||||
return res;
|
return (uint8_t) std::min(res, uint16_t(255));
|
||||||
}
|
}
|
||||||
inline uint8_t color_uncorrect_green(uint8_t green) const ESPHOME_ALWAYS_INLINE {
|
inline uint8_t color_uncorrect_green(uint8_t green) const ESPHOME_ALWAYS_INLINE {
|
||||||
if (this->max_brightness_.green == 0 || this->local_brightness_ == 0)
|
if (this->max_brightness_.green == 0 || this->local_brightness_ == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint16_t uncorrected = this->gamma_reverse_table_[green] * 255UL;
|
uint16_t uncorrected = this->gamma_reverse_table_[green] * 255UL;
|
||||||
uint8_t res = ((uncorrected / this->max_brightness_.green) * 255UL) / this->local_brightness_;
|
uint16_t res = ((uncorrected / this->max_brightness_.green) * 255UL) / this->local_brightness_;
|
||||||
return res;
|
return (uint8_t) std::min(res, uint16_t(255));
|
||||||
}
|
}
|
||||||
inline uint8_t color_uncorrect_blue(uint8_t blue) const ESPHOME_ALWAYS_INLINE {
|
inline uint8_t color_uncorrect_blue(uint8_t blue) const ESPHOME_ALWAYS_INLINE {
|
||||||
if (this->max_brightness_.blue == 0 || this->local_brightness_ == 0)
|
if (this->max_brightness_.blue == 0 || this->local_brightness_ == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint16_t uncorrected = this->gamma_reverse_table_[blue] * 255UL;
|
uint16_t uncorrected = this->gamma_reverse_table_[blue] * 255UL;
|
||||||
uint8_t res = ((uncorrected / this->max_brightness_.blue) * 255UL) / this->local_brightness_;
|
uint16_t res = ((uncorrected / this->max_brightness_.blue) * 255UL) / this->local_brightness_;
|
||||||
return res;
|
return (uint8_t) std::min(res, uint16_t(255));
|
||||||
}
|
}
|
||||||
inline uint8_t color_uncorrect_white(uint8_t white) const ESPHOME_ALWAYS_INLINE {
|
inline uint8_t color_uncorrect_white(uint8_t white) const ESPHOME_ALWAYS_INLINE {
|
||||||
if (this->max_brightness_.white == 0 || this->local_brightness_ == 0)
|
if (this->max_brightness_.white == 0 || this->local_brightness_ == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint16_t uncorrected = this->gamma_reverse_table_[white] * 255UL;
|
uint16_t uncorrected = this->gamma_reverse_table_[white] * 255UL;
|
||||||
uint8_t res = ((uncorrected / this->max_brightness_.white) * 255UL) / this->local_brightness_;
|
uint16_t res = ((uncorrected / this->max_brightness_.white) * 255UL) / this->local_brightness_;
|
||||||
return res;
|
return (uint8_t) std::min(res, uint16_t(255));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -24,7 +24,11 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
esp32=False,
|
esp32=False,
|
||||||
rp2040=False,
|
rp2040=False,
|
||||||
): cv.All(
|
): cv.All(
|
||||||
cv.boolean, cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040])
|
cv.boolean,
|
||||||
|
cv.Any(
|
||||||
|
cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040]),
|
||||||
|
cv.boolean_false,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_MIN_IPV6_ADDR_COUNT, default=0): cv.positive_int,
|
cv.Optional(CONF_MIN_IPV6_ADDR_COUNT, default=0): cv.positive_int,
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,9 +201,6 @@ std::string ProntoProtocol::compensate_and_dump_sequence_(const RawTimings &data
|
||||||
out += dump_duration_(t_duration, timebase);
|
out += dump_duration_(t_duration, timebase);
|
||||||
}
|
}
|
||||||
|
|
||||||
// append minimum gap
|
|
||||||
out += dump_duration_(PRONTO_DEFAULT_GAP, timebase, true);
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,13 @@ inline double deg2rad(double degrees) {
|
||||||
void Rtttl::dump_config() { ESP_LOGCONFIG(TAG, "Rtttl"); }
|
void Rtttl::dump_config() { ESP_LOGCONFIG(TAG, "Rtttl"); }
|
||||||
|
|
||||||
void Rtttl::play(std::string rtttl) {
|
void Rtttl::play(std::string rtttl) {
|
||||||
|
if (this->state_ != State::STATE_STOPPED && this->state_ != State::STATE_STOPPING) {
|
||||||
|
int pos = this->rtttl_.find(':');
|
||||||
|
auto name = this->rtttl_.substr(0, pos);
|
||||||
|
ESP_LOGW(TAG, "RTTL Component is already playing: %s", name.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->rtttl_ = std::move(rtttl);
|
this->rtttl_ = std::move(rtttl);
|
||||||
|
|
||||||
this->default_duration_ = 4;
|
this->default_duration_ = 4;
|
||||||
|
@ -98,13 +105,20 @@ void Rtttl::play(std::string rtttl) {
|
||||||
this->note_duration_ = 1;
|
this->note_duration_ = 1;
|
||||||
|
|
||||||
#ifdef USE_SPEAKER
|
#ifdef USE_SPEAKER
|
||||||
this->samples_sent_ = 0;
|
if (this->speaker_ != nullptr) {
|
||||||
this->samples_count_ = 0;
|
this->set_state_(State::STATE_INIT);
|
||||||
|
this->samples_sent_ = 0;
|
||||||
|
this->samples_count_ = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_OUTPUT
|
||||||
|
if (this->output_ != nullptr) {
|
||||||
|
this->set_state_(State::STATE_RUNNING);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rtttl::stop() {
|
void Rtttl::stop() {
|
||||||
this->note_duration_ = 0;
|
|
||||||
#ifdef USE_OUTPUT
|
#ifdef USE_OUTPUT
|
||||||
if (this->output_ != nullptr) {
|
if (this->output_ != nullptr) {
|
||||||
this->output_->set_level(0.0);
|
this->output_->set_level(0.0);
|
||||||
|
@ -117,16 +131,35 @@ void Rtttl::stop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
this->note_duration_ = 0;
|
||||||
|
this->set_state_(STATE_STOPPING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rtttl::loop() {
|
void Rtttl::loop() {
|
||||||
if (this->note_duration_ == 0)
|
if (this->note_duration_ == 0 || this->state_ == State::STATE_STOPPED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef USE_SPEAKER
|
#ifdef USE_SPEAKER
|
||||||
if (this->speaker_ != nullptr) {
|
if (this->speaker_ != nullptr) {
|
||||||
|
if (this->state_ == State::STATE_STOPPING) {
|
||||||
|
if (this->speaker_->is_stopped()) {
|
||||||
|
this->set_state_(State::STATE_STOPPED);
|
||||||
|
}
|
||||||
|
} else if (this->state_ == State::STATE_INIT) {
|
||||||
|
if (this->speaker_->is_stopped()) {
|
||||||
|
this->speaker_->start();
|
||||||
|
this->set_state_(State::STATE_STARTING);
|
||||||
|
}
|
||||||
|
} else if (this->state_ == State::STATE_STARTING) {
|
||||||
|
if (this->speaker_->is_running()) {
|
||||||
|
this->set_state_(State::STATE_RUNNING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!this->speaker_->is_running()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this->samples_sent_ != this->samples_count_) {
|
if (this->samples_sent_ != this->samples_count_) {
|
||||||
SpeakerSample sample[SAMPLE_BUFFER_SIZE + 1];
|
SpeakerSample sample[SAMPLE_BUFFER_SIZE + 2];
|
||||||
int x = 0;
|
int x = 0;
|
||||||
double rem = 0.0;
|
double rem = 0.0;
|
||||||
|
|
||||||
|
@ -136,7 +169,7 @@ void Rtttl::loop() {
|
||||||
if (this->samples_per_wave_ != 0 && this->samples_sent_ >= this->samples_gap_) { // Play note//
|
if (this->samples_per_wave_ != 0 && this->samples_sent_ >= this->samples_gap_) { // Play note//
|
||||||
rem = ((this->samples_sent_ << 10) % this->samples_per_wave_) * (360.0 / this->samples_per_wave_);
|
rem = ((this->samples_sent_ << 10) % this->samples_per_wave_) * (360.0 / this->samples_per_wave_);
|
||||||
|
|
||||||
int16_t val = (49152 * this->gain_) * sin(deg2rad(rem));
|
int16_t val = (127 * this->gain_) * sin(deg2rad(rem)); // 16bit = 49152
|
||||||
|
|
||||||
sample[x].left = val;
|
sample[x].left = val;
|
||||||
sample[x].right = val;
|
sample[x].right = val;
|
||||||
|
@ -153,9 +186,9 @@ void Rtttl::loop() {
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
if (x > 0) {
|
if (x > 0) {
|
||||||
int send = this->speaker_->play((uint8_t *) (&sample), x * 4);
|
int send = this->speaker_->play((uint8_t *) (&sample), x * 2);
|
||||||
if (send != x * 4) {
|
if (send != x * 4) {
|
||||||
this->samples_sent_ -= (x - (send / 4));
|
this->samples_sent_ -= (x - (send / 2));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -167,14 +200,7 @@ void Rtttl::loop() {
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
if (!this->rtttl_[position_]) {
|
if (!this->rtttl_[position_]) {
|
||||||
this->note_duration_ = 0;
|
this->finish_();
|
||||||
#ifdef USE_OUTPUT
|
|
||||||
if (this->output_ != nullptr) {
|
|
||||||
this->output_->set_level(0.0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ESP_LOGD(TAG, "Playback finished");
|
|
||||||
this->on_finished_playback_callback_.call();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +239,7 @@ void Rtttl::loop() {
|
||||||
case 'a':
|
case 'a':
|
||||||
note = 10;
|
note = 10;
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
case 'b':
|
case 'b':
|
||||||
note = 12;
|
note = 12;
|
||||||
break;
|
break;
|
||||||
|
@ -238,14 +265,21 @@ void Rtttl::loop() {
|
||||||
uint8_t scale = get_integer_();
|
uint8_t scale = get_integer_();
|
||||||
if (scale == 0)
|
if (scale == 0)
|
||||||
scale = this->default_octave_;
|
scale = this->default_octave_;
|
||||||
|
|
||||||
|
if (scale < 4 || scale > 7) {
|
||||||
|
ESP_LOGE(TAG, "Octave out of valid range. Should be between 4 and 7. (Octave: %d)", scale);
|
||||||
|
this->finish_();
|
||||||
|
return;
|
||||||
|
}
|
||||||
bool need_note_gap = false;
|
bool need_note_gap = false;
|
||||||
|
|
||||||
// Now play the note
|
// Now play the note
|
||||||
if (note) {
|
if (note) {
|
||||||
auto note_index = (scale - 4) * 12 + note;
|
auto note_index = (scale - 4) * 12 + note;
|
||||||
if (note_index < 0 || note_index >= (int) sizeof(NOTES)) {
|
if (note_index < 0 || note_index >= (int) sizeof(NOTES)) {
|
||||||
ESP_LOGE(TAG, "Note out of valid range");
|
ESP_LOGE(TAG, "Note out of valid range (note: %d, scale: %d, index: %d, max: %d)", note, scale, note_index,
|
||||||
this->note_duration_ = 0;
|
(int) sizeof(NOTES));
|
||||||
|
this->finish_();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto freq = NOTES[note_index];
|
auto freq = NOTES[note_index];
|
||||||
|
@ -285,14 +319,17 @@ void Rtttl::loop() {
|
||||||
this->samples_gap_ = (this->sample_rate_ * DOUBLE_NOTE_GAP_MS) / 1600; //(ms);
|
this->samples_gap_ = (this->sample_rate_ * DOUBLE_NOTE_GAP_MS) / 1600; //(ms);
|
||||||
}
|
}
|
||||||
if (this->output_freq_ != 0) {
|
if (this->output_freq_ != 0) {
|
||||||
|
// make sure there is enough samples to add a full last sinus.
|
||||||
|
|
||||||
|
uint16_t samples_wish = this->samples_count_;
|
||||||
this->samples_per_wave_ = (this->sample_rate_ << 10) / this->output_freq_;
|
this->samples_per_wave_ = (this->sample_rate_ << 10) / this->output_freq_;
|
||||||
|
|
||||||
// make sure there is enough samples to add a full last sinus.
|
|
||||||
uint16_t division = ((this->samples_count_ << 10) / this->samples_per_wave_) + 1;
|
uint16_t division = ((this->samples_count_ << 10) / this->samples_per_wave_) + 1;
|
||||||
uint16_t x = this->samples_count_;
|
|
||||||
this->samples_count_ = (division * this->samples_per_wave_);
|
this->samples_count_ = (division * this->samples_per_wave_);
|
||||||
ESP_LOGD(TAG, "play time old: %d div: %d new: %d %d", x, division, this->samples_count_, this->samples_per_wave_);
|
|
||||||
this->samples_count_ = this->samples_count_ >> 10;
|
this->samples_count_ = this->samples_count_ >> 10;
|
||||||
|
ESP_LOGVV(TAG, "- Calc play time: wish: %d gets: %d (div: %d spw: %d)", samples_wish, this->samples_count_,
|
||||||
|
division, this->samples_per_wave_);
|
||||||
}
|
}
|
||||||
// Convert from frequency in Hz to high and low samples in fixed point
|
// Convert from frequency in Hz to high and low samples in fixed point
|
||||||
}
|
}
|
||||||
|
@ -301,5 +338,53 @@ void Rtttl::loop() {
|
||||||
this->last_note_ = millis();
|
this->last_note_ = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Rtttl::finish_() {
|
||||||
|
#ifdef USE_OUTPUT
|
||||||
|
if (this->output_ != nullptr) {
|
||||||
|
this->output_->set_level(0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SPEAKER
|
||||||
|
if (this->speaker_ != nullptr) {
|
||||||
|
SpeakerSample sample[2];
|
||||||
|
sample[0].left = 0;
|
||||||
|
sample[0].right = 0;
|
||||||
|
sample[1].left = 0;
|
||||||
|
sample[1].right = 0;
|
||||||
|
this->speaker_->play((uint8_t *) (&sample), 8);
|
||||||
|
|
||||||
|
this->speaker_->finish();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
this->set_state_(State::STATE_STOPPING);
|
||||||
|
this->note_duration_ = 0;
|
||||||
|
this->on_finished_playback_callback_.call();
|
||||||
|
ESP_LOGD(TAG, "Playback finished");
|
||||||
|
}
|
||||||
|
|
||||||
|
static const LogString *state_to_string(State state) {
|
||||||
|
switch (state) {
|
||||||
|
case STATE_STOPPED:
|
||||||
|
return LOG_STR("STATE_STOPPED");
|
||||||
|
case STATE_STARTING:
|
||||||
|
return LOG_STR("STATE_STARTING");
|
||||||
|
case STATE_RUNNING:
|
||||||
|
return LOG_STR("STATE_RUNNING");
|
||||||
|
case STATE_STOPPING:
|
||||||
|
return LOG_STR("STATE_STOPPING");
|
||||||
|
case STATE_INIT:
|
||||||
|
return LOG_STR("STATE_INIT");
|
||||||
|
default:
|
||||||
|
return LOG_STR("UNKNOWN");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void Rtttl::set_state_(State state) {
|
||||||
|
State old_state = this->state_;
|
||||||
|
this->state_ = state;
|
||||||
|
ESP_LOGD(TAG, "State changed from %s to %s", LOG_STR_ARG(state_to_string(old_state)),
|
||||||
|
LOG_STR_ARG(state_to_string(state)));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace rtttl
|
} // namespace rtttl
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
|
@ -14,12 +14,20 @@
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace rtttl {
|
namespace rtttl {
|
||||||
|
|
||||||
|
enum State : uint8_t {
|
||||||
|
STATE_STOPPED = 0,
|
||||||
|
STATE_INIT,
|
||||||
|
STATE_STARTING,
|
||||||
|
STATE_RUNNING,
|
||||||
|
STATE_STOPPING,
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef USE_SPEAKER
|
#ifdef USE_SPEAKER
|
||||||
static const size_t SAMPLE_BUFFER_SIZE = 512;
|
static const size_t SAMPLE_BUFFER_SIZE = 2048;
|
||||||
|
|
||||||
struct SpeakerSample {
|
struct SpeakerSample {
|
||||||
int16_t left{0};
|
int8_t left{0};
|
||||||
int16_t right{0};
|
int8_t right{0};
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -42,7 +50,7 @@ class Rtttl : public Component {
|
||||||
void stop();
|
void stop();
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
bool is_playing() { return this->note_duration_ != 0; }
|
bool is_playing() { return this->state_ != State::STATE_STOPPED; }
|
||||||
void loop() override;
|
void loop() override;
|
||||||
|
|
||||||
void add_on_finished_playback_callback(std::function<void()> callback) {
|
void add_on_finished_playback_callback(std::function<void()> callback) {
|
||||||
|
@ -57,6 +65,8 @@ class Rtttl : public Component {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
void finish_();
|
||||||
|
void set_state_(State state);
|
||||||
|
|
||||||
std::string rtttl_{""};
|
std::string rtttl_{""};
|
||||||
size_t position_{0};
|
size_t position_{0};
|
||||||
|
@ -68,13 +78,12 @@ class Rtttl : public Component {
|
||||||
|
|
||||||
uint32_t output_freq_;
|
uint32_t output_freq_;
|
||||||
float gain_{0.6f};
|
float gain_{0.6f};
|
||||||
|
State state_{State::STATE_STOPPED};
|
||||||
|
|
||||||
#ifdef USE_OUTPUT
|
#ifdef USE_OUTPUT
|
||||||
output::FloatOutput *output_;
|
output::FloatOutput *output_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void play_output_();
|
|
||||||
|
|
||||||
#ifdef USE_SPEAKER
|
#ifdef USE_SPEAKER
|
||||||
speaker::Speaker *speaker_{nullptr};
|
speaker::Speaker *speaker_{nullptr};
|
||||||
int sample_rate_{16000};
|
int sample_rate_{16000};
|
||||||
|
|
|
@ -370,6 +370,20 @@ def boolean(value):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def boolean_false(value):
|
||||||
|
"""Validate the given config option to be a boolean, set to False.
|
||||||
|
|
||||||
|
This option allows a bunch of different ways of expressing boolean values:
|
||||||
|
- instance of boolean
|
||||||
|
- 'true'/'false'
|
||||||
|
- 'yes'/'no'
|
||||||
|
- 'enable'/disable
|
||||||
|
"""
|
||||||
|
if boolean(value):
|
||||||
|
raise Invalid("Expected boolean value to be false")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
@schema_extractor_list
|
@schema_extractor_list
|
||||||
def ensure_list(*validators):
|
def ensure_list(*validators):
|
||||||
"""Validate this configuration option to be a list.
|
"""Validate this configuration option to be a list.
|
||||||
|
@ -1850,7 +1864,7 @@ def maybe_simple_value(*validators, **kwargs):
|
||||||
if value == SCHEMA_EXTRACT:
|
if value == SCHEMA_EXTRACT:
|
||||||
return (validator, key)
|
return (validator, key)
|
||||||
|
|
||||||
if isinstance(value, dict) and key in value:
|
if isinstance(value, dict):
|
||||||
return validator(value)
|
return validator(value)
|
||||||
return validator({key: value})
|
return validator({key: value})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2024.8.0b1"
|
__version__ = "2024.8.0b2"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||||
|
|
|
@ -11,10 +11,6 @@ esphome:
|
||||||
message: Button was pressed
|
message: Button was pressed
|
||||||
- homeassistant.tag_scanned: pulse
|
- homeassistant.tag_scanned: pulse
|
||||||
|
|
||||||
wifi:
|
|
||||||
ssid: MySSID
|
|
||||||
password: password1
|
|
||||||
|
|
||||||
api:
|
api:
|
||||||
port: 8000
|
port: 8000
|
||||||
password: pwd
|
password: pwd
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: MySSID
|
||||||
|
password: password1
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: MySSID
|
||||||
|
password: password1
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: MySSID
|
||||||
|
password: password1
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: MySSID
|
||||||
|
password: password1
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: MySSID
|
||||||
|
password: password1
|
||||||
|
|
3
tests/components/api/test.host.yaml
Normal file
3
tests/components/api/test.host.yaml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
network:
|
|
@ -1 +1,5 @@
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: MySSID
|
||||||
|
password: password1
|
||||||
|
|
4
tests/components/network/test-ipv6.bk72xx-ard.yaml
Normal file
4
tests/components/network/test-ipv6.bk72xx-ard.yaml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
substitutions:
|
||||||
|
network_enable_ipv6: "false"
|
||||||
|
|
||||||
|
<<: !include common.yaml
|
Loading…
Reference in a new issue