kopia lustrzana https://github.com/pimoroni/pimoroni-pico
ST7735: Update 160x80 LCD to new PicoGraphics<PenRGB565>
rodzic
cf6b6e04f4
commit
1a251822f5
|
@ -67,7 +67,6 @@ namespace pimoroni {
|
||||||
};
|
};
|
||||||
|
|
||||||
void ST7735::init(bool auto_init_sequence) {
|
void ST7735::init(bool auto_init_sequence) {
|
||||||
// configure spi interface and pins
|
|
||||||
spi_init(spi, spi_baud);
|
spi_init(spi, spi_baud);
|
||||||
|
|
||||||
gpio_set_function(dc, GPIO_FUNC_SIO);
|
gpio_set_function(dc, GPIO_FUNC_SIO);
|
||||||
|
@ -76,21 +75,9 @@ namespace pimoroni {
|
||||||
gpio_set_function(cs, GPIO_FUNC_SIO);
|
gpio_set_function(cs, GPIO_FUNC_SIO);
|
||||||
gpio_set_dir(cs, GPIO_OUT);
|
gpio_set_dir(cs, GPIO_OUT);
|
||||||
|
|
||||||
gpio_set_function(sck, GPIO_FUNC_SPI);
|
gpio_set_function(sck, GPIO_FUNC_SPI);
|
||||||
gpio_set_function(mosi, GPIO_FUNC_SPI);
|
gpio_set_function(mosi, GPIO_FUNC_SPI);
|
||||||
|
|
||||||
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 != PIN_UNUSED) {
|
|
||||||
gpio_set_function(vsync, GPIO_FUNC_SIO);
|
|
||||||
gpio_set_dir(vsync, GPIO_IN);
|
|
||||||
gpio_set_pulls(vsync, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if a backlight pin is provided then set it up for
|
// if a backlight pin is provided then set it up for
|
||||||
// pwm control
|
// pwm control
|
||||||
if(bl != PIN_UNUSED) {
|
if(bl != PIN_UNUSED) {
|
||||||
|
@ -98,6 +85,7 @@ namespace pimoroni {
|
||||||
pwm_set_wrap(pwm_gpio_to_slice_num(bl), 65535);
|
pwm_set_wrap(pwm_gpio_to_slice_num(bl), 65535);
|
||||||
pwm_init(pwm_gpio_to_slice_num(bl), &cfg, true);
|
pwm_init(pwm_gpio_to_slice_num(bl), &cfg, true);
|
||||||
gpio_set_function(bl, GPIO_FUNC_PWM);
|
gpio_set_function(bl, GPIO_FUNC_PWM);
|
||||||
|
set_backlight(0); // Turn backlight off initially to avoid nasty surprises
|
||||||
}
|
}
|
||||||
|
|
||||||
// if auto_init_sequence then send initialisation sequence
|
// if auto_init_sequence then send initialisation sequence
|
||||||
|
@ -155,30 +143,10 @@ namespace pimoroni {
|
||||||
command(reg::DISPON);
|
command(reg::DISPON);
|
||||||
sleep_ms(100);
|
sleep_ms(100);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
spi_inst_t* ST7735::get_spi() const {
|
if(bl != PIN_UNUSED) {
|
||||||
return spi;
|
set_backlight(255); // Turn backlight on now surprises have passed
|
||||||
}
|
}
|
||||||
|
|
||||||
int ST7735::get_cs() const {
|
|
||||||
return cs;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ST7735::get_dc() const {
|
|
||||||
return dc;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ST7735::get_sck() const {
|
|
||||||
return sck;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ST7735::get_mosi() const {
|
|
||||||
return mosi;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ST7735::get_bl() const {
|
|
||||||
return bl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST7735::command(uint8_t command, size_t len, const char *data) {
|
void ST7735::command(uint8_t command, size_t len, const char *data) {
|
||||||
|
@ -196,23 +164,21 @@ namespace pimoroni {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Native 16-bit framebuffer update
|
// Native 16-bit framebuffer update
|
||||||
void ST7735::update() {
|
void ST7735::update(PicoGraphics<PenRGB565> *graphics) {
|
||||||
command(reg::RAMWR, width * height * sizeof(uint16_t), (const char*)frame_buffer);
|
command(reg::RAMWR, width * height * sizeof(uint16_t), (const char*)graphics->get_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8-bit framebuffer with palette conversion update
|
// 8-bit framebuffer with palette conversion update
|
||||||
void ST7735::update(uint16_t *palette) {
|
void ST7735::update(PicoGraphics<PenRGB332> *graphics) {
|
||||||
command(reg::RAMWR);
|
command(reg::RAMWR);
|
||||||
uint16_t row[width];
|
|
||||||
gpio_put(dc, 1); // data mode
|
gpio_put(dc, 1); // data mode
|
||||||
gpio_put(cs, 0);
|
gpio_put(cs, 0);
|
||||||
|
|
||||||
|
uint16_t row_buf[width];
|
||||||
for(auto y = 0u; y < height; y++) {
|
for(auto y = 0u; y < height; y++) {
|
||||||
for(auto x = 0u; x < width; x++) {
|
graphics->get_data(y, &row_buf);
|
||||||
auto i = y * width + x;
|
|
||||||
row[x] = palette[((uint8_t *)frame_buffer)[i]];
|
|
||||||
}
|
|
||||||
// TODO: Add DMA->SPI / PIO while we prep the next row
|
// TODO: Add DMA->SPI / PIO while we prep the next row
|
||||||
spi_write_blocking(spi, (const uint8_t*)row, width * sizeof(uint16_t));
|
spi_write_blocking(spi, (const uint8_t*)row_buf, width * sizeof(uint16_t));
|
||||||
}
|
}
|
||||||
gpio_put(cs, 1);
|
gpio_put(cs, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
#include "hardware/spi.h"
|
#include "hardware/spi.h"
|
||||||
#include "hardware/gpio.h"
|
#include "hardware/gpio.h"
|
||||||
#include "../../common/pimoroni_common.hpp"
|
#include "common/pimoroni_common.hpp"
|
||||||
|
#include "common/pimoroni_bus.hpp"
|
||||||
|
#include "libraries/pico_graphics/pico_graphics.hpp"
|
||||||
|
|
||||||
namespace pimoroni {
|
namespace pimoroni {
|
||||||
|
|
||||||
|
@ -10,13 +12,6 @@ namespace pimoroni {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// Constants
|
// 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;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint8_t ROWS = 162;
|
static const uint8_t ROWS = 162;
|
||||||
static const uint8_t COLS = 132;
|
static const uint8_t COLS = 132;
|
||||||
|
@ -28,81 +23,46 @@ namespace pimoroni {
|
||||||
// screen properties
|
// screen properties
|
||||||
uint16_t width;
|
uint16_t width;
|
||||||
uint16_t height;
|
uint16_t height;
|
||||||
uint16_t row_stride;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// frame buffer where pixel data is stored
|
|
||||||
void *frame_buffer;
|
|
||||||
|
|
||||||
private:
|
|
||||||
spi_inst_t *spi = spi0;
|
spi_inst_t *spi = spi0;
|
||||||
|
|
||||||
uint32_t dma_channel;
|
uint32_t dma_channel;
|
||||||
|
|
||||||
// interface pins with our standard defaults where appropriate
|
// interface pins with our standard defaults where appropriate
|
||||||
uint cs = DEFAULT_CS_PIN;
|
uint cs;
|
||||||
uint dc = DEFAULT_DC_PIN;
|
uint dc;
|
||||||
uint sck = DEFAULT_SCK_PIN;
|
uint sck;
|
||||||
uint mosi = DEFAULT_MOSI_PIN;
|
uint mosi;
|
||||||
uint miso = PIN_UNUSED; // we generally don't use this pin
|
uint bl;
|
||||||
uint bl = DEFAULT_BL_PIN;
|
|
||||||
uint vsync = PIN_UNUSED; // only available on some products
|
|
||||||
|
|
||||||
uint32_t spi_baud = 30 * 1024 * 1024;
|
uint32_t spi_baud = 30 * 1024 * 1024;
|
||||||
|
|
||||||
uint8_t offset_cols = 0;
|
uint8_t offset_cols = 0;
|
||||||
uint8_t offset_rows = 0;
|
uint8_t offset_rows = 0;
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// Constructors/Destructor
|
// Constructors/Destructor
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public:
|
public:
|
||||||
ST7735(uint16_t width, uint16_t height, void *frame_buffer, BG_SPI_SLOT slot) :
|
ST7735(uint16_t width, uint16_t height, SPIPins pins) :
|
||||||
width(width), height(height), frame_buffer(frame_buffer) {
|
width(width), height(height),
|
||||||
switch(slot) {
|
spi(pins.spi), cs(pins.cs), dc(pins.dc), sck(pins.sck), mosi(pins.mosi), bl(pins.bl) {
|
||||||
case PICO_EXPLORER_ONBOARD: // Don't read too much into this, the case is just here to avoid a compile error
|
init();
|
||||||
cs = SPI_BG_FRONT_CS;
|
|
||||||
bl = PIN_UNUSED;
|
|
||||||
break;
|
|
||||||
case BG_SPI_FRONT:
|
|
||||||
cs = SPI_BG_FRONT_CS;
|
|
||||||
bl = SPI_BG_FRONT_PWM;
|
|
||||||
break;
|
|
||||||
case BG_SPI_BACK:
|
|
||||||
cs = SPI_BG_BACK_CS;
|
|
||||||
bl = SPI_BG_BACK_PWM;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ST7735(uint16_t width, uint16_t height, void *frame_buffer) :
|
|
||||||
width(width), height(height), frame_buffer(frame_buffer) {}
|
|
||||||
|
|
||||||
ST7735(uint16_t width, uint16_t height, void *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) {}
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// Methods
|
// Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public:
|
public:
|
||||||
void init(bool auto_init_sequence = true);
|
// Update functions for supported Pen types
|
||||||
|
void update(PicoGraphics<PenRGB565> *graphics);
|
||||||
spi_inst_t* get_spi() const;
|
void update(PicoGraphics<PenRGB332> *graphics);
|
||||||
int get_cs() const;
|
|
||||||
int get_dc() const;
|
|
||||||
int get_sck() const;
|
|
||||||
int get_mosi() const;
|
|
||||||
int get_bl() const;
|
|
||||||
|
|
||||||
void command(uint8_t command, size_t len = 0, const char *data = NULL);
|
|
||||||
void update();
|
|
||||||
void update(uint16_t *palette);
|
|
||||||
void set_backlight(uint8_t brightness);
|
void set_backlight(uint8_t brightness);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init(bool auto_init_sequence = true);
|
||||||
|
void command(uint8_t command, size_t len = 0, const char *data = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace pimoroni {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Parallel init
|
// Parallel init
|
||||||
ST7789(uint16_t width, uint16_t height, Rotation rotation, void *frame_buffer, ParallelPins pins) :
|
ST7789(uint16_t width, uint16_t height, Rotation rotation, ParallelPins pins) :
|
||||||
spi(nullptr),
|
spi(nullptr),
|
||||||
width(width), height(height), rotation(rotation), round(false),
|
width(width), height(height), rotation(rotation), round(false),
|
||||||
cs(pins.cs), dc(pins.dc), wr_sck(pins.wr_sck), rd_sck(pins.rd_sck), d0(pins.d0), bl(pins.bl) {
|
cs(pins.cs), dc(pins.dc), wr_sck(pins.wr_sck), rd_sck(pins.rd_sck), d0(pins.d0), bl(pins.bl) {
|
||||||
|
@ -65,7 +65,7 @@ namespace pimoroni {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serial init
|
// Serial init
|
||||||
ST7789(uint16_t width, uint16_t height, Rotation rotation, bool round, void *frame_buffer, SPIPins pins) :
|
ST7789(uint16_t width, uint16_t height, Rotation rotation, bool round, SPIPins pins) :
|
||||||
spi(pins.spi),
|
spi(pins.spi),
|
||||||
width(width), height(height), rotation(rotation), round(round),
|
width(width), height(height), rotation(rotation), round(round),
|
||||||
cs(pins.cs), dc(pins.dc), wr_sck(pins.sck), d0(pins.mosi), bl(pins.bl) {
|
cs(pins.cs), dc(pins.dc), wr_sck(pins.sck), d0(pins.mosi), bl(pins.bl) {
|
||||||
|
|
|
@ -2,57 +2,5 @@
|
||||||
|
|
||||||
namespace pimoroni {
|
namespace pimoroni {
|
||||||
|
|
||||||
BreakoutColourLCD160x80::BreakoutColourLCD160x80(void *buf)
|
|
||||||
: PicoGraphics(WIDTH, HEIGHT, buf), screen(WIDTH, HEIGHT, buf) {
|
|
||||||
__fb = buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
BreakoutColourLCD160x80::BreakoutColourLCD160x80(void *buf, spi_inst_t *spi,
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
BreakoutColourLCD160x80::BreakoutColourLCD160x80(void *buf, BG_SPI_SLOT slot)
|
|
||||||
: PicoGraphics(WIDTH, HEIGHT, buf), screen(WIDTH, HEIGHT, buf, slot) {
|
|
||||||
__fb = buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakoutColourLCD160x80::init() {
|
|
||||||
// initialise the screen
|
|
||||||
screen.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
spi_inst_t* BreakoutColourLCD160x80::get_spi() const {
|
|
||||||
return screen.get_spi();
|
|
||||||
}
|
|
||||||
|
|
||||||
int BreakoutColourLCD160x80::get_cs() const {
|
|
||||||
return screen.get_cs();
|
|
||||||
}
|
|
||||||
|
|
||||||
int BreakoutColourLCD160x80::get_dc() const {
|
|
||||||
return screen.get_dc();
|
|
||||||
}
|
|
||||||
|
|
||||||
int BreakoutColourLCD160x80::get_sck() const {
|
|
||||||
return screen.get_sck();
|
|
||||||
}
|
|
||||||
|
|
||||||
int BreakoutColourLCD160x80::get_mosi() const {
|
|
||||||
return screen.get_mosi();
|
|
||||||
}
|
|
||||||
|
|
||||||
int BreakoutColourLCD160x80::get_bl() const {
|
|
||||||
return screen.get_bl();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakoutColourLCD160x80::update() {
|
|
||||||
screen.update(palette);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakoutColourLCD160x80::set_backlight(uint8_t brightness) {
|
|
||||||
screen.set_backlight(brightness);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,10 +3,11 @@
|
||||||
#include "drivers/st7735/st7735.hpp"
|
#include "drivers/st7735/st7735.hpp"
|
||||||
#include "libraries/pico_graphics/pico_graphics.hpp"
|
#include "libraries/pico_graphics/pico_graphics.hpp"
|
||||||
#include "common/pimoroni_common.hpp"
|
#include "common/pimoroni_common.hpp"
|
||||||
|
#include "common/pimoroni_bus.hpp"
|
||||||
|
|
||||||
namespace pimoroni {
|
namespace pimoroni {
|
||||||
|
|
||||||
class BreakoutColourLCD160x80 : public PicoGraphics {
|
class BreakoutColourLCD160x80 : public PicoGraphics<PenRGB565> {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// Constants
|
// Constants
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
@ -17,8 +18,6 @@ namespace pimoroni {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// Variables
|
// Variables
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public:
|
|
||||||
void *__fb;
|
|
||||||
private:
|
private:
|
||||||
ST7735 screen;
|
ST7735 screen;
|
||||||
|
|
||||||
|
@ -27,27 +26,22 @@ namespace pimoroni {
|
||||||
// Constructors/Destructor
|
// Constructors/Destructor
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public:
|
public:
|
||||||
BreakoutColourLCD160x80(void *buf);
|
|
||||||
BreakoutColourLCD160x80(void *buf, spi_inst_t *spi,
|
|
||||||
uint cs, uint dc, uint sck, uint mosi, uint miso = PIN_UNUSED, uint bl = PIN_UNUSED);
|
|
||||||
BreakoutColourLCD160x80(void *buf, BG_SPI_SLOT slot);
|
|
||||||
|
|
||||||
|
BreakoutColourLCD160x80(void *frame_buffer)
|
||||||
|
: BreakoutColourLCD160x80(frame_buffer, get_spi_pins(BG_SPI_FRONT)) {
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
BreakoutColourLCD160x80(void *frame_buffer, SPIPins bus_pins)
|
||||||
// Methods
|
: PicoGraphics<PenRGB565>(WIDTH, HEIGHT, frame_buffer), screen(WIDTH, HEIGHT, bus_pins){
|
||||||
//--------------------------------------------------
|
}
|
||||||
public:
|
|
||||||
void init();
|
|
||||||
|
|
||||||
spi_inst_t* get_spi() const;
|
void update() {
|
||||||
int get_cs() const;
|
screen.update(this);
|
||||||
int get_dc() const;
|
}
|
||||||
int get_sck() const;
|
|
||||||
int get_mosi() const;
|
|
||||||
int get_bl() const;
|
|
||||||
|
|
||||||
void update();
|
void set_backlight(uint8_t brightness) {
|
||||||
void set_backlight(uint8_t brightness);
|
screen.set_backlight(brightness);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,8 +260,8 @@ namespace pimoroni {
|
||||||
public:
|
public:
|
||||||
void *frame_buffer;
|
void *frame_buffer;
|
||||||
|
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
Rect clip;
|
Rect clip;
|
||||||
|
|
||||||
const bitmap::font_t *font;
|
const bitmap::font_t *font;
|
||||||
|
|
||||||
|
@ -271,8 +271,8 @@ namespace pimoroni {
|
||||||
PicoGraphics(uint16_t width, uint16_t height, void *frame_buffer)
|
PicoGraphics(uint16_t width, uint16_t height, void *frame_buffer)
|
||||||
: frame_buffer(frame_buffer), bounds(0, 0, width, height), clip(0, 0, width, height) {
|
: frame_buffer(frame_buffer), bounds(0, 0, width, height), clip(0, 0, width, height) {
|
||||||
set_font(&font6);
|
set_font(&font6);
|
||||||
if(frame_buffer == nullptr) {
|
if(this->frame_buffer == nullptr) {
|
||||||
frame_buffer = (void *)(new uint8_t[pen.buffer_size(width, height)]);
|
this->frame_buffer = (void *)(new uint8_t[pen.buffer_size(width, height)]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ namespace pimoroni {
|
||||||
void set_clip(const Rect &r);
|
void set_clip(const Rect &r);
|
||||||
void remove_clip();
|
void remove_clip();
|
||||||
|
|
||||||
void* get_data() {
|
void *get_data() {
|
||||||
return frame_buffer;
|
return frame_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,19 +14,19 @@ namespace pimoroni {
|
||||||
public:
|
public:
|
||||||
PicoGraphicsST7789(uint16_t width, uint16_t height, Rotation rotation, bool round=false, void *frame_buffer=nullptr) :
|
PicoGraphicsST7789(uint16_t width, uint16_t height, Rotation rotation, bool round=false, void *frame_buffer=nullptr) :
|
||||||
PicoGraphics<T>(width, height, frame_buffer),
|
PicoGraphics<T>(width, height, frame_buffer),
|
||||||
st7789(width, height, rotation, round, frame_buffer, get_spi_pins(BG_SPI_FRONT)) {
|
st7789(width, height, rotation, round, get_spi_pins(BG_SPI_FRONT)) {
|
||||||
common_init();
|
common_init();
|
||||||
};
|
};
|
||||||
|
|
||||||
PicoGraphicsST7789(uint16_t width, uint16_t height, Rotation rotation, bool round, void *frame_buffer, SPIPins bus_pins) :
|
PicoGraphicsST7789(uint16_t width, uint16_t height, Rotation rotation, bool round, void *frame_buffer, SPIPins bus_pins) :
|
||||||
PicoGraphics<T>(width, height, frame_buffer),
|
PicoGraphics<T>(width, height, frame_buffer),
|
||||||
st7789(width, height, rotation, round, frame_buffer, bus_pins) {
|
st7789(width, height, rotation, round, bus_pins) {
|
||||||
common_init();
|
common_init();
|
||||||
};
|
};
|
||||||
|
|
||||||
PicoGraphicsST7789(uint16_t width, uint16_t height, Rotation rotation, void *frame_buffer, ParallelPins bus_pins) :
|
PicoGraphicsST7789(uint16_t width, uint16_t height, Rotation rotation, void *frame_buffer, ParallelPins bus_pins) :
|
||||||
PicoGraphics<T>(width, height, frame_buffer),
|
PicoGraphics<T>(width, height, frame_buffer),
|
||||||
st7789(width, height, rotation, frame_buffer, bus_pins) {
|
st7789(width, height, rotation, bus_pins) {
|
||||||
common_init();
|
common_init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,52 +4,64 @@
|
||||||
// BreakoutColourLCD160x80 Class
|
// BreakoutColourLCD160x80 Class
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/***** Methods *****/
|
// Module functions
|
||||||
|
STATIC MP_DEFINE_CONST_FUN_OBJ_3(BreakoutColourLCD160x80_module_RGB565_obj, BreakoutColourLCD160x80_module_RGB565);
|
||||||
|
|
||||||
|
// Class Methods
|
||||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutColourLCD160x80_update_obj, BreakoutColourLCD160x80_update);
|
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutColourLCD160x80_update_obj, BreakoutColourLCD160x80_update);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_set_backlight_obj, 1, BreakoutColourLCD160x80_set_backlight);
|
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutColourLCD160x80_set_backlight_obj, BreakoutColourLCD160x80_set_backlight);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_set_pen_obj, 1, BreakoutColourLCD160x80_set_pen);
|
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_create_pen_obj, 1, BreakoutColourLCD160x80_create_pen);
|
// Pen
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_set_clip_obj, 1, BreakoutColourLCD160x80_set_clip);
|
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutColourLCD160x80_set_pen_obj, BreakoutColourLCD160x80_set_pen);
|
||||||
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(BreakoutColourLCD160x80_create_pen_obj, 4, 4, BreakoutColourLCD160x80_create_pen);
|
||||||
|
|
||||||
|
// Primitives
|
||||||
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(BreakoutColourLCD160x80_set_clip_obj, 5, 5, BreakoutColourLCD160x80_set_clip);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutColourLCD160x80_remove_clip_obj, BreakoutColourLCD160x80_remove_clip);
|
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutColourLCD160x80_remove_clip_obj, BreakoutColourLCD160x80_remove_clip);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutColourLCD160x80_clear_obj, BreakoutColourLCD160x80_clear);
|
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutColourLCD160x80_clear_obj, BreakoutColourLCD160x80_clear);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_pixel_obj, 1, BreakoutColourLCD160x80_pixel);
|
MP_DEFINE_CONST_FUN_OBJ_3(BreakoutColourLCD160x80_pixel_obj, BreakoutColourLCD160x80_pixel);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_pixel_span_obj, 1, BreakoutColourLCD160x80_pixel_span);
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(BreakoutColourLCD160x80_pixel_span_obj, 4, 4, BreakoutColourLCD160x80_pixel_span);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_rectangle_obj, 1, BreakoutColourLCD160x80_rectangle);
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(BreakoutColourLCD160x80_rectangle_obj, 5, 5, BreakoutColourLCD160x80_rectangle);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_circle_obj, 1, BreakoutColourLCD160x80_circle);
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(BreakoutColourLCD160x80_circle_obj, 4, 4, BreakoutColourLCD160x80_circle);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_character_obj, 1, BreakoutColourLCD160x80_character);
|
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_character_obj, 1, BreakoutColourLCD160x80_character);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_text_obj, 1, BreakoutColourLCD160x80_text);
|
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_text_obj, 1, BreakoutColourLCD160x80_text);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_polygon_obj, 1, BreakoutColourLCD160x80_polygon);
|
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_measure_text_obj, 1, BreakoutColourLCD160x80_measure_text);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_triangle_obj, 1, BreakoutColourLCD160x80_triangle);
|
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_polygon_obj, 2, BreakoutColourLCD160x80_polygon);
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutColourLCD160x80_line_obj, 1, BreakoutColourLCD160x80_line);
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(BreakoutColourLCD160x80_triangle_obj, 7, 7, BreakoutColourLCD160x80_triangle);
|
||||||
|
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(BreakoutColourLCD160x80_line_obj, 5, 5, BreakoutColourLCD160x80_line);
|
||||||
|
|
||||||
|
// Utility
|
||||||
|
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutColourLCD160x80_get_bounds_obj, BreakoutColourLCD160x80_get_bounds);
|
||||||
|
|
||||||
/***** Binding of Methods *****/
|
/***** Binding of Methods *****/
|
||||||
STATIC const mp_rom_map_elem_t BreakoutColourLCD160x80_locals_dict_table[] = {
|
STATIC const mp_rom_map_elem_t BreakoutColourLCD160x80_locals_dict_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&BreakoutColourLCD160x80_update_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_pixel), MP_ROM_PTR(&BreakoutColourLCD160x80_pixel_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_set_backlight), MP_ROM_PTR(&BreakoutColourLCD160x80_set_backlight_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_set_pen), MP_ROM_PTR(&BreakoutColourLCD160x80_set_pen_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_set_pen), MP_ROM_PTR(&BreakoutColourLCD160x80_set_pen_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&BreakoutColourLCD160x80_update_obj) },
|
||||||
|
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_set_backlight), MP_ROM_PTR(&BreakoutColourLCD160x80_set_backlight_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_create_pen), MP_ROM_PTR(&BreakoutColourLCD160x80_create_pen_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_create_pen), MP_ROM_PTR(&BreakoutColourLCD160x80_create_pen_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_set_clip), MP_ROM_PTR(&BreakoutColourLCD160x80_set_clip_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_set_clip), MP_ROM_PTR(&BreakoutColourLCD160x80_set_clip_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_remove_clip), MP_ROM_PTR(&BreakoutColourLCD160x80_remove_clip_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_remove_clip), MP_ROM_PTR(&BreakoutColourLCD160x80_remove_clip_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&BreakoutColourLCD160x80_clear_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&BreakoutColourLCD160x80_clear_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_pixel), MP_ROM_PTR(&BreakoutColourLCD160x80_pixel_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_pixel_span), MP_ROM_PTR(&BreakoutColourLCD160x80_pixel_span_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_pixel_span), MP_ROM_PTR(&BreakoutColourLCD160x80_pixel_span_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_rectangle), MP_ROM_PTR(&BreakoutColourLCD160x80_rectangle_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_rectangle), MP_ROM_PTR(&BreakoutColourLCD160x80_rectangle_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_circle), MP_ROM_PTR(&BreakoutColourLCD160x80_circle_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_circle), MP_ROM_PTR(&BreakoutColourLCD160x80_circle_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_character), MP_ROM_PTR(&BreakoutColourLCD160x80_character_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_character), MP_ROM_PTR(&BreakoutColourLCD160x80_character_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_text), MP_ROM_PTR(&BreakoutColourLCD160x80_text_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_text), MP_ROM_PTR(&BreakoutColourLCD160x80_text_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_measure_text), MP_ROM_PTR(&BreakoutColourLCD160x80_measure_text_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_polygon), MP_ROM_PTR(&BreakoutColourLCD160x80_polygon_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_polygon), MP_ROM_PTR(&BreakoutColourLCD160x80_polygon_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_triangle), MP_ROM_PTR(&BreakoutColourLCD160x80_triangle_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_triangle), MP_ROM_PTR(&BreakoutColourLCD160x80_triangle_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_line), MP_ROM_PTR(&BreakoutColourLCD160x80_line_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_line), MP_ROM_PTR(&BreakoutColourLCD160x80_line_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_WIDTH), MP_ROM_INT(WIDTH) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_HEIGHT), MP_ROM_INT(HEIGHT) },
|
{ MP_ROM_QSTR(MP_QSTR_get_bounds), MP_ROM_PTR(&BreakoutColourLCD160x80_get_bounds_obj) }
|
||||||
};
|
};
|
||||||
STATIC MP_DEFINE_CONST_DICT(BreakoutColourLCD160x80_locals_dict, BreakoutColourLCD160x80_locals_dict_table);
|
STATIC MP_DEFINE_CONST_DICT(BreakoutColourLCD160x80_locals_dict, BreakoutColourLCD160x80_locals_dict_table);
|
||||||
|
|
||||||
/***** Class Definition *****/
|
/***** Class Definition *****/
|
||||||
const mp_obj_type_t breakout_colourlcd160x80_BreakoutColourLCD160x80_type = {
|
const mp_obj_type_t BreakoutColourLCD160x80_type = {
|
||||||
{ &mp_type_type },
|
{ &mp_type_type },
|
||||||
.name = MP_QSTR_breakout_colourlcd160x80,
|
.name = MP_QSTR_breakout_colourlcd160x80,
|
||||||
.print = BreakoutColourLCD160x80_print,
|
|
||||||
.make_new = BreakoutColourLCD160x80_make_new,
|
.make_new = BreakoutColourLCD160x80_make_new,
|
||||||
.locals_dict = (mp_obj_dict_t*)&BreakoutColourLCD160x80_locals_dict,
|
.locals_dict = (mp_obj_dict_t*)&BreakoutColourLCD160x80_locals_dict,
|
||||||
};
|
};
|
||||||
|
@ -62,7 +74,12 @@ const mp_obj_type_t breakout_colourlcd160x80_BreakoutColourLCD160x80_type = {
|
||||||
/***** Globals Table *****/
|
/***** Globals Table *****/
|
||||||
STATIC const mp_map_elem_t breakout_colourlcd160x80_globals_table[] = {
|
STATIC const mp_map_elem_t breakout_colourlcd160x80_globals_table[] = {
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_breakout_colourlcd160x80) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_breakout_colourlcd160x80) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_BreakoutColourLCD160x80), (mp_obj_t)&breakout_colourlcd160x80_BreakoutColourLCD160x80_type },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_BreakoutColourLCD160x80), (mp_obj_t)&BreakoutColourLCD160x80_type },
|
||||||
|
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_RGB565), MP_ROM_PTR(&BreakoutColourLCD160x80_module_RGB565_obj) },
|
||||||
|
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_WIDTH), MP_ROM_INT(WIDTH) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_HEIGHT), MP_ROM_INT(HEIGHT) },
|
||||||
};
|
};
|
||||||
STATIC MP_DEFINE_CONST_DICT(mp_module_breakout_colourlcd160x80_globals, breakout_colourlcd160x80_globals_table);
|
STATIC MP_DEFINE_CONST_DICT(mp_module_breakout_colourlcd160x80_globals, breakout_colourlcd160x80_globals_table);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#include "libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.hpp"
|
#include "libraries/breakout_colourlcd160x80/breakout_colourlcd160x80.hpp"
|
||||||
|
#include "common/pimoroni_common.hpp"
|
||||||
|
#include "common/pimoroni_bus.hpp"
|
||||||
|
|
||||||
#include "micropython/modules/util.hpp"
|
#include "micropython/modules/util.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,339 +9,233 @@ using namespace pimoroni;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "breakout_colourlcd160x80.h"
|
#include "breakout_colourlcd160x80.h"
|
||||||
|
#include "micropython/modules/pimoroni_bus/pimoroni_bus.h"
|
||||||
|
|
||||||
/***** Variables Struct *****/
|
/***** Variables Struct *****/
|
||||||
typedef struct _breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t {
|
typedef struct _BreakoutColourLCD160x80_obj_t {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
BreakoutColourLCD160x80 *breakout;
|
BreakoutColourLCD160x80 *breakout;
|
||||||
} breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t;
|
void *buffer;
|
||||||
|
} BreakoutColourLCD160x80_obj_t;
|
||||||
|
|
||||||
/***** Print *****/
|
|
||||||
void BreakoutColourLCD160x80_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
|
||||||
(void)kind; //Unused input parameter
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
|
||||||
BreakoutColourLCD160x80* breakout = self->breakout;
|
|
||||||
mp_print_str(print, "BreakoutColourLCD160x80(");
|
|
||||||
|
|
||||||
mp_print_str(print, "spi = ");
|
|
||||||
mp_obj_print_helper(print, mp_obj_new_int((breakout->get_spi() == spi0) ? 0 : 1), PRINT_REPR);
|
|
||||||
|
|
||||||
mp_print_str(print, ", cs = ");
|
|
||||||
mp_obj_print_helper(print, mp_obj_new_int(breakout->get_cs()), PRINT_REPR);
|
|
||||||
|
|
||||||
mp_print_str(print, ", dc = ");
|
|
||||||
mp_obj_print_helper(print, mp_obj_new_int(breakout->get_dc()), PRINT_REPR);
|
|
||||||
|
|
||||||
mp_print_str(print, ", sck = ");
|
|
||||||
mp_obj_print_helper(print, mp_obj_new_int(breakout->get_sck()), PRINT_REPR);
|
|
||||||
|
|
||||||
mp_print_str(print, ", mosi = ");
|
|
||||||
mp_obj_print_helper(print, mp_obj_new_int(breakout->get_mosi()), PRINT_REPR);
|
|
||||||
|
|
||||||
mp_print_str(print, ", bl = ");
|
|
||||||
mp_obj_print_helper(print, mp_obj_new_int(breakout->get_bl()), PRINT_REPR);
|
|
||||||
|
|
||||||
mp_print_str(print, ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Constructor *****/
|
/***** Constructor *****/
|
||||||
mp_obj_t BreakoutColourLCD160x80_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
mp_obj_t BreakoutColourLCD160x80_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = nullptr;
|
BreakoutColourLCD160x80_obj_t *self = nullptr;
|
||||||
|
|
||||||
if(n_args + n_kw == 2) {
|
enum { ARG_bus, ARG_buffer };
|
||||||
enum { ARG_buffer, ARG_slot };
|
static const mp_arg_t allowed_args[] = {
|
||||||
static const mp_arg_t allowed_args[] = {
|
{ MP_QSTR_bus, MP_ARG_OBJ, { .u_obj = mp_const_none } },
|
||||||
{ MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
{ MP_QSTR_buffer, MP_ARG_OBJ, { .u_obj = mp_const_none } },
|
||||||
{ MP_QSTR_slot, MP_ARG_REQUIRED | MP_ARG_INT },
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// Parse args.
|
// Parse args.
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
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;
|
self = m_new_obj(BreakoutColourLCD160x80_obj_t);
|
||||||
if(slot == BG_SPI_FRONT || slot == BG_SPI_BACK) {
|
self->base.type = &BreakoutColourLCD160x80_type;
|
||||||
self = m_new_obj(breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
|
||||||
self->base.type = &breakout_colourlcd160x80_BreakoutColourLCD160x80_type;
|
|
||||||
|
|
||||||
mp_buffer_info_t bufinfo;
|
// Get or create a suitable framebuffer
|
||||||
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_RW);
|
// save a pointer onto the object so that GC can find it
|
||||||
|
size_t required_size = PenRGB565::buffer_size(WIDTH, HEIGHT);
|
||||||
self->breakout = m_new_class(BreakoutColourLCD160x80, bufinfo.buf, (BG_SPI_SLOT)slot);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mp_raise_ValueError("slot not a valid value. Expected 0 to 1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
enum { ARG_buffer, ARG_spi, ARG_cs, ARG_dc, ARG_sck, ARG_mosi, ARG_bl };
|
|
||||||
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 = ST7735::DEFAULT_CS_PIN} },
|
|
||||||
{ MP_QSTR_dc, MP_ARG_INT, {.u_int = ST7735::DEFAULT_DC_PIN} },
|
|
||||||
{ MP_QSTR_sck, MP_ARG_INT, {.u_int = ST7735::DEFAULT_SCK_PIN} },
|
|
||||||
{ MP_QSTR_mosi, MP_ARG_INT, {.u_int = ST7735::DEFAULT_MOSI_PIN} },
|
|
||||||
{ MP_QSTR_bl, MP_ARG_INT, {.u_int = ST7735::DEFAULT_BL_PIN} },
|
|
||||||
};
|
|
||||||
|
|
||||||
// Parse args.
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
|
||||||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
|
if (args[ARG_buffer].u_obj != mp_const_none) {
|
||||||
mp_buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_RW);
|
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_RW);
|
||||||
|
self->buffer = bufinfo.buf;
|
||||||
// Get SPI bus.
|
if(bufinfo.len < (size_t)(required_size)) {
|
||||||
int spi_id = args[ARG_spi].u_int;
|
mp_raise_ValueError("Supplied buffer is too small!");
|
||||||
int sck = args[ARG_sck].u_int;
|
|
||||||
int mosi = args[ARG_mosi].u_int;
|
|
||||||
|
|
||||||
if(spi_id == -1) {
|
|
||||||
spi_id = (sck >> 3) & 0b1; // If no spi specified, choose the one for the given SCK pin
|
|
||||||
}
|
}
|
||||||
if(spi_id < 0 || spi_id > 1) {
|
} else {
|
||||||
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("SPI(%d) doesn't exist"), spi_id);
|
self->buffer = m_new(uint8_t, required_size);
|
||||||
}
|
|
||||||
|
|
||||||
if(!IS_VALID_SCK(spi_id, sck)) {
|
|
||||||
mp_raise_ValueError(MP_ERROR_TEXT("bad SCK pin"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!IS_VALID_MOSI(spi_id, mosi)) {
|
|
||||||
mp_raise_ValueError(MP_ERROR_TEXT("bad MOSI pin"));
|
|
||||||
}
|
|
||||||
|
|
||||||
self = m_new_obj(breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
|
||||||
self->base.type = &breakout_colourlcd160x80_BreakoutColourLCD160x80_type;
|
|
||||||
|
|
||||||
spi_inst_t *spi = (spi_id == 0) ? spi0 : spi1;
|
|
||||||
self->breakout = m_new_class(BreakoutColourLCD160x80, bufinfo.buf, spi,
|
|
||||||
args[ARG_cs].u_int, args[ARG_dc].u_int, sck, mosi, PIN_UNUSED, args[ARG_bl].u_int);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self->breakout->init();
|
// Check the bus argument for a valid SPIBus
|
||||||
|
// or just build the class and accept the defaults.
|
||||||
|
if (args[ARG_bus].u_obj == mp_const_none) {
|
||||||
|
self->breakout = m_new_class(BreakoutColourLCD160x80, self->buffer);
|
||||||
|
} else if (mp_obj_is_type(args[ARG_bus].u_obj, &ParallelPins_type)) {
|
||||||
|
_PimoroniBus_obj_t *bus = (_PimoroniBus_obj_t *)MP_OBJ_TO_PTR(args[ARG_bus].u_obj);
|
||||||
|
self->breakout = m_new_class(BreakoutColourLCD160x80, self->buffer, *(SPIPins *)(bus->pins));
|
||||||
|
} else {
|
||||||
|
mp_raise_ValueError("SPIBus expected!");
|
||||||
|
}
|
||||||
|
|
||||||
return MP_OBJ_FROM_PTR(self);
|
return MP_OBJ_FROM_PTR(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Methods *****/
|
/***** Methods *****/
|
||||||
|
mp_obj_t BreakoutColourLCD160x80_get_bounds(mp_obj_t self_in) {
|
||||||
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, BreakoutColourLCD160x80_obj_t);
|
||||||
|
mp_obj_t tuple[2] = {
|
||||||
|
mp_obj_new_int(self->breakout->bounds.w),
|
||||||
|
mp_obj_new_int(self->breakout->bounds.h)
|
||||||
|
};
|
||||||
|
return mp_obj_new_tuple(2, tuple);
|
||||||
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_update(mp_obj_t self_in) {
|
mp_obj_t BreakoutColourLCD160x80_update(mp_obj_t self_in) {
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, BreakoutColourLCD160x80_obj_t);
|
||||||
self->breakout->update();
|
self->breakout->update();
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_set_backlight(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_set_backlight(mp_obj_t self_in, mp_obj_t brightness) {
|
||||||
enum { ARG_self, ARG_brightness };
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, BreakoutColourLCD160x80_obj_t);
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
{ MP_QSTR_brightness, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
};
|
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
float b = mp_obj_get_float(brightness);
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
if(b < 0 || b > 1.0f) mp_raise_ValueError("brightness out of range. Expected 0.0 to 1.0");
|
||||||
|
|
||||||
float brightness = mp_obj_get_float(args[ARG_brightness].u_obj);
|
self->breakout->set_backlight((uint8_t)(b * 255.0f));
|
||||||
|
|
||||||
if(brightness < 0 || brightness > 1.0f)
|
|
||||||
mp_raise_ValueError("brightness out of range. Expected 0.0 to 1.0");
|
|
||||||
else
|
|
||||||
self->breakout->set_backlight((uint8_t)(brightness * 255.0f));
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_set_pen(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_module_RGB332(mp_obj_t r, mp_obj_t g, mp_obj_t b) {
|
||||||
|
return mp_obj_new_int(PicoGraphicsPenType::rgb_to_rgb332(
|
||||||
|
mp_obj_get_int(r),
|
||||||
|
mp_obj_get_int(g),
|
||||||
|
mp_obj_get_int(b)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
enum { ARG_self, ARG_pen };
|
mp_obj_t BreakoutColourLCD160x80_module_RGB565(mp_obj_t r, mp_obj_t g, mp_obj_t b) {
|
||||||
static const mp_arg_t allowed_args[] = {
|
return mp_obj_new_int(PicoGraphicsPenType::rgb_to_rgb565(
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
mp_obj_get_int(r),
|
||||||
{ MP_QSTR_pen, MP_ARG_REQUIRED | MP_ARG_INT },
|
mp_obj_get_int(g),
|
||||||
};
|
mp_obj_get_int(b)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
mp_obj_t BreakoutColourLCD160x80_set_pen(mp_obj_t self_in, mp_obj_t pen) {
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, BreakoutColourLCD160x80_obj_t);
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
self->breakout->set_pen(mp_obj_get_int(pen));
|
||||||
|
|
||||||
int pen = args[ARG_pen].u_int;
|
|
||||||
|
|
||||||
if(pen < 0 || pen > 0xffff)
|
|
||||||
mp_raise_ValueError("p is not a valid pen.");
|
|
||||||
else
|
|
||||||
self->breakout->set_pen(pen);
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_create_pen(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_reset_pen(mp_obj_t self_in, mp_obj_t pen) {
|
||||||
int pen = 0;
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, BreakoutColourLCD160x80_obj_t);
|
||||||
|
|
||||||
|
self->breakout->reset_pen(mp_obj_get_int(pen));
|
||||||
|
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
|
||||||
|
mp_obj_t BreakoutColourLCD160x80_update_pen(size_t n_args, const mp_obj_t *args) {
|
||||||
|
enum { ARG_self, ARG_i, ARG_r, ARG_g, ARG_b };
|
||||||
|
|
||||||
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], BreakoutColourLCD160x80_obj_t);
|
||||||
|
|
||||||
|
self->breakout->update_pen(
|
||||||
|
mp_obj_get_int(args[ARG_i]) & 0xff,
|
||||||
|
mp_obj_get_int(args[ARG_r]) & 0xff,
|
||||||
|
mp_obj_get_int(args[ARG_g]) & 0xff,
|
||||||
|
mp_obj_get_int(args[ARG_b]) & 0xff
|
||||||
|
);
|
||||||
|
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
|
||||||
|
mp_obj_t BreakoutColourLCD160x80_create_pen(size_t n_args, const mp_obj_t *args) {
|
||||||
enum { ARG_self, ARG_r, ARG_g, ARG_b };
|
enum { ARG_self, ARG_r, ARG_g, ARG_b };
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
{ MP_QSTR_r, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_g, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_b, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
};
|
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], BreakoutColourLCD160x80_obj_t);
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
int result = self->breakout->create_pen(
|
||||||
|
mp_obj_get_int(args[ARG_r]) & 0xff,
|
||||||
|
mp_obj_get_int(args[ARG_g]) & 0xff,
|
||||||
|
mp_obj_get_int(args[ARG_b]) & 0xff
|
||||||
|
);
|
||||||
|
|
||||||
int r = args[ARG_r].u_int;
|
if (result == -1) mp_raise_ValueError("create_pen failed. No matching colour or space in palette!");
|
||||||
int g = args[ARG_g].u_int;
|
|
||||||
int b = args[ARG_b].u_int;
|
|
||||||
|
|
||||||
if(r < 0 || r > 255)
|
return mp_obj_new_int(result);
|
||||||
mp_raise_ValueError("r out of range. Expected 0 to 255");
|
|
||||||
else if(g < 0 || g > 255)
|
|
||||||
mp_raise_ValueError("g out of range. Expected 0 to 255");
|
|
||||||
else if(b < 0 || b > 255)
|
|
||||||
mp_raise_ValueError("b out of range. Expected 0 to 255");
|
|
||||||
else
|
|
||||||
pen = self->breakout->create_pen(r, g, b);
|
|
||||||
|
|
||||||
return mp_obj_new_int(pen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_set_clip(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_set_clip(size_t n_args, const mp_obj_t *args) {
|
||||||
enum { ARG_self, ARG_x, ARG_y, ARG_w, ARG_h };
|
enum { ARG_self, ARG_x, ARG_y, ARG_w, ARG_h };
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
{ MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_w, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_h, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
};
|
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], BreakoutColourLCD160x80_obj_t);
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
self->breakout->set_clip({
|
||||||
|
mp_obj_get_int(args[ARG_x]),
|
||||||
int x = args[ARG_x].u_int;
|
mp_obj_get_int(args[ARG_y]),
|
||||||
int y = args[ARG_y].u_int;
|
mp_obj_get_int(args[ARG_w]),
|
||||||
int w = args[ARG_w].u_int;
|
mp_obj_get_int(args[ARG_h])
|
||||||
int h = args[ARG_h].u_int;
|
});
|
||||||
|
|
||||||
Rect r(x, y, w, h);
|
|
||||||
self->breakout->set_clip(r);
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_remove_clip(mp_obj_t self_in) {
|
mp_obj_t BreakoutColourLCD160x80_remove_clip(mp_obj_t self_in) {
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, BreakoutColourLCD160x80_obj_t);
|
||||||
|
|
||||||
self->breakout->remove_clip();
|
self->breakout->remove_clip();
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_clear(mp_obj_t self_in) {
|
mp_obj_t BreakoutColourLCD160x80_clear(mp_obj_t self_in) {
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, BreakoutColourLCD160x80_obj_t);
|
||||||
|
|
||||||
self->breakout->clear();
|
self->breakout->clear();
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_pixel(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_pixel(mp_obj_t self_in, mp_obj_t x, mp_obj_t y) {
|
||||||
enum { ARG_self, ARG_x, ARG_y };
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(self_in, BreakoutColourLCD160x80_obj_t);
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
{ MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
};
|
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
self->breakout->pixel({
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
mp_obj_get_int(x),
|
||||||
|
mp_obj_get_int(y)
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
});
|
||||||
|
|
||||||
int x = args[ARG_x].u_int;
|
|
||||||
int y = args[ARG_y].u_int;
|
|
||||||
|
|
||||||
Point p(x, y);
|
|
||||||
self->breakout->pixel(p);
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_pixel_span(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_pixel_span(size_t n_args, const mp_obj_t *args) {
|
||||||
enum { ARG_self, ARG_x, ARG_y, ARG_l };
|
enum { ARG_self, ARG_x, ARG_y, ARG_l };
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
{ MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_l, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
};
|
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], BreakoutColourLCD160x80_obj_t);
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
self->breakout->pixel_span({
|
||||||
|
mp_obj_get_int(args[ARG_x]),
|
||||||
int x = args[ARG_x].u_int;
|
mp_obj_get_int(args[ARG_y])
|
||||||
int y = args[ARG_y].u_int;
|
}, mp_obj_get_int(args[ARG_l]));
|
||||||
int l = args[ARG_l].u_int;
|
|
||||||
|
|
||||||
Point p(x, y);
|
|
||||||
self->breakout->pixel_span(p, l);
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_rectangle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_rectangle(size_t n_args, const mp_obj_t *args) {
|
||||||
enum { ARG_self, ARG_x, ARG_y, ARG_w, ARG_h };
|
enum { ARG_self, ARG_x, ARG_y, ARG_w, ARG_h };
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
{ MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_w, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_h, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
};
|
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], BreakoutColourLCD160x80_obj_t);
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
self->breakout->rectangle({
|
||||||
|
mp_obj_get_int(args[ARG_x]),
|
||||||
int x = args[ARG_x].u_int;
|
mp_obj_get_int(args[ARG_y]),
|
||||||
int y = args[ARG_y].u_int;
|
mp_obj_get_int(args[ARG_w]),
|
||||||
int w = args[ARG_w].u_int;
|
mp_obj_get_int(args[ARG_h])
|
||||||
int h = args[ARG_h].u_int;
|
});
|
||||||
|
|
||||||
Rect r(x, y, w, h);
|
|
||||||
self->breakout->rectangle(r);
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_circle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_circle(size_t n_args, const mp_obj_t *args) {
|
||||||
enum { ARG_self, ARG_x, ARG_y, ARG_r };
|
enum { ARG_self, ARG_x, ARG_y, ARG_r };
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
{ MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_r, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
};
|
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], BreakoutColourLCD160x80_obj_t);
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
self->breakout->circle({
|
||||||
|
mp_obj_get_int(args[ARG_x]),
|
||||||
int x = args[ARG_x].u_int;
|
mp_obj_get_int(args[ARG_y])
|
||||||
int y = args[ARG_y].u_int;
|
}, mp_obj_get_int(args[ARG_r]));
|
||||||
int r = args[ARG_r].u_int;
|
|
||||||
|
|
||||||
Point p(x, y);
|
|
||||||
self->breakout->circle(p, r);
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
@ -348,15 +245,15 @@ mp_obj_t BreakoutColourLCD160x80_character(size_t n_args, const mp_obj_t *pos_ar
|
||||||
static const mp_arg_t allowed_args[] = {
|
static const mp_arg_t allowed_args[] = {
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||||
{ MP_QSTR_char, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
{ MP_QSTR_char, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||||
{ MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT },
|
{ MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||||
{ MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT },
|
{ MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||||
{ MP_QSTR_scale, MP_ARG_INT, {.u_int = 2} },
|
{ MP_QSTR_scale, MP_ARG_INT, {.u_int = 2} },
|
||||||
};
|
};
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, BreakoutColourLCD160x80_obj_t);
|
||||||
|
|
||||||
int c = mp_obj_get_int(args[ARG_char].u_obj);
|
int c = mp_obj_get_int(args[ARG_char].u_obj);
|
||||||
int x = args[ARG_x].u_int;
|
int x = args[ARG_x].u_int;
|
||||||
|
@ -382,118 +279,124 @@ mp_obj_t BreakoutColourLCD160x80_text(size_t n_args, const mp_obj_t *pos_args, m
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, BreakoutColourLCD160x80_obj_t);
|
||||||
|
|
||||||
mp_obj_t text_obj = args[ARG_text].u_obj;
|
mp_obj_t text_obj = args[ARG_text].u_obj;
|
||||||
if(mp_obj_is_str_or_bytes(text_obj)) {
|
|
||||||
GET_STR_DATA_LEN(text_obj, str, str_len);
|
|
||||||
|
|
||||||
std::string t((const char*)str);
|
if(!mp_obj_is_str_or_bytes(text_obj)) mp_raise_TypeError("text: string required");
|
||||||
|
|
||||||
int x = args[ARG_x].u_int;
|
GET_STR_DATA_LEN(text_obj, str, str_len);
|
||||||
int y = args[ARG_y].u_int;
|
|
||||||
int wrap = args[ARG_wrap].u_int;
|
|
||||||
int scale = args[ARG_scale].u_int;
|
|
||||||
|
|
||||||
self->breakout->text(t, Point(x, y), wrap, scale);
|
std::string t((const char*)str);
|
||||||
}
|
|
||||||
else if(mp_obj_is_float(text_obj)) {
|
int x = args[ARG_x].u_int;
|
||||||
mp_raise_TypeError("can't convert 'float' object to str implicitly");
|
int y = args[ARG_y].u_int;
|
||||||
}
|
int wrap = args[ARG_wrap].u_int;
|
||||||
else if(mp_obj_is_int(text_obj)) {
|
int scale = args[ARG_scale].u_int;
|
||||||
mp_raise_TypeError("can't convert 'int' object to str implicitly");
|
|
||||||
}
|
self->breakout->text(t, Point(x, y), wrap, scale);
|
||||||
else if(mp_obj_is_bool(text_obj)) {
|
|
||||||
mp_raise_TypeError("can't convert 'bool' object to str implicitly");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mp_raise_TypeError("can't convert object to str implicitly");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mp_obj_t BreakoutColourLCD160x80_measure_text(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||||
|
enum { ARG_self, ARG_text, ARG_scale };
|
||||||
|
static const mp_arg_t allowed_args[] = {
|
||||||
|
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||||
|
{ MP_QSTR_text, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||||
|
{ MP_QSTR_scale, MP_ARG_INT, {.u_int = 2} },
|
||||||
|
};
|
||||||
|
|
||||||
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
|
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, BreakoutColourLCD160x80_obj_t);
|
||||||
|
|
||||||
|
mp_obj_t text_obj = args[ARG_text].u_obj;
|
||||||
|
|
||||||
|
if(!mp_obj_is_str_or_bytes(text_obj)) mp_raise_TypeError("text: string required");
|
||||||
|
|
||||||
|
GET_STR_DATA_LEN(text_obj, str, str_len);
|
||||||
|
|
||||||
|
std::string t((const char*)str);
|
||||||
|
|
||||||
|
int scale = args[ARG_scale].u_int;
|
||||||
|
|
||||||
|
int width = self->breakout->measure_text(t, scale);
|
||||||
|
|
||||||
|
return mp_obj_new_int(width);
|
||||||
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_polygon(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_polygon(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||||
// enum { ARG_self, ARG_x, ARG_y, ARG_r };
|
size_t num_tuples = n_args - 1;
|
||||||
// static const mp_arg_t allowed_args[] = {
|
const mp_obj_t *tuples = pos_args + 1;
|
||||||
// { MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
// { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
// { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
// { MP_QSTR_r, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
// };
|
|
||||||
|
|
||||||
// mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(pos_args[0], BreakoutColourLCD160x80_obj_t);
|
||||||
// mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
// breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
// Check if there is only one argument, which might be a list
|
||||||
|
if(n_args == 2) {
|
||||||
|
if(mp_obj_is_type(pos_args[1], &mp_type_list)) {
|
||||||
|
mp_obj_list_t *points = MP_OBJ_TO_PTR2(pos_args[1], mp_obj_list_t);
|
||||||
|
|
||||||
// int x = args[ARG_x].u_int;
|
if(points->len <= 0) mp_raise_ValueError("poly(): cannot provide an empty list");
|
||||||
// int y = args[ARG_y].u_int;
|
|
||||||
// int r = args[ARG_r].u_int;
|
|
||||||
|
|
||||||
// Point p(x, y);
|
num_tuples = points->len;
|
||||||
// self->breakout->circle(p, r);
|
tuples = points->items;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mp_raise_TypeError("poly(): can't convert object to list");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mp_raise_NotImplementedError("polygon is not implemented. Please avoid using this function for now");
|
if(num_tuples > 0) {
|
||||||
|
std::vector<Point> points;
|
||||||
|
for(size_t i = 0; i < num_tuples; i++) {
|
||||||
|
mp_obj_t obj = tuples[i];
|
||||||
|
if(!mp_obj_is_type(obj, &mp_type_tuple)) mp_raise_ValueError("poly(): can't convert object to tuple");
|
||||||
|
|
||||||
|
mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR2(obj, mp_obj_tuple_t);
|
||||||
|
|
||||||
|
if(tuple->len != 2) mp_raise_ValueError("poly(): tuple must only contain two numbers");
|
||||||
|
|
||||||
|
points.push_back({
|
||||||
|
mp_obj_get_int(tuple->items[0]),
|
||||||
|
mp_obj_get_int(tuple->items[1])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self->breakout->polygon(points);
|
||||||
|
}
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_triangle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_triangle(size_t n_args, const mp_obj_t *args) {
|
||||||
enum { ARG_self, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_x3, ARG_y3 };
|
enum { ARG_self, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_x3, ARG_y3 };
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
{ MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_x3, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y3, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
};
|
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], BreakoutColourLCD160x80_obj_t);
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
self->breakout->triangle(
|
||||||
|
{mp_obj_get_int(args[ARG_x1]),
|
||||||
int x1 = args[ARG_x1].u_int;
|
mp_obj_get_int(args[ARG_y1])},
|
||||||
int y1 = args[ARG_y1].u_int;
|
{mp_obj_get_int(args[ARG_x2]),
|
||||||
int x2 = args[ARG_x2].u_int;
|
mp_obj_get_int(args[ARG_y2])},
|
||||||
int y2 = args[ARG_y2].u_int;
|
{mp_obj_get_int(args[ARG_x3]),
|
||||||
int x3 = args[ARG_x3].u_int;
|
mp_obj_get_int(args[ARG_y3])}
|
||||||
int y3 = args[ARG_y3].u_int;
|
);
|
||||||
|
|
||||||
Point p1(x1, y1);
|
|
||||||
Point p2(x2, y2);
|
|
||||||
Point p3(x3, y3);
|
|
||||||
self->breakout->triangle(p1, p2, p3);
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t BreakoutColourLCD160x80_line(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t BreakoutColourLCD160x80_line(size_t n_args, const mp_obj_t *args) {
|
||||||
enum { ARG_self, ARG_x1, ARG_y1, ARG_x2, ARG_y2 };
|
enum { ARG_self, ARG_x1, ARG_y1, ARG_x2, ARG_y2 };
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
|
||||||
{ MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
{ MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT },
|
|
||||||
};
|
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], BreakoutColourLCD160x80_obj_t);
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_colourlcd160x80_BreakoutColourLCD160x80_obj_t);
|
self->breakout->line(
|
||||||
|
{mp_obj_get_int(args[ARG_x1]),
|
||||||
int x1 = args[ARG_x1].u_int;
|
mp_obj_get_int(args[ARG_y1])},
|
||||||
int y1 = args[ARG_y1].u_int;
|
{mp_obj_get_int(args[ARG_x2]),
|
||||||
int x2 = args[ARG_x2].u_int;
|
mp_obj_get_int(args[ARG_y2])}
|
||||||
int y2 = args[ARG_y2].u_int;
|
);
|
||||||
|
|
||||||
Point p1(x1, y1);
|
|
||||||
Point p2(x2, y2);
|
|
||||||
self->breakout->line(p1, p2);
|
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,31 +2,39 @@
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/objstr.h"
|
#include "py/objstr.h"
|
||||||
|
|
||||||
/***** Constants *****/
|
|
||||||
static const int WIDTH = 160;
|
static const int WIDTH = 160;
|
||||||
static const int HEIGHT = 80;
|
static const int HEIGHT = 80;
|
||||||
|
|
||||||
|
// Type
|
||||||
|
extern const mp_obj_type_t BreakoutColourLCD160x80_type;
|
||||||
|
|
||||||
/***** Extern of Class Definition *****/
|
// Module functions
|
||||||
extern const mp_obj_type_t breakout_colourlcd160x80_BreakoutColourLCD160x80_type;
|
extern mp_obj_t BreakoutColourLCD160x80_module_RGB565(mp_obj_t r, mp_obj_t g, mp_obj_t b);
|
||||||
|
|
||||||
/***** Extern of Class Methods *****/
|
// Class methods
|
||||||
extern void BreakoutColourLCD160x80_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind);
|
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
|
extern mp_obj_t BreakoutColourLCD160x80_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_update(mp_obj_t self_in);
|
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_set_backlight(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
|
||||||
|
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_set_pen(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t BreakoutColourLCD160x80_update(mp_obj_t self_in);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_create_pen(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t BreakoutColourLCD160x80_set_backlight(mp_obj_t self_in, mp_obj_t brightness);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_set_clip(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_remove_clip(mp_obj_t self_in);
|
// Pen
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_clear(mp_obj_t self_in);
|
extern mp_obj_t BreakoutColourLCD160x80_set_pen(mp_obj_t self_in, mp_obj_t pen);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_pixel(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t BreakoutColourLCD160x80_create_pen(size_t n_args, const mp_obj_t *args);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_pixel_span(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_rectangle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
// Primitives
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_circle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t BreakoutColourLCD160x80_set_clip(size_t n_args, const mp_obj_t *args);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_character(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t BreakoutColourLCD160x80_remove_clip(mp_obj_t self_in);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_text(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t BreakoutColourLCD160x80_clear(mp_obj_t self_in);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_polygon(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t BreakoutColourLCD160x80_pixel(mp_obj_t self_in, mp_obj_t x, mp_obj_t y);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_triangle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t BreakoutColourLCD160x80_pixel_span(size_t n_args, const mp_obj_t *args);
|
||||||
extern mp_obj_t BreakoutColourLCD160x80_line(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
extern mp_obj_t BreakoutColourLCD160x80_rectangle(size_t n_args, const mp_obj_t *args);
|
||||||
|
extern mp_obj_t BreakoutColourLCD160x80_circle(size_t n_args, const mp_obj_t *args);
|
||||||
|
extern mp_obj_t BreakoutColourLCD160x80_character(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||||
|
extern mp_obj_t BreakoutColourLCD160x80_text(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||||
|
extern mp_obj_t BreakoutColourLCD160x80_measure_text(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||||
|
extern mp_obj_t BreakoutColourLCD160x80_polygon(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||||
|
extern mp_obj_t BreakoutColourLCD160x80_triangle(size_t n_args, const mp_obj_t *args);
|
||||||
|
extern mp_obj_t BreakoutColourLCD160x80_line(size_t n_args, const mp_obj_t *args);
|
||||||
|
|
||||||
|
// Utility
|
||||||
|
extern mp_obj_t BreakoutColourLCD160x80_get_bounds(mp_obj_t self_in);
|
|
@ -19,4 +19,10 @@ target_compile_definitions(usermod_${MOD_NAME} INTERFACE
|
||||||
-DMODULE_${MOD_NAME_UPPER}_ENABLED=1
|
-DMODULE_${MOD_NAME_UPPER}_ENABLED=1
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(usermod INTERFACE usermod_${MOD_NAME})
|
target_link_libraries(usermod INTERFACE usermod_${MOD_NAME})
|
||||||
|
|
||||||
|
set_source_files_properties(
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.c
|
||||||
|
PROPERTIES COMPILE_FLAGS
|
||||||
|
"-Wno-discarded-qualifiers"
|
||||||
|
)
|
|
@ -79,9 +79,6 @@ STATIC const mp_map_elem_t st7789_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_RGB332), MP_ROM_PTR(&GenericST7789_module_RGB332_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_RGB332), MP_ROM_PTR(&GenericST7789_module_RGB332_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_RGB565), MP_ROM_PTR(&GenericST7789_module_RGB565_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_RGB565), MP_ROM_PTR(&GenericST7789_module_RGB565_obj) },
|
||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_PALETTE_RGB332), MP_ROM_INT(0) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_PALETTE_USER), MP_ROM_INT(1) },
|
|
||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_LCD_240X240), MP_ROM_INT(DISPLAY_LCD_240X240) },
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_LCD_240X240), MP_ROM_INT(DISPLAY_LCD_240X240) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_ROUND_LCD_240X240), MP_ROM_INT(DISPLAY_ROUND_LCD_240X240) },
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_ROUND_LCD_240X240), MP_ROM_INT(DISPLAY_ROUND_LCD_240X240) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_PICO_DISPLAY), MP_ROM_INT(DISPLAY_PICO_DISPLAY) },
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_PICO_DISPLAY), MP_ROM_INT(DISPLAY_PICO_DISPLAY) },
|
||||||
|
|
Ładowanie…
Reference in New Issue