use a less fun but more descriptive namespace

custom
jacqueline 3 years ago
parent 28d73ad866
commit 675d52c9a5
  1. 4
      src/drivers/battery.cpp
  2. 4
      src/drivers/dac.cpp
  3. 4
      src/drivers/display-init.cpp
  4. 4
      src/drivers/display.cpp
  5. 4
      src/drivers/gpio-expander.cpp
  6. 4
      src/drivers/i2c.cpp
  7. 4
      src/drivers/include/battery.hpp
  8. 4
      src/drivers/include/dac.hpp
  9. 4
      src/drivers/include/display-init.hpp
  10. 4
      src/drivers/include/display.hpp
  11. 4
      src/drivers/include/gpio-expander.hpp
  12. 4
      src/drivers/include/i2c.hpp
  13. 4
      src/drivers/include/playback.hpp
  14. 4
      src/drivers/include/storage.hpp
  15. 4
      src/drivers/playback.cpp
  16. 4
      src/drivers/storage.cpp
  17. 26
      src/main/main.cpp

@ -4,7 +4,7 @@
#include "esp_adc_cal.h" #include "esp_adc_cal.h"
#include "hal/adc_types.h" #include "hal/adc_types.h"
namespace gay_ipod { namespace drivers {
static esp_adc_cal_characteristics_t calibration; 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); return esp_adc_cal_raw_to_voltage(raw, &calibration);
} }
} // namespace gay_ipod } // namespace drivers

@ -11,7 +11,7 @@
#include "esp_log.h" #include "esp_log.h"
#include "hal/i2c_types.h" #include "hal/i2c_types.h"
namespace gay_ipod { namespace drivers {
static const char* kTag = "AUDIODAC"; static const char* kTag = "AUDIODAC";
static const uint8_t kPcm5122Address = 0x4C; static const uint8_t kPcm5122Address = 0x4C;
@ -103,4 +103,4 @@ void AudioDac::WriteRegister(Register reg, uint8_t val) {
ESP_ERROR_CHECK(transaction.Execute()); ESP_ERROR_CHECK(transaction.Execute());
} }
} // namespace gay_ipod } // namespace drivers

@ -1,6 +1,6 @@
#include "display-init.hpp" #include "display-init.hpp"
namespace gay_ipod { namespace drivers {
namespace displays { namespace displays {
/* Bit to use to signify we should delay after part of an init sequence */ /* Bit to use to signify we should delay after part of an init sequence */
@ -100,4 +100,4 @@ const InitialisationData kST7735R = {
kST7735RCommonFooter}}; kST7735RCommonFooter}};
} // namespace displays } // 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 sBuffer1[kDisplayBufferSize];
DMA_ATTR static lv_color_t sBuffer2[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 // Static functions for interrop with the LVGL display driver API, which
// requires a function pointer. // requires a function pointer.
@ -282,4 +282,4 @@ void Display::ServiceTransactions() {
} }
} }
} // namespace gay_ipod } // namespace drivers

