Commit 7dc2c7fe authored by Russ Hughes's avatar Russ Hughes

on and off methods added for backlight pin control, firmware updated

parent 19acd6f5
...@@ -187,9 +187,13 @@ I couldn't run the display on an SPI with baudrate higher than 40MHZ ...@@ -187,9 +187,13 @@ I couldn't run the display on an SPI with baudrate higher than 40MHZ
This driver supports only 16bit colors in RGB565 notation. This driver supports only 16bit colors in RGB565 notation.
- `ST7789.fill(color)` - `ST7789.on()`
Fill the entire display with the specified color. Turn on the backlight pin if one was defined during init.
- `ST7789.off()`
Turn off the backlight pin if one was defined during init.
- `ST7789.pixel(x, y, color)` - `ST7789.pixel(x, y, color)`
......
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
#define DC_HIGH() (mp_hal_pin_write(self->dc, 1)) #define DC_HIGH() (mp_hal_pin_write(self->dc, 1))
#define RESET_LOW() { if (self->reset) mp_hal_pin_write(self->reset, 0); } #define RESET_LOW() { if (self->reset) mp_hal_pin_write(self->reset, 0); }
#define RESET_HIGH() { if (self->reset) mp_hal_pin_write(self->reset, 1); } #define RESET_HIGH() { if (self->reset) mp_hal_pin_write(self->reset, 1); }
#define DISP_HIGH() { if (self->backlight) mp_hal_pin_write(self->backlight, 1); }
#define DISP_LOW() { if (self->backlight) mp_hal_pin_write(self->backlight, 0); }
STATIC void write_spi(mp_obj_base_t *spi_obj, const uint8_t *buf, int len) { STATIC void write_spi(mp_obj_base_t *spi_obj, const uint8_t *buf, int len) {
...@@ -821,9 +823,30 @@ STATIC mp_obj_t st7789_ST7789_init(mp_obj_t self_in) { ...@@ -821,9 +823,30 @@ STATIC mp_obj_t st7789_ST7789_init(mp_obj_t self_in) {
return mp_const_none; return mp_const_none;
} }
MP_DEFINE_CONST_FUN_OBJ_1(st7789_ST7789_init_obj, st7789_ST7789_init); MP_DEFINE_CONST_FUN_OBJ_1(st7789_ST7789_init_obj, st7789_ST7789_init);
STATIC mp_obj_t st7789_ST7789_on(mp_obj_t self_in) {
st7789_ST7789_obj_t *self = MP_OBJ_TO_PTR(self_in);
DISP_HIGH();
mp_hal_delay_ms(10);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(st7789_ST7789_on_obj, st7789_ST7789_on);
STATIC mp_obj_t st7789_ST7789_off(mp_obj_t self_in) {
st7789_ST7789_obj_t *self = MP_OBJ_TO_PTR(self_in);
DISP_LOW();
mp_hal_delay_ms(10);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(st7789_ST7789_off_obj, st7789_ST7789_off);
STATIC mp_obj_t st7789_ST7789_hline(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t st7789_ST7789_hline(size_t n_args, const mp_obj_t *args) {
st7789_ST7789_obj_t *self = MP_OBJ_TO_PTR(args[0]); st7789_ST7789_obj_t *self = MP_OBJ_TO_PTR(args[0]);
mp_int_t x = mp_obj_get_int(args[1]); mp_int_t x = mp_obj_get_int(args[1]);
...@@ -1124,6 +1147,8 @@ STATIC const mp_rom_map_elem_t st7789_ST7789_locals_dict_table[] = { ...@@ -1124,6 +1147,8 @@ STATIC const mp_rom_map_elem_t st7789_ST7789_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_set_window), MP_ROM_PTR(&st7789_ST7789_set_window_obj) }, { MP_ROM_QSTR(MP_QSTR_set_window), MP_ROM_PTR(&st7789_ST7789_set_window_obj) },
{ MP_ROM_QSTR(MP_QSTR_map_bitarray_to_rgb565), MP_ROM_PTR(&st7789_map_bitarray_to_rgb565_obj) }, { MP_ROM_QSTR(MP_QSTR_map_bitarray_to_rgb565), MP_ROM_PTR(&st7789_map_bitarray_to_rgb565_obj) },
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&st7789_ST7789_init_obj) }, { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&st7789_ST7789_init_obj) },
{ MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&st7789_ST7789_on_obj) },
{ MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(&st7789_ST7789_off_obj) },
{ MP_ROM_QSTR(MP_QSTR_pixel), MP_ROM_PTR(&st7789_ST7789_pixel_obj) }, { MP_ROM_QSTR(MP_QSTR_pixel), MP_ROM_PTR(&st7789_ST7789_pixel_obj) },
{ MP_ROM_QSTR(MP_QSTR_line), MP_ROM_PTR(&st7789_ST7789_line_obj) }, { MP_ROM_QSTR(MP_QSTR_line), MP_ROM_PTR(&st7789_ST7789_line_obj) },
{ MP_ROM_QSTR(MP_QSTR_blit_buffer), MP_ROM_PTR(&st7789_ST7789_blit_buffer_obj) }, { MP_ROM_QSTR(MP_QSTR_blit_buffer), MP_ROM_PTR(&st7789_ST7789_blit_buffer_obj) },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment