diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-30 16:48:10 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-30 16:48:10 +1000 |
| commit | 320fdeb9d8355d3c361d5c6d60de8afc64501af9 (patch) | |
| tree | f0d5a2ab82199c78ad6768c6b18ba1239a0b7ee4 /src/drivers/include | |
| parent | 4247c9fe7d25c921fbfc73fc50e849c8780e7ad6 (diff) | |
| download | tangara-fw-320fdeb9d8355d3c361d5c6d60de8afc64501af9.tar.gz | |
Use a service locator instead of passing around subsets of drivers between FSMs
Diffstat (limited to 'src/drivers/include')
| -rw-r--r-- | src/drivers/include/display.hpp | 6 | ||||
| -rw-r--r-- | src/drivers/include/i2s_dac.hpp | 6 | ||||
| -rw-r--r-- | src/drivers/include/relative_wheel.hpp | 8 | ||||
| -rw-r--r-- | src/drivers/include/storage.hpp | 6 |
4 files changed, 11 insertions, 15 deletions
diff --git a/src/drivers/include/display.hpp b/src/drivers/include/display.hpp index 77165c99..766fc4ea 100644 --- a/src/drivers/include/display.hpp +++ b/src/drivers/include/display.hpp @@ -30,10 +30,10 @@ class Display { * over SPI. This never fails, since unfortunately these display don't give * us back any kind of signal to tell us we're actually using them correctly. */ - static auto Create(IGpios* expander, + static auto Create(IGpios& expander, const displays::InitialisationData& init_data) -> Display*; - Display(IGpios* gpio, spi_device_handle_t handle); + Display(IGpios& gpio, spi_device_handle_t handle); ~Display(); auto SetDisplayOn(bool) -> void; @@ -49,7 +49,7 @@ class Display { Display& operator=(const Display&) = delete; private: - IGpios* gpio_; + IGpios& gpio_; spi_device_handle_t handle_; std::unique_ptr<tasks::Worker> worker_task_; diff --git a/src/drivers/include/i2s_dac.hpp b/src/drivers/include/i2s_dac.hpp index c7faed2f..6bc5b6a4 100644 --- a/src/drivers/include/i2s_dac.hpp +++ b/src/drivers/include/i2s_dac.hpp @@ -33,9 +33,9 @@ namespace drivers { */ class I2SDac { public: - static auto create(IGpios* expander) -> std::optional<I2SDac*>; + static auto create(IGpios& expander) -> std::optional<I2SDac*>; - I2SDac(IGpios* gpio, i2s_chan_handle_t i2s_handle); + I2SDac(IGpios& gpio, i2s_chan_handle_t i2s_handle); ~I2SDac(); auto Start() -> void; @@ -69,7 +69,7 @@ class I2SDac { I2SDac& operator=(const I2SDac&) = delete; private: - IGpios* gpio_; + IGpios& gpio_; i2s_chan_handle_t i2s_handle_; bool i2s_active_; StreamBufferHandle_t buffer_; diff --git a/src/drivers/include/relative_wheel.hpp b/src/drivers/include/relative_wheel.hpp index 5e801aba..b5532a4c 100644 --- a/src/drivers/include/relative_wheel.hpp +++ b/src/drivers/include/relative_wheel.hpp @@ -20,11 +20,7 @@ namespace drivers { class RelativeWheel { public: - static auto Create(TouchWheel* touch) -> RelativeWheel* { - return new RelativeWheel(touch); - } - - explicit RelativeWheel(TouchWheel* touch); + explicit RelativeWheel(TouchWheel& touch); auto Update() -> void; auto SetEnabled(bool) -> void; @@ -37,7 +33,7 @@ class RelativeWheel { RelativeWheel& operator=(const RelativeWheel&) = delete; private: - TouchWheel* touch_; + TouchWheel& touch_; bool is_enabled_; diff --git a/src/drivers/include/storage.hpp b/src/drivers/include/storage.hpp index 65be75f1..0b0cb494 100644 --- a/src/drivers/include/storage.hpp +++ b/src/drivers/include/storage.hpp @@ -31,9 +31,9 @@ class SdStorage { FAILED_TO_MOUNT, }; - static auto Create(IGpios* gpio) -> cpp::result<SdStorage*, Error>; + static auto Create(IGpios& gpio) -> cpp::result<SdStorage*, Error>; - SdStorage(IGpios* gpio, + SdStorage(IGpios& gpio, sdspi_dev_handle_t handle_, std::unique_ptr<sdmmc_host_t> host_, std::unique_ptr<sdmmc_card_t> card_, @@ -50,7 +50,7 @@ class SdStorage { SdStorage& operator=(const SdStorage&) = delete; private: - IGpios* gpio_; + IGpios& gpio_; // SPI and SD driver info sdspi_dev_handle_t handle_; |