@ -4,7 +4,7 @@
#include <cstdint> #include <cstdint>
namespace gay_ipod { namespace drivers {
GpioExpander::GpioExpander() { GpioExpander::GpioExpander() {
ports_ = pack(kPortADefault, kPortBDefault); ports_ = pack(kPortADefault, kPortBDefault);
@ -84,4 +84,4 @@ GpioExpander::SpiLock::~SpiLock() {
gpio_.with([&](auto& gpio) { gpio.set_pin(cs_, 1); }); gpio_.with([&](auto& gpio) { gpio.set_pin(cs_, 1); });
} }
} // namespace gay_ipod } // namespace drivers

@ -4,7 +4,7 @@
#include "assert.h" #include "assert.h"
#include "driver/i2c.h" #include "driver/i2c.h"
namespace gay_ipod { namespace drivers {
static constexpr int kCmdLinkSize = I2C_LINK_RECOMMENDED_SIZE(12); 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; return *this;
} }
} // namespace gay_ipod } // namespace drivers

@ -4,7 +4,7 @@
#include "esp_err.h" #include "esp_err.h"
namespace gay_ipod { namespace drivers {
esp_err_t init_adc(void); esp_err_t init_adc(void);
@ -13,4 +13,4 @@ esp_err_t init_adc(void);
*/ */
uint32_t read_battery_voltage(void); uint32_t read_battery_voltage(void);
} // namespace gay_ipod } // namespace drivers

@ -8,7 +8,7 @@
#include "esp_err.h" #include "esp_err.h"
#include "result.hpp" #include "result.hpp"
namespace gay_ipod { namespace drivers {
/** /**
* Interface for a PCM5122PWR DAC, configured over I2C. * Interface for a PCM5122PWR DAC, configured over I2C.
@ -70,4 +70,4 @@ class AudioDac {
void WriteRegister(Register reg, uint8_t val); void WriteRegister(Register reg, uint8_t val);
}; };
} // namespace gay_ipod } // namespace drivers

@ -2,7 +2,7 @@
#include <cstdint> #include <cstdint>
namespace gay_ipod { namespace drivers {
namespace displays { namespace displays {
extern const uint8_t kDelayBit; extern const uint8_t kDelayBit;
@ -78,4 +78,4 @@ enum StCommands {
}; };
} // namespace displays } // namespace displays
} // namespace gay_ipod } // namespace drivers

@ -7,7 +7,7 @@
#include "lvgl/lvgl.h" #include "lvgl/lvgl.h"
#include "result.hpp" #include "result.hpp"
namespace gay_ipod { namespace drivers {
/* /*
* Display driver for LVGL. * Display driver for LVGL.
@ -64,4 +64,4 @@ class Display {
uintptr_t flags = 0); uintptr_t flags = 0);
}; };
} // namespace gay_ipod } // namespace drivers

@ -13,7 +13,7 @@
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
namespace gay_ipod { namespace drivers {
/** /**
* Wrapper for interfacing with the PCA8575 GPIO expander. Includes basic * Wrapper for interfacing with the PCA8575 GPIO expander. Includes basic
@ -205,4 +205,4 @@ class GpioExpander {
std::atomic<uint16_t> inputs_; std::atomic<uint16_t> inputs_;
}; };
} // namespace gay_ipod } // namespace drivers

@ -5,7 +5,7 @@
#include "driver/i2c.h" #include "driver/i2c.h"
#include "hal/i2c_types.h" #include "hal/i2c_types.h"
namespace gay_ipod { namespace drivers {
/* /*
* Convenience wrapper for performing an I2C transaction with a reasonable * Convenience wrapper for performing an I2C transaction with a reasonable
@ -81,4 +81,4 @@ class I2CTransaction {
uint8_t* buffer_; uint8_t* buffer_;
}; };
} // namespace gay_ipod } // namespace drivers

@ -17,7 +17,7 @@
#include "mp3_decoder.h" #include "mp3_decoder.h"
#include "result.hpp" #include "result.hpp"
namespace gay_ipod { namespace drivers {
class DacAudioPlayback { class DacAudioPlayback {
public: public:
@ -64,4 +64,4 @@ class DacAudioPlayback {
audio_element_handle_t mp3_decoder_; audio_element_handle_t mp3_decoder_;
}; };
} // namespace gay_ipod } // namespace drivers

@ -10,7 +10,7 @@
#include "esp_vfs_fat.h" #include "esp_vfs_fat.h"
#include "result.hpp" #include "result.hpp"
namespace gay_ipod { namespace drivers {
extern const char* kStoragePath; extern const char* kStoragePath;
@ -57,4 +57,4 @@ class SdStorage {
FATFS* fs_ = nullptr; FATFS* fs_ = nullptr;
}; };
} // namespace gay_ipod } // namespace drivers

@ -15,7 +15,7 @@
static const char* kTag = "PLAYBACK"; static const char* kTag = "PLAYBACK";
static const i2s_port_t kI2SPort = I2S_NUM_0; 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) { static audio_element_status_t status_from_the_void(void* status) {
uintptr_t as_pointer_int = reinterpret_cast<uintptr_t>(status); uintptr_t as_pointer_int = reinterpret_cast<uintptr_t>(status);
@ -243,4 +243,4 @@ auto DacAudioPlayback::volume() -> uint8_t {
return volume_; return volume_;
} }
} // namespace gay_ipod } // namespace drivers

@ -22,7 +22,7 @@
static const char* kTag = "SDSTORAGE"; static const char* kTag = "SDSTORAGE";
static const uint8_t kMaxOpenFiles = 8; static const uint8_t kMaxOpenFiles = 8;
namespace gay_ipod { namespace drivers {
const char* kStoragePath = "/sdcard"; const char* kStoragePath = "/sdcard";
@ -146,4 +146,4 @@ auto SdStorage::HandleTransaction(sdspi_dev_handle_t handle,
return do_transaction_(handle, cmdinfo); return do_transaction_(handle, cmdinfo);
} }
} // namespace gay_ipod } // namespace drivers

@ -104,13 +104,13 @@ static StaticTask_t sLvglTaskBuffer = {};
static StackType_t sLvglStack[kLvglStackSize] = {0}; static StackType_t sLvglStack[kLvglStackSize] = {0};
struct LvglArgs { struct LvglArgs {
gay_ipod::GpioExpander* gpio_expander; drivers::GpioExpander* gpio_expander;
}; };
void lvgl_main(void* voidArgs) { void lvgl_main(void* voidArgs) {
ESP_LOGI(TAG, "starting LVGL task"); ESP_LOGI(TAG, "starting LVGL task");
LvglArgs* args = (LvglArgs*)voidArgs; 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. // Dispose of the args now that we've gotten everything out of them.
delete args; delete args;
@ -123,12 +123,12 @@ void lvgl_main(void* voidArgs) {
ESP_LOGI(TAG, "init display"); ESP_LOGI(TAG, "init display");
auto display_res = 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()) { if (display_res.has_error()) {
ESP_LOGE(TAG, "Failed: %d", display_res.error()); ESP_LOGE(TAG, "Failed: %d", display_res.error());
return; 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); auto label = lv_label_create(NULL);
lv_label_set_text(label, "g'day, cunts!"); 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)); ESP_ERROR_CHECK(gpio_install_isr_service(ESP_INTR_FLAG_LOWMED));
init_i2c(); init_i2c();
init_spi(); init_spi();
ESP_ERROR_CHECK(gay_ipod::init_adc()); ESP_ERROR_CHECK(drivers::init_adc());
ESP_LOGI(TAG, "Init GPIOs"); ESP_LOGI(TAG, "Init GPIOs");
gay_ipod::GpioExpander* expander = new gay_ipod::GpioExpander(); drivers::GpioExpander* expander = new drivers::GpioExpander();
// for debugging usb ic // 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"); 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()) { if (storage_res.has_error()) {
ESP_LOGE(TAG, "Failed: %d", storage_res.error()); ESP_LOGE(TAG, "Failed: %d", storage_res.error());
return; 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"); 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()) { if (storage_res.has_error()) {
ESP_LOGE(TAG, "Failed: %d", dac_res.error()); ESP_LOGE(TAG, "Failed: %d", dac_res.error());
return; 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"); 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()) { if (playback_res.has_error()) {
ESP_LOGE(TAG, "Failed: %d", playback_res.error()); ESP_LOGE(TAG, "Failed: %d", playback_res.error());
return; return;
} }
std::unique_ptr<gay_ipod::DacAudioPlayback> playback = std::unique_ptr<drivers::DacAudioPlayback> playback =
std::move(playback_res.value()); std::move(playback_res.value());
*/ */

Loading…
Cancel
Save