diff --git a/common/pimoroni.hpp b/common/pimoroni.hpp new file mode 100644 index 00000000..5c1db512 --- /dev/null +++ b/common/pimoroni.hpp @@ -0,0 +1,35 @@ +#pragma once +#include +#include + +#define PIMORONI_I2C_DEFAULT_INSTANCE i2c0 +#define PIMORONI_SPI_DEFAULT_INSTANCE spi0 + +namespace pimoroni { + static const unsigned int PIN_UNUSED = UINT_MAX; + + // I2C + static const unsigned int I2C_DEFAULT_SDA = 20; + static const unsigned int I2C_DEFAULT_SCL = 21; + static const unsigned int I2C_DEFAULT_INT = 22; + + static const unsigned int I2C_BG_SDA = 4; + static const unsigned int I2C_BG_SCL = 5; + static const unsigned int I2C_BG_INT = 3; + + // SPI + static const unsigned int SPI_DEFAULT_MOSI = 19; + static const unsigned int SPI_DEFAULT_MISO = 16; + static const unsigned int SPI_DEFAULT_SCK = 18; + + static const unsigned int SPI_BG_FRONT_PWM = 20; + static const unsigned int SPI_BG_FRONT_CS = 17; + + static const unsigned int SPI_BG_BACK_PWM = 21; + static const unsigned int SPI_BG_BACK_CS = 22; + + enum BG_SPI_SLOT { + BG_SPI_FRONT, + BG_SPI_BACK + }; +} \ No newline at end of file diff --git a/drivers/msa301/msa301.hpp b/drivers/msa301/msa301.hpp index afdbc8ca..eb03ceca 100644 --- a/drivers/msa301/msa301.hpp +++ b/drivers/msa301/msa301.hpp @@ -2,6 +2,7 @@ #include "hardware/i2c.h" #include "hardware/gpio.h" +#include "common/pimoroni.hpp" namespace pimoroni { @@ -110,9 +111,10 @@ namespace pimoroni { // interface pins with our standard defaults where appropriate int8_t address = DEFAULT_I2C_ADDRESS; - int8_t sda = DEFAULT_SDA_PIN; - int8_t scl = DEFAULT_SCL_PIN; - int8_t interrupt = DEFAULT_INT_PIN; + uint sda = I2C_DEFAULT_SDA; + uint scl = I2C_DEFAULT_SCL; + uint interrupt = I2C_DEFAULT_INT; + i2c_inst_t *i2c = PIMORONI_I2C_DEFAULT_INSTANCE; //-------------------------------------------------- @@ -121,7 +123,7 @@ namespace pimoroni { public: MSA301() {} - MSA301(i2c_inst_t *i2c, uint8_t sda, uint8_t scl, uint8_t interrupt) : + MSA301(i2c_inst_t *i2c, uint sda, uint scl, uint interrupt) : i2c(i2c), sda(sda), scl(scl), interrupt(interrupt) {} diff --git a/drivers/rv3028/rv3028.hpp b/drivers/rv3028/rv3028.hpp index 4ef2f1ec..bc7c7f44 100644 --- a/drivers/rv3028/rv3028.hpp +++ b/drivers/rv3028/rv3028.hpp @@ -12,6 +12,7 @@ Distributed as-is; no warranty is given. #include "hardware/i2c.h" #include "hardware/gpio.h" +#include "common/pimoroni.hpp" #include #include @@ -206,13 +207,13 @@ namespace pimoroni { // Variables //-------------------------------------------------- private: - i2c_inst_t *i2c = i2c0; + i2c_inst_t *i2c = PIMORONI_I2C_DEFAULT_INSTANCE; // interface pins with our standard defaults where appropriate - int8_t address = DEFAULT_I2C_ADDRESS; - int8_t sda = DEFAULT_SDA_PIN; - int8_t scl = DEFAULT_SCL_PIN; - int8_t interrupt = DEFAULT_INT_PIN; + int8_t address = DEFAULT_I2C_ADDRESS; + uint sda = DEFAULT_SDA_PIN; + uint scl = DEFAULT_SCL_PIN; + uint interrupt = DEFAULT_INT_PIN; uint8_t times[TIME_ARRAY_LENGTH]; diff --git a/drivers/st7735/st7735.hpp b/drivers/st7735/st7735.hpp index a5214ec7..c3c7c832 100644 --- a/drivers/st7735/st7735.hpp +++ b/drivers/st7735/st7735.hpp @@ -2,6 +2,7 @@ #include "hardware/spi.h" #include "hardware/gpio.h" +#include "../../common/pimoroni.hpp" namespace pimoroni { @@ -20,17 +21,6 @@ namespace pimoroni { static const uint8_t ROWS = 162; static const uint8_t COLS = 132; - - //-------------------------------------------------- - // Enums - //-------------------------------------------------- - public: - enum BG_SPI_SLOT { - BG_SPI_FRONT, - BG_SPI_BACK - }; - - //-------------------------------------------------- // Variables //-------------------------------------------------- diff --git a/drivers/st7789/st7789.cpp b/drivers/st7789/st7789.cpp index 9729e53a..af73df5d 100644 --- a/drivers/st7789/st7789.cpp +++ b/drivers/st7789/st7789.cpp @@ -67,13 +67,13 @@ namespace pimoroni { gpio_set_function(sck, GPIO_FUNC_SPI); gpio_set_function(mosi, GPIO_FUNC_SPI); - if(miso != -1) { + if(miso != PIN_UNUSED) { gpio_set_function(miso, GPIO_FUNC_SPI); } // if supported by the display then the vsync pin is // toggled high during vertical blanking period - if(vsync != -1) { + if(vsync != PIN_UNUSED) { gpio_set_function(vsync, GPIO_FUNC_SIO); gpio_set_dir(vsync, GPIO_IN); gpio_set_pulls(vsync, false, true); @@ -81,7 +81,7 @@ namespace pimoroni { // if a backlight pin is provided then set it up for // pwm control - if(bl != -1) { + if(bl != PIN_UNUSED) { pwm_config cfg = pwm_get_default_config(); pwm_set_wrap(pwm_gpio_to_slice_num(bl), 65535); pwm_init(pwm_gpio_to_slice_num(bl), &cfg, true); @@ -180,23 +180,23 @@ namespace pimoroni { return spi; } - int ST7789::get_cs() const { + uint ST7789::get_cs() const { return cs; } - int ST7789::get_dc() const { + uint ST7789::get_dc() const { return dc; } - int ST7789::get_sck() const { + uint ST7789::get_sck() const { return sck; } - int ST7789::get_mosi() const { + uint ST7789::get_mosi() const { return mosi; } - int ST7789::get_bl() const { + uint ST7789::get_bl() const { return bl; } diff --git a/drivers/st7789/st7789.hpp b/drivers/st7789/st7789.hpp index 8407f575..029d739d 100644 --- a/drivers/st7789/st7789.hpp +++ b/drivers/st7789/st7789.hpp @@ -2,29 +2,12 @@ #include "hardware/spi.h" #include "hardware/gpio.h" +#include "../../common/pimoroni.hpp" namespace pimoroni { class ST7789 { - //-------------------------------------------------- - // Constants - //-------------------------------------------------- - public: - static const uint8_t DEFAULT_CS_PIN = 17; - static const uint8_t DEFAULT_DC_PIN = 16; - static const uint8_t DEFAULT_SCK_PIN = 18; - static const uint8_t DEFAULT_MOSI_PIN = 19; - static const uint8_t DEFAULT_BL_PIN = 20; - - - //-------------------------------------------------- - // Enums - //-------------------------------------------------- - public: - enum BG_SPI_SLOT { - BG_SPI_FRONT, - BG_SPI_BACK - }; + spi_inst_t *spi = PIMORONI_SPI_DEFAULT_INSTANCE; //-------------------------------------------------- @@ -35,42 +18,33 @@ namespace pimoroni { uint16_t width; uint16_t height; uint16_t row_stride; + uint32_t dma_channel; + + // interface pins with our standard defaults where appropriate + uint cs = SPI_BG_FRONT_CS; + uint dc = SPI_DEFAULT_MISO; + uint sck = SPI_DEFAULT_SCK; + uint mosi = SPI_DEFAULT_MOSI; + uint miso = PIN_UNUSED; // used as data/command + uint bl = SPI_BG_FRONT_PWM; + uint vsync = PIN_UNUSED; // only available on some products + + uint32_t spi_baud = 16 * 1000 * 1000; public: // frame buffer where pixel data is stored uint16_t *frame_buffer; - private: - spi_inst_t *spi = spi0; - - uint32_t dma_channel; - - // interface pins with our standard defaults where appropriate - int8_t cs = DEFAULT_CS_PIN; - int8_t dc = DEFAULT_DC_PIN; - int8_t sck = DEFAULT_SCK_PIN; - int8_t mosi = DEFAULT_MOSI_PIN; - int8_t miso = -1; // we generally don't use this pin - int8_t bl = DEFAULT_BL_PIN; - int8_t vsync = -1; // only available on some products - - uint32_t spi_baud = 16 * 1000 * 1000; - - - //-------------------------------------------------- - // Constructors/Destructor - //-------------------------------------------------- - public: ST7789(uint16_t width, uint16_t height, uint16_t *frame_buffer, BG_SPI_SLOT slot) : width(width), height(height), frame_buffer(frame_buffer) { switch(slot) { case BG_SPI_FRONT: - cs = 17; - bl = 20; + cs = SPI_BG_FRONT_CS; + bl = SPI_BG_FRONT_PWM; break; case BG_SPI_BACK: - cs = 22; - bl = 21; + cs = SPI_BG_BACK_CS; + bl = SPI_BG_BACK_PWM; break; } } @@ -80,9 +54,10 @@ namespace pimoroni { ST7789(uint16_t width, uint16_t height, uint16_t *frame_buffer, spi_inst_t *spi, - uint8_t cs, uint8_t dc, uint8_t sck, uint8_t mosi, uint8_t miso = -1, uint8_t bl = -1) : - width(width), height(height), frame_buffer(frame_buffer), - spi(spi), cs(cs), dc(dc), sck(sck), mosi(mosi), miso(miso), bl(bl) {} + uint cs, uint dc, uint sck, uint mosi, uint miso = PIN_UNUSED, uint bl = PIN_UNUSED) : + spi(spi), + width(width), height(height), + cs(cs), dc(dc), sck(sck), mosi(mosi), miso(miso), bl(bl), frame_buffer(frame_buffer) {} //-------------------------------------------------- @@ -92,11 +67,11 @@ namespace pimoroni { void init(bool auto_init_sequence = true, bool round = false); spi_inst_t* get_spi() const; - int get_cs() const; - int get_dc() const; - int get_sck() const; - int get_mosi() const; - int get_bl() const; + uint get_cs() const; + uint get_dc() const; + uint get_sck() const; + uint get_mosi() const; + uint get_bl() const; void command(uint8_t command, size_t len = 0, const char *data = NULL); void vsync_callback(gpio_irq_callback_t callback); diff --git a/examples/breakout_roundlcd/demo.cpp b/examples/breakout_roundlcd/demo.cpp index 51fe8f1d..103062e6 100644 --- a/examples/breakout_roundlcd/demo.cpp +++ b/examples/breakout_roundlcd/demo.cpp @@ -12,7 +12,7 @@ using namespace pimoroni; uint16_t buffer[BreakoutRoundLCD::WIDTH * BreakoutRoundLCD::HEIGHT]; -BreakoutRoundLCD display(buffer, ST7789::BG_SPI_FRONT); +BreakoutRoundLCD display(buffer, BG_SPI_FRONT); constexpr float RADIUS = BreakoutRoundLCD::WIDTH / 2; diff --git a/libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.cpp b/libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.cpp index f6469902..c2f035d8 100644 --- a/libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.cpp +++ b/libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.cpp @@ -13,7 +13,7 @@ namespace pimoroni { __fb = buf; } - BreakoutColourLCD160x80::BreakoutColourLCD160x80(uint16_t *buf, ST7735::BG_SPI_SLOT slot) + BreakoutColourLCD160x80::BreakoutColourLCD160x80(uint16_t *buf, BG_SPI_SLOT slot) : PicoGraphics(WIDTH, HEIGHT, buf), screen(WIDTH, HEIGHT, buf, slot) { __fb = buf; } diff --git a/libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.hpp b/libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.hpp index 7e628be7..bf75a916 100644 --- a/libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.hpp +++ b/libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.hpp @@ -2,6 +2,7 @@ #include "drivers/st7735/st7735.hpp" #include "libraries/pico_graphics/pico_graphics.hpp" +#include "common/pimoroni.hpp" namespace pimoroni { @@ -31,7 +32,7 @@ namespace pimoroni { BreakoutColourLCD160x80(uint16_t *buf); BreakoutColourLCD160x80(uint16_t *buf, spi_inst_t *spi, uint8_t cs, uint8_t dc, uint8_t sck, uint8_t mosi, uint8_t miso = PIN_UNUSED, uint8_t bl = PIN_UNUSED); - BreakoutColourLCD160x80(uint16_t *buf, ST7735::BG_SPI_SLOT slot); + BreakoutColourLCD160x80(uint16_t *buf, BG_SPI_SLOT slot); //-------------------------------------------------- diff --git a/libraries/breakout_colourlcd240x240/breakout_colourlcd240x240.cpp b/libraries/breakout_colourlcd240x240/breakout_colourlcd240x240.cpp index 3cf1cad6..83427e72 100644 --- a/libraries/breakout_colourlcd240x240/breakout_colourlcd240x240.cpp +++ b/libraries/breakout_colourlcd240x240/breakout_colourlcd240x240.cpp @@ -13,7 +13,7 @@ namespace pimoroni { __fb = buf; } - BreakoutColourLCD240x240::BreakoutColourLCD240x240(uint16_t *buf, ST7789::BG_SPI_SLOT slot) + BreakoutColourLCD240x240::BreakoutColourLCD240x240(uint16_t *buf, BG_SPI_SLOT slot) : PicoGraphics(WIDTH, HEIGHT, buf), screen(WIDTH, HEIGHT, buf, slot) { __fb = buf; } diff --git a/libraries/breakout_colourlcd240x240/breakout_colourlcd240x240.hpp b/libraries/breakout_colourlcd240x240/breakout_colourlcd240x240.hpp index 470b8d70..16e5e773 100644 --- a/libraries/breakout_colourlcd240x240/breakout_colourlcd240x240.hpp +++ b/libraries/breakout_colourlcd240x240/breakout_colourlcd240x240.hpp @@ -2,6 +2,7 @@ #include "drivers/st7789/st7789.hpp" #include "libraries/pico_graphics/pico_graphics.hpp" +#include "common/pimoroni.hpp" namespace pimoroni { @@ -31,7 +32,7 @@ namespace pimoroni { BreakoutColourLCD240x240(uint16_t *buf); BreakoutColourLCD240x240(uint16_t *buf, spi_inst_t *spi, uint8_t cs, uint8_t dc, uint8_t sck, uint8_t mosi, uint8_t miso = PIN_UNUSED, uint8_t bl = PIN_UNUSED); - BreakoutColourLCD240x240(uint16_t *buf, ST7789::BG_SPI_SLOT slot); + BreakoutColourLCD240x240(uint16_t *buf, BG_SPI_SLOT slot); //-------------------------------------------------- diff --git a/libraries/breakout_roundlcd/breakout_roundlcd.cpp b/libraries/breakout_roundlcd/breakout_roundlcd.cpp index 2e27134d..49a639da 100644 --- a/libraries/breakout_roundlcd/breakout_roundlcd.cpp +++ b/libraries/breakout_roundlcd/breakout_roundlcd.cpp @@ -8,13 +8,12 @@ namespace pimoroni { } BreakoutRoundLCD::BreakoutRoundLCD(uint16_t *buf, spi_inst_t *spi, - uint8_t cs, uint8_t dc, uint8_t sck, uint8_t mosi, uint8_t miso, uint8_t bl) + uint cs, uint dc, uint sck, uint mosi, uint miso, uint bl) : PicoGraphics(WIDTH, HEIGHT, buf), screen(WIDTH, HEIGHT, buf, spi, cs, dc, sck, mosi, miso, bl) { __fb = buf; } - BreakoutRoundLCD::BreakoutRoundLCD(uint16_t *buf, ST7789::BG_SPI_SLOT slot) - : PicoGraphics(WIDTH, HEIGHT, buf), screen(WIDTH, HEIGHT, buf, slot) { + BreakoutRoundLCD::BreakoutRoundLCD(uint16_t *buf, BG_SPI_SLOT slot) : PicoGraphics(WIDTH, HEIGHT, buf), screen(WIDTH, HEIGHT, buf, slot) { __fb = buf; } diff --git a/libraries/breakout_roundlcd/breakout_roundlcd.hpp b/libraries/breakout_roundlcd/breakout_roundlcd.hpp index 9d0c07e0..24c82ed6 100644 --- a/libraries/breakout_roundlcd/breakout_roundlcd.hpp +++ b/libraries/breakout_roundlcd/breakout_roundlcd.hpp @@ -31,8 +31,8 @@ namespace pimoroni { public: BreakoutRoundLCD(uint16_t *buf); BreakoutRoundLCD(uint16_t *buf, spi_inst_t *spi, - uint8_t cs, uint8_t dc, uint8_t sck, uint8_t mosi, uint8_t miso = PIN_UNUSED, uint8_t bl = PIN_UNUSED); - BreakoutRoundLCD(uint16_t *buf, ST7789::BG_SPI_SLOT slot); + uint cs, uint dc, uint sck, uint mosi, uint miso = PIN_UNUSED, uint bl = PIN_UNUSED); + BreakoutRoundLCD(uint16_t *buf, BG_SPI_SLOT slot); //-------------------------------------------------- diff --git a/libraries/pico_explorer/pico_explorer.cpp b/libraries/pico_explorer/pico_explorer.cpp index 0d160686..5c416a25 100644 --- a/libraries/pico_explorer/pico_explorer.cpp +++ b/libraries/pico_explorer/pico_explorer.cpp @@ -95,7 +95,7 @@ namespace pimoroni { } } - void PicoExplorer::set_audio_pin(uint8_t pin) { + void PicoExplorer::set_audio_pin(uint pin) { pwm_config tone_pwm_cfg = pwm_get_default_config(); // calculate the pwm wrap value for this frequency diff --git a/libraries/pico_explorer/pico_explorer.hpp b/libraries/pico_explorer/pico_explorer.hpp index 0cee484c..3c5217ee 100644 --- a/libraries/pico_explorer/pico_explorer.hpp +++ b/libraries/pico_explorer/pico_explorer.hpp @@ -9,10 +9,10 @@ namespace pimoroni { public: static const int WIDTH = 240; static const int HEIGHT = 240; - static const uint8_t A = 12; - static const uint8_t B = 13; - static const uint8_t X = 14; - static const uint8_t Y = 15; + static const uint A = 12; + static const uint B = 13; + static const uint X = 14; + static const uint Y = 15; static const uint8_t ADC0 = 0; static const uint8_t ADC1 = 1; @@ -25,14 +25,14 @@ namespace pimoroni { static const uint8_t REVERSE = 1; static const uint8_t STOP = 2; - static const uint8_t GP0 = 0; - static const uint8_t GP1 = 1; - static const uint8_t GP2 = 2; - static const uint8_t GP3 = 3; - static const uint8_t GP4 = 4; - static const uint8_t GP5 = 5; - static const uint8_t GP6 = 6; - static const uint8_t GP7 = 7; + static const uint GP0 = 0; + static const uint GP1 = 1; + static const uint GP2 = 2; + static const uint GP3 = 3; + static const uint GP4 = 4; + static const uint GP5 = 5; + static const uint GP6 = 6; + static const uint GP7 = 7; uint16_t *__fb; private: @@ -50,7 +50,7 @@ namespace pimoroni { void set_motor(uint8_t channel, uint8_t action, float speed = 0.0f); - void set_audio_pin(uint8_t pin); + void set_audio_pin(uint pin); void set_tone(uint16_t frequency, float duty = 0.2f); }; diff --git a/micropython/modules/breakout_colourlcd160x80/breakout_colourlcd160x80.cpp b/micropython/modules/breakout_colourlcd160x80/breakout_colourlcd160x80.cpp index 967be361..42bc4d6c 100644 --- a/micropython/modules/breakout_colourlcd160x80/breakout_colourlcd160x80.cpp +++ b/micropython/modules/breakout_colourlcd160x80/breakout_colourlcd160x80.cpp @@ -63,14 +63,14 @@ mp_obj_t BreakoutColourLCD160x80_make_new(const mp_obj_type_t *type, size_t n_ar mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); int slot = args[ARG_slot].u_int; - if(slot == ST7735::BG_SPI_FRONT || slot == ST7735::BG_SPI_BACK) { + if(slot == BG_SPI_FRONT || slot == BG_SPI_BACK) { self = m_new_obj(breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t); self->base.type = &breakout_colourlcd160x80_BreakoutColourLCD160x80_type; mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_RW); - self->breakout = new BreakoutColourLCD160x80((uint16_t *)bufinfo.buf, (ST7735::BG_SPI_SLOT)slot); + self->breakout = new BreakoutColourLCD160x80((uint16_t *)bufinfo.buf, (BG_SPI_SLOT)slot); } else { mp_raise_ValueError("slot not a valid value. Expected 0 to 1"); diff --git a/micropython/modules/breakout_colourlcd240x240/breakout_colourlcd240x240.cpp b/micropython/modules/breakout_colourlcd240x240/breakout_colourlcd240x240.cpp index 8927d5f7..642d9638 100644 --- a/micropython/modules/breakout_colourlcd240x240/breakout_colourlcd240x240.cpp +++ b/micropython/modules/breakout_colourlcd240x240/breakout_colourlcd240x240.cpp @@ -63,14 +63,14 @@ mp_obj_t BreakoutColourLCD240x240_make_new(const mp_obj_type_t *type, size_t n_a mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); int slot = args[ARG_slot].u_int; - if(slot == ST7789::BG_SPI_FRONT || slot == ST7789::BG_SPI_BACK) { + if(slot == BG_SPI_FRONT || slot == BG_SPI_BACK) { self = m_new_obj(breakout_colourlcd240x240_BreakoutColourLCD240x240_obj_t); self->base.type = &breakout_colourlcd240x240_BreakoutColourLCD240x240_type; mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_RW); - self->breakout = new BreakoutColourLCD240x240((uint16_t *)bufinfo.buf, (ST7789::BG_SPI_SLOT)slot); + self->breakout = new BreakoutColourLCD240x240((uint16_t *)bufinfo.buf, (BG_SPI_SLOT)slot); } else { mp_raise_ValueError("slot not a valid value. Expected 0 to 1"); @@ -81,11 +81,11 @@ mp_obj_t BreakoutColourLCD240x240_make_new(const mp_obj_type_t *type, size_t n_a static const mp_arg_t allowed_args[] = { { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_spi, MP_ARG_INT, {.u_int = -1} }, - { MP_QSTR_cs, MP_ARG_INT, {.u_int = ST7789::DEFAULT_CS_PIN} }, - { MP_QSTR_dc, MP_ARG_INT, {.u_int = ST7789::DEFAULT_DC_PIN} }, - { MP_QSTR_sck, MP_ARG_INT, {.u_int = ST7789::DEFAULT_SCK_PIN} }, - { MP_QSTR_mosi, MP_ARG_INT, {.u_int = ST7789::DEFAULT_MOSI_PIN} }, - { MP_QSTR_bl, MP_ARG_INT, {.u_int = ST7789::DEFAULT_BL_PIN} }, + { MP_QSTR_cs, MP_ARG_INT, {.u_int = pimoroni::SPI_BG_FRONT_CS} }, + { MP_QSTR_dc, MP_ARG_INT, {.u_int = pimoroni::SPI_DEFAULT_MISO} }, + { MP_QSTR_sck, MP_ARG_INT, {.u_int = pimoroni::SPI_DEFAULT_SCK} }, + { MP_QSTR_mosi, MP_ARG_INT, {.u_int = pimoroni::SPI_DEFAULT_MOSI} }, + { MP_QSTR_bl, MP_ARG_INT, {.u_int = pimoroni::SPI_BG_FRONT_PWM} }, }; // Parse args. diff --git a/micropython/modules/breakout_roundlcd/breakout_roundlcd.cpp b/micropython/modules/breakout_roundlcd/breakout_roundlcd.cpp index 624db96d..901aa9dd 100644 --- a/micropython/modules/breakout_roundlcd/breakout_roundlcd.cpp +++ b/micropython/modules/breakout_roundlcd/breakout_roundlcd.cpp @@ -63,14 +63,14 @@ mp_obj_t BreakoutRoundLCD_make_new(const mp_obj_type_t *type, size_t n_args, siz mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); int slot = args[ARG_slot].u_int; - if(slot == ST7789::BG_SPI_FRONT || slot == ST7789::BG_SPI_BACK) { + if(slot == BG_SPI_FRONT || slot == BG_SPI_BACK) { self = m_new_obj(breakout_roundlcd_BreakoutRoundLCD_obj_t); self->base.type = &breakout_roundlcd_BreakoutRoundLCD_type; mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_RW); - self->breakout = new BreakoutRoundLCD((uint16_t *)bufinfo.buf, (ST7789::BG_SPI_SLOT)slot); + self->breakout = new BreakoutRoundLCD((uint16_t *)bufinfo.buf, (BG_SPI_SLOT)slot); } else { mp_raise_ValueError("slot not a valid value. Expected 0 to 1"); @@ -81,11 +81,11 @@ mp_obj_t BreakoutRoundLCD_make_new(const mp_obj_type_t *type, size_t n_args, siz static const mp_arg_t allowed_args[] = { { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_spi, MP_ARG_INT, {.u_int = -1} }, - { MP_QSTR_cs, MP_ARG_INT, {.u_int = ST7789::DEFAULT_CS_PIN} }, - { MP_QSTR_dc, MP_ARG_INT, {.u_int = ST7789::DEFAULT_DC_PIN} }, - { MP_QSTR_sck, MP_ARG_INT, {.u_int = ST7789::DEFAULT_SCK_PIN} }, - { MP_QSTR_mosi, MP_ARG_INT, {.u_int = ST7789::DEFAULT_MOSI_PIN} }, - { MP_QSTR_bl, MP_ARG_INT, {.u_int = ST7789::DEFAULT_BL_PIN} }, + { MP_QSTR_cs, MP_ARG_INT, {.u_int = pimoroni::SPI_BG_FRONT_CS} }, + { MP_QSTR_dc, MP_ARG_INT, {.u_int = pimoroni::SPI_DEFAULT_MISO} }, + { MP_QSTR_sck, MP_ARG_INT, {.u_int = pimoroni::SPI_DEFAULT_SCK} }, + { MP_QSTR_mosi, MP_ARG_INT, {.u_int = pimoroni::SPI_DEFAULT_MOSI} }, + { MP_QSTR_bl, MP_ARG_INT, {.u_int = pimoroni::SPI_BG_FRONT_PWM} }, }; // Parse args.