use a less fun but more descriptive namespace
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "esp_adc_cal.h"
|
||||
#include "hal/adc_types.h"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
static esp_adc_cal_characteristics_t calibration;
|
||||
|
||||
@@ -28,4 +28,4 @@ uint32_t read_battery_voltage(void) {
|
||||
return esp_adc_cal_raw_to_voltage(raw, &calibration);
|
||||
}
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "hal/i2c_types.h"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
static const char* kTag = "AUDIODAC";
|
||||
static const uint8_t kPcm5122Address = 0x4C;
|
||||
@@ -103,4 +103,4 @@ void AudioDac::WriteRegister(Register reg, uint8_t val) {
|
||||
ESP_ERROR_CHECK(transaction.Execute());
|
||||
}
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "display-init.hpp"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
namespace displays {
|
||||
|
||||
/* Bit to use to signify we should delay after part of an init sequence */
|
||||
@@ -100,4 +100,4 @@ const InitialisationData kST7735R = {
|
||||
kST7735RCommonFooter}};
|
||||
|
||||
} // namespace displays
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -41,7 +41,7 @@ static const int kDisplayBufferSize = (kDisplayWidth * kDisplayHeight) / 10;
|
||||
DMA_ATTR static lv_color_t sBuffer1[kDisplayBufferSize];
|
||||
DMA_ATTR static lv_color_t sBuffer2[kDisplayBufferSize];
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
// Static functions for interrop with the LVGL display driver API, which
|
||||
// requires a function pointer.
|
||||
@@ -282,4 +282,4 @@ void Display::ServiceTransactions() {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
GpioExpander::GpioExpander() {
|
||||
ports_ = pack(kPortADefault, kPortBDefault);
|
||||
@@ -84,4 +84,4 @@ GpioExpander::SpiLock::~SpiLock() {
|
||||
gpio_.with([&](auto& gpio) { gpio.set_pin(cs_, 1); });
|
||||
}
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
#include "assert.h"
|
||||
#include "driver/i2c.h"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
static constexpr int kCmdLinkSize = I2C_LINK_RECOMMENDED_SIZE(12);
|
||||
|
||||
@@ -48,4 +48,4 @@ I2CTransaction& I2CTransaction::read(uint8_t* dest, i2c_ack_type_t ack) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
esp_err_t init_adc(void);
|
||||
|
||||
@@ -13,4 +13,4 @@ esp_err_t init_adc(void);
|
||||
*/
|
||||
uint32_t read_battery_voltage(void);
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "esp_err.h"
|
||||
#include "result.hpp"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
/**
|
||||
* Interface for a PCM5122PWR DAC, configured over I2C.
|
||||
@@ -70,4 +70,4 @@ class AudioDac {
|
||||
void WriteRegister(Register reg, uint8_t val);
|
||||
};
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
namespace displays {
|
||||
|
||||
extern const uint8_t kDelayBit;
|
||||
@@ -78,4 +78,4 @@ enum StCommands {
|
||||
};
|
||||
|
||||
} // namespace displays
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "result.hpp"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
/*
|
||||
* Display driver for LVGL.
|
||||
@@ -64,4 +64,4 @@ class Display {
|
||||
uintptr_t flags = 0);
|
||||
};
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
/**
|
||||
* Wrapper for interfacing with the PCA8575 GPIO expander. Includes basic
|
||||
@@ -205,4 +205,4 @@ class GpioExpander {
|
||||
std::atomic<uint16_t> inputs_;
|
||||
};
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "driver/i2c.h"
|
||||
#include "hal/i2c_types.h"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
/*
|
||||
* Convenience wrapper for performing an I2C transaction with a reasonable
|
||||
@@ -81,4 +81,4 @@ class I2CTransaction {
|
||||
uint8_t* buffer_;
|
||||
};
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "mp3_decoder.h"
|
||||
#include "result.hpp"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
class DacAudioPlayback {
|
||||
public:
|
||||
@@ -64,4 +64,4 @@ class DacAudioPlayback {
|
||||
audio_element_handle_t mp3_decoder_;
|
||||
};
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "esp_vfs_fat.h"
|
||||
#include "result.hpp"
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
extern const char* kStoragePath;
|
||||
|
||||
@@ -57,4 +57,4 @@ class SdStorage {
|
||||
FATFS* fs_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
static const char* kTag = "PLAYBACK";
|
||||
static const i2s_port_t kI2SPort = I2S_NUM_0;
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
static audio_element_status_t status_from_the_void(void* status) {
|
||||
uintptr_t as_pointer_int = reinterpret_cast<uintptr_t>(status);
|
||||
@@ -243,4 +243,4 @@ auto DacAudioPlayback::volume() -> uint8_t {
|
||||
return volume_;
|
||||
}
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
static const char* kTag = "SDSTORAGE";
|
||||
static const uint8_t kMaxOpenFiles = 8;
|
||||
|
||||
namespace gay_ipod {
|
||||
namespace drivers {
|
||||
|
||||
const char* kStoragePath = "/sdcard";
|
||||
|
||||
@@ -146,4 +146,4 @@ auto SdStorage::HandleTransaction(sdspi_dev_handle_t handle,
|
||||
return do_transaction_(handle, cmdinfo);
|
||||
}
|
||||
|
||||
} // namespace gay_ipod
|
||||
} // namespace drivers
|
||||
|
||||
+13
-13
@@ -104,13 +104,13 @@ static StaticTask_t sLvglTaskBuffer = {};
|
||||
static StackType_t sLvglStack[kLvglStackSize] = {0};
|
||||
|
||||
struct LvglArgs {
|
||||
gay_ipod::GpioExpander* gpio_expander;
|
||||
drivers::GpioExpander* gpio_expander;
|
||||
};
|
||||
|
||||
void lvgl_main(void* voidArgs) {
|
||||
ESP_LOGI(TAG, "starting LVGL task");
|
||||
LvglArgs* args = (LvglArgs*)voidArgs;
|
||||
gay_ipod::GpioExpander* gpio_expander = args->gpio_expander;
|
||||
drivers::GpioExpander* gpio_expander = args->gpio_expander;
|
||||
|
||||
// Dispose of the args now that we've gotten everything out of them.
|
||||
delete args;
|
||||
@@ -123,12 +123,12 @@ void lvgl_main(void* voidArgs) {
|
||||
|
||||
ESP_LOGI(TAG, "init display");
|
||||
auto display_res =
|
||||
gay_ipod::Display::create(gpio_expander, gay_ipod::displays::kST7735R);
|
||||
drivers::Display::create(gpio_expander, drivers::displays::kST7735R);
|
||||
if (display_res.has_error()) {
|
||||
ESP_LOGE(TAG, "Failed: %d", display_res.error());
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<gay_ipod::Display> display = std::move(display_res.value());
|
||||
std::unique_ptr<drivers::Display> display = std::move(display_res.value());
|
||||
|
||||
auto label = lv_label_create(NULL);
|
||||
lv_label_set_text(label, "g'day, cunts!");
|
||||
@@ -151,38 +151,38 @@ extern "C" void app_main(void) {
|
||||
ESP_ERROR_CHECK(gpio_install_isr_service(ESP_INTR_FLAG_LOWMED));
|
||||
init_i2c();
|
||||
init_spi();
|
||||
ESP_ERROR_CHECK(gay_ipod::init_adc());
|
||||
ESP_ERROR_CHECK(drivers::init_adc());
|
||||
|
||||
ESP_LOGI(TAG, "Init GPIOs");
|
||||
gay_ipod::GpioExpander* expander = new gay_ipod::GpioExpander();
|
||||
drivers::GpioExpander* expander = new drivers::GpioExpander();
|
||||
|
||||
// for debugging usb ic
|
||||
// expander.set_sd_mux(gay_ipod::GpioExpander::USB);
|
||||
// expander.set_sd_mux(drivers::GpioExpander::USB);
|
||||
|
||||
/*
|
||||
ESP_LOGI(TAG, "Init SD card");
|
||||
auto storage_res = gay_ipod::SdStorage::create(expander);
|
||||
auto storage_res = drivers::SdStorage::create(expander);
|
||||
if (storage_res.has_error()) {
|
||||
ESP_LOGE(TAG, "Failed: %d", storage_res.error());
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<gay_ipod::SdStorage> storage = std::move(storage_res.value());
|
||||
std::unique_ptr<drivers::SdStorage> storage = std::move(storage_res.value());
|
||||
|
||||
ESP_LOGI(TAG, "Init DAC");
|
||||
auto dac_res = gay_ipod::AudioDac::create(expander);
|
||||
auto dac_res = drivers::AudioDac::create(expander);
|
||||
if (storage_res.has_error()) {
|
||||
ESP_LOGE(TAG, "Failed: %d", dac_res.error());
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<gay_ipod::AudioDac> dac = std::move(dac_res.value());
|
||||
std::unique_ptr<drivers::AudioDac> dac = std::move(dac_res.value());
|
||||
|
||||
ESP_LOGI(TAG, "Init Audio Pipeline");
|
||||
auto playback_res = gay_ipod::DacAudioPlayback::create(dac.get());
|
||||
auto playback_res = drivers::DacAudioPlayback::create(dac.get());
|
||||
if (playback_res.has_error()) {
|
||||
ESP_LOGE(TAG, "Failed: %d", playback_res.error());
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<gay_ipod::DacAudioPlayback> playback =
|
||||
std::unique_ptr<drivers::DacAudioPlayback> playback =
|
||||
std::move(playback_res.value());
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user