aboutsummaryrefslogtreecommitdiff
path: root/ports/stm32/lcd.c
diff options
context:
space:
mode:
authorDamien George2018-07-08 23:25:11 +1000
committerDamien George2018-07-08 23:25:11 +1000
commite1ae9939aca230758951f5b5b45084374e497254 (patch)
tree9b5e424e366e94395cd4976dd9acc6eb906e87ae /ports/stm32/lcd.c
parentaa735dc6a478f1f99f6e433b89ca047cbf536f33 (diff)
stm32: Support compiling with object representation D.
With this and previous patches the stm32 port can now be compiled using object representation D (nan boxing). Note that native code and frozen mpy files with float constants are currently not supported with this object representation.
Diffstat (limited to 'ports/stm32/lcd.c')
-rw-r--r--ports/stm32/lcd.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/ports/stm32/lcd.c b/ports/stm32/lcd.c
index 10fb54eb5..b35bd3bbd 100644
--- a/ports/stm32/lcd.c
+++ b/ports/stm32/lcd.c
@@ -307,7 +307,7 @@ STATIC mp_obj_t pyb_lcd_make_new(const mp_obj_type_t *type, size_t n_args, size_
memset(lcd->pix_buf, 0, LCD_PIX_BUF_BYTE_SIZE);
memset(lcd->pix_buf2, 0, LCD_PIX_BUF_BYTE_SIZE);
- return lcd;
+ return MP_OBJ_FROM_PTR(lcd);
}
/// \method command(instr_data, buf)
@@ -316,7 +316,7 @@ STATIC mp_obj_t pyb_lcd_make_new(const mp_obj_type_t *type, size_t n_args, size_
/// instruction, otherwise pass 1 to send data. `buf` is a buffer with the
/// instructions/data to send.
STATIC mp_obj_t pyb_lcd_command(mp_obj_t self_in, mp_obj_t instr_data_in, mp_obj_t val) {
- pyb_lcd_obj_t *self = self_in;
+ pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(self_in);
// get whether instr or data
int instr_data = mp_obj_get_int(instr_data_in);
@@ -339,7 +339,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_lcd_command_obj, pyb_lcd_command);
///
/// Set the contrast of the LCD. Valid values are between 0 and 47.
STATIC mp_obj_t pyb_lcd_contrast(mp_obj_t self_in, mp_obj_t contrast_in) {
- pyb_lcd_obj_t *self = self_in;
+ pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(self_in);
int contrast = mp_obj_get_int(contrast_in);
if (contrast < 0) {
contrast = 0;
@@ -356,7 +356,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_contrast_obj, pyb_lcd_contrast);
///
/// Turn the backlight on/off. True or 1 turns it on, False or 0 turns it off.
STATIC mp_obj_t pyb_lcd_light(mp_obj_t self_in, mp_obj_t value) {
- pyb_lcd_obj_t *self = self_in;
+ pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (mp_obj_is_true(value)) {
mp_hal_pin_high(self->pin_bl); // set pin high to turn backlight on
} else {
@@ -370,7 +370,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_light_obj, pyb_lcd_light);
///
/// Write the string `str` to the screen. It will appear immediately.
STATIC mp_obj_t pyb_lcd_write(mp_obj_t self_in, mp_obj_t str) {
- pyb_lcd_obj_t *self = self_in;
+ pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(self_in);
size_t len;
const char *data = mp_obj_str_get_data(str, &len);
lcd_write_strn(self, data, len);
@@ -384,7 +384,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_write_obj, pyb_lcd_write);
///
/// This method writes to the hidden buffer. Use `show()` to show the buffer.
STATIC mp_obj_t pyb_lcd_fill(mp_obj_t self_in, mp_obj_t col_in) {
- pyb_lcd_obj_t *self = self_in;
+ pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(self_in);
int col = mp_obj_get_int(col_in);
if (col) {
col = 0xff;
@@ -401,7 +401,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_fill_obj, pyb_lcd_fill);
///
/// This method reads from the visible buffer.
STATIC mp_obj_t pyb_lcd_get(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) {
- pyb_lcd_obj_t *self = self_in;
+ pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(self_in);
int x = mp_obj_get_int(x_in);
int y = mp_obj_get_int(y_in);
if (0 <= x && x <= 127 && 0 <= y && y <= 31) {
@@ -420,7 +420,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_lcd_get_obj, pyb_lcd_get);
///
/// This method writes to the hidden buffer. Use `show()` to show the buffer.
STATIC mp_obj_t pyb_lcd_pixel(size_t n_args, const mp_obj_t *args) {
- pyb_lcd_obj_t *self = args[0];
+ pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(args[0]);
int x = mp_obj_get_int(args[1]);
int y = mp_obj_get_int(args[2]);
if (0 <= x && x <= 127 && 0 <= y && y <= 31) {
@@ -442,7 +442,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_pixel_obj, 4, 4, pyb_lcd_pixe
/// This method writes to the hidden buffer. Use `show()` to show the buffer.
STATIC mp_obj_t pyb_lcd_text(size_t n_args, const mp_obj_t *args) {
// extract arguments
- pyb_lcd_obj_t *self = args[0];
+ pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(args[0]);
size_t len;
const char *data = mp_obj_str_get_data(args[1], &len);
int x0 = mp_obj_get_int(args[2]);
@@ -488,7 +488,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_text_obj, 5, 5, pyb_lcd_text)
///
/// Show the hidden buffer on the screen.
STATIC mp_obj_t pyb_lcd_show(mp_obj_t self_in) {
- pyb_lcd_obj_t *self = self_in;
+ pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(self_in);
memcpy(self->pix_buf, self->pix_buf2, LCD_PIX_BUF_BYTE_SIZE);
for (uint page = 0; page < 4; page++) {
lcd_out(self, LCD_INSTR, 0xb0 | page); // page address set