build fixes for new compiler version and standard
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "audio_element_handle.hpp"
|
||||
#include "audio_element.hpp"
|
||||
#include "freertos/projdefs.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
namespace audio {
|
||||
|
||||
@@ -47,7 +48,7 @@ auto AudioElementHandle::QuitSync() -> void {
|
||||
}
|
||||
|
||||
auto AudioElementHandle::MonitorUtilState(eTaskState desired) -> void {
|
||||
while (eTaskGetState(task_.get()) != desired) {
|
||||
while (eTaskGetState(*task_) != desired) {
|
||||
WakeUpTask();
|
||||
vTaskDelay(pdMS_TO_TICKS(1));
|
||||
}
|
||||
@@ -63,13 +64,13 @@ auto AudioElementHandle::WakeUpTask() -> void {
|
||||
// between now and its next element state check. Also think about chunk blocks
|
||||
// nested in element bodies.
|
||||
// Maybe we need a big mutex or semaphore somewhere in here.
|
||||
switch (eTaskGetState(task_.get())) {
|
||||
switch (eTaskGetState(*task_)) {
|
||||
case eBlocked:
|
||||
// TODO: when is this safe?
|
||||
xTaskAbortDelay(task_.get());
|
||||
xTaskAbortDelay(*task_);
|
||||
break;
|
||||
case eSuspended:
|
||||
vTaskResume(task_.get());
|
||||
vTaskResume(*task_);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
+11
-9
@@ -2,17 +2,19 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#include "esp_adc/adc_cali.h"
|
||||
#include "esp_adc/adc_cali_scheme.h"
|
||||
#include "hal/adc_types.h"
|
||||
|
||||
namespace drivers {
|
||||
|
||||
static const uint8_t kAdcBitWidth = ADC_BITWIDTH_12;
|
||||
static const uint8_t kAdcUnit = ADC_UNIT_1;
|
||||
static const adc_bitwidth_t kAdcBitWidth = ADC_BITWIDTH_12;
|
||||
static const adc_unit_t kAdcUnit = ADC_UNIT_1;
|
||||
// Max battery voltage should be a little over 2V due to our divider, so we need
|
||||
// the max attenuation to properly handle the full range.
|
||||
static const uint8_t kAdcAttenuation = ADC_ATTEN_DB_11;
|
||||
static const adc_atten_t kAdcAttenuation = ADC_ATTEN_DB_11;
|
||||
// Corresponds to GPIO 34.
|
||||
static const uint8_t kAdcChannel = ADC_CHANNEL_6;
|
||||
static const adc_channel_t kAdcChannel = ADC_CHANNEL_6;
|
||||
|
||||
Battery::Battery() {
|
||||
adc_oneshot_unit_init_cfg_t unit_config = {
|
||||
@@ -21,8 +23,8 @@ Battery::Battery() {
|
||||
ESP_ERROR_CHECK(adc_oneshot_new_unit(&unit_config, &adc_handle_));
|
||||
|
||||
adc_oneshot_chan_cfg_t channel_config = {
|
||||
.bitwidth = kAdcBitWidth,
|
||||
.atten = kAdcAttenuation,
|
||||
.bitwidth = kAdcBitWidth,
|
||||
};
|
||||
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc_handle_, kAdcChannel, &channel_config));
|
||||
|
||||
@@ -42,11 +44,11 @@ Battery::~Battery() {
|
||||
|
||||
auto Battery::Millivolts() -> uint32_t {
|
||||
// GPIO 34
|
||||
int raw;
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_handle, kAdcChannel &raw));
|
||||
int raw = 0;
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_handle_, kAdcChannel, &raw));
|
||||
|
||||
int voltage;
|
||||
ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc_calibration_handle, raw, &voltage));
|
||||
int voltage = 0;
|
||||
ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc_calibration_handle_, raw, &voltage));
|
||||
|
||||
return voltage;
|
||||
}
|
||||
|
||||
+4
-2
@@ -5,6 +5,8 @@
|
||||
#include "assert.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "driver/i2s.h"
|
||||
#include "driver/i2s_types.h"
|
||||
#include "driver/i2s_types_legacy.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "hal/i2c_types.h"
|
||||
@@ -17,7 +19,7 @@ namespace drivers {
|
||||
|
||||
static const char* kTag = "AUDIODAC";
|
||||
static const uint8_t kPcm5122Address = 0x4C;
|
||||
static const uint8_t kPcm5122Timeout = 100 / portTICK_RATE_MS;
|
||||
static const uint8_t kPcm5122Timeout = pdMS_TO_TICKS(100);
|
||||
static const i2s_port_t kI2SPort = I2S_NUM_0;
|
||||
|
||||
static const AudioDac::SampleRate kDefaultSampleRate =
|
||||
@@ -46,7 +48,7 @@ auto AudioDac::create(GpioExpander* expander)
|
||||
.use_apll = false,
|
||||
.tx_desc_auto_clear = false,
|
||||
.fixed_mclk = 0,
|
||||
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT,
|
||||
.mclk_multiple = I2S_MCLK_MULTIPLE_512, // TODO: double check
|
||||
.bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT,
|
||||
};
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ auto Display::create(GpioExpander* expander,
|
||||
ESP_LOGI(kTag, "Registering driver");
|
||||
display->display_ = lv_disp_drv_register(&display->driver_);
|
||||
|
||||
return std::move(display);
|
||||
return display;
|
||||
}
|
||||
|
||||
Display::Display(GpioExpander* gpio, spi_device_handle_t handle)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#include "esp_adc/adc_cali.h"
|
||||
#include "esp_err.h"
|
||||
#include "result.hpp"
|
||||
|
||||
@@ -18,7 +19,7 @@ class Battery {
|
||||
*/
|
||||
auto Millivolts() -> uint32_t;
|
||||
private:
|
||||
adc_oneshot_handle_t adc_handle_;
|
||||
adc_oneshot_unit_handle_t adc_handle_;
|
||||
adc_cali_handle_t adc_calibration_handle_;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "hal/i2s_types.h"
|
||||
#include "result.hpp"
|
||||
#include "span.hpp"
|
||||
#include "driver/i2s_types_legacy.h"
|
||||
|
||||
#include "gpio_expander.hpp"
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "display_init.hpp"
|
||||
#include "gpio_expander.hpp"
|
||||
#include "sys/_stdint.h"
|
||||
|
||||
namespace drivers {
|
||||
|
||||
@@ -63,7 +64,7 @@ class Display {
|
||||
void SendTransaction(TransactionType type,
|
||||
const uint8_t* data,
|
||||
size_t length,
|
||||
uintptr_t flags = 0);
|
||||
uint32_t flags = 0);
|
||||
};
|
||||
|
||||
} // namespace drivers
|
||||
|
||||
@@ -32,7 +32,7 @@ class GpioExpander {
|
||||
~GpioExpander();
|
||||
|
||||
static const uint8_t kPca8575Address = 0x20;
|
||||
static const uint8_t kPca8575Timeout = 100 / portTICK_RATE_MS;
|
||||
static const uint8_t kPca8575Timeout = pdMS_TO_TICKS(100);
|
||||
|
||||
// Port A:
|
||||
// 0 - audio power enable
|
||||
|
||||
@@ -20,7 +20,7 @@ esp_err_t deinit_i2c(void);
|
||||
*/
|
||||
class I2CTransaction {
|
||||
public:
|
||||
static const uint8_t kI2CTimeout = 100 / portTICK_RATE_MS;
|
||||
static const uint8_t kI2CTimeout = pdMS_TO_TICKS(100);
|
||||
|
||||
I2CTransaction();
|
||||
~I2CTransaction();
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ extern "C" void app_main(void) {
|
||||
|
||||
ESP_LOGI(TAG, "Init battery measurement");
|
||||
drivers::Battery* battery = new drivers::Battery();
|
||||
ESP_LOGI(TAG, "it's reading %dmV!", battery->Millivolts());
|
||||
ESP_LOGI(TAG, "it's reading %d mV!", (int) battery->Millivolts());
|
||||
|
||||
ESP_LOGI(TAG, "Init SD card");
|
||||
auto storage_res = drivers::SdStorage::create(expander);
|
||||
|
||||
Reference in New Issue
Block a user