diff options
Diffstat (limited to 'ports/stm32/lcd.c')
| -rw-r--r-- | ports/stm32/lcd.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/ports/stm32/lcd.c b/ports/stm32/lcd.c index a78718872..ec53b1c46 100644 --- a/ports/stm32/lcd.c +++ b/ports/stm32/lcd.c @@ -105,11 +105,11 @@ typedef struct _pyb_lcd_obj_t { byte pix_buf2[LCD_PIX_BUF_BYTE_SIZE]; } pyb_lcd_obj_t; -STATIC void lcd_delay(void) { +static void lcd_delay(void) { __asm volatile ("nop\nnop"); } -STATIC void lcd_out(pyb_lcd_obj_t *lcd, int instr_data, uint8_t i) { +static void lcd_out(pyb_lcd_obj_t *lcd, int instr_data, uint8_t i) { lcd_delay(); mp_hal_pin_low(lcd->pin_cs1); // CS=0; enable if (instr_data == LCD_INSTR) { @@ -125,7 +125,7 @@ STATIC void lcd_out(pyb_lcd_obj_t *lcd, int instr_data, uint8_t i) { // write a string to the LCD at the current cursor location // output it straight away (doesn't use the pixel buffer) -STATIC void lcd_write_strn(pyb_lcd_obj_t *lcd, const char *str, unsigned int len) { +static void lcd_write_strn(pyb_lcd_obj_t *lcd, const char *str, unsigned int len) { int redraw_min = lcd->line * LCD_CHAR_BUF_W + lcd->column; int redraw_max = redraw_min; for (; len > 0; len--, str++) { @@ -192,7 +192,7 @@ STATIC void lcd_write_strn(pyb_lcd_obj_t *lcd, const char *str, unsigned int len /// /// Construct an LCD object in the given skin position. `skin_position` can be 'X' or 'Y', and /// should match the position where the LCD pyskin is plugged in. -STATIC mp_obj_t pyb_lcd_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +static mp_obj_t pyb_lcd_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { // check arguments mp_arg_check_num(n_args, n_kw, 1, 1, false); @@ -323,7 +323,7 @@ STATIC mp_obj_t pyb_lcd_make_new(const mp_obj_type_t *type, size_t n_args, size_ /// Send an arbitrary command to the LCD. Pass 0 for `instr_data` to send an /// 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) { +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 = MP_OBJ_TO_PTR(self_in); // get whether instr or data @@ -341,12 +341,12 @@ STATIC mp_obj_t pyb_lcd_command(mp_obj_t self_in, mp_obj_t instr_data_in, mp_obj return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_lcd_command_obj, pyb_lcd_command); +static MP_DEFINE_CONST_FUN_OBJ_3(pyb_lcd_command_obj, pyb_lcd_command); /// \method contrast(value) /// /// 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) { +static mp_obj_t pyb_lcd_contrast(mp_obj_t self_in, mp_obj_t contrast_in) { pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(self_in); int contrast = mp_obj_get_int(contrast_in); if (contrast < 0) { @@ -358,12 +358,12 @@ STATIC mp_obj_t pyb_lcd_contrast(mp_obj_t self_in, mp_obj_t contrast_in) { lcd_out(self, LCD_INSTR, contrast); // electronic volume register set return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_contrast_obj, pyb_lcd_contrast); +static MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_contrast_obj, pyb_lcd_contrast); /// \method light(value) /// /// 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) { +static mp_obj_t pyb_lcd_light(mp_obj_t self_in, mp_obj_t value) { 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 @@ -372,26 +372,26 @@ STATIC mp_obj_t pyb_lcd_light(mp_obj_t self_in, mp_obj_t value) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_light_obj, pyb_lcd_light); +static MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_light_obj, pyb_lcd_light); /// \method write(str) /// /// 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) { +static mp_obj_t pyb_lcd_write(mp_obj_t self_in, mp_obj_t str) { 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); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_write_obj, pyb_lcd_write); +static MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_write_obj, pyb_lcd_write); /// \method fill(colour) /// /// Fill the screen with the given colour (0 or 1 for white or black). /// /// 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) { +static mp_obj_t pyb_lcd_fill(mp_obj_t self_in, mp_obj_t col_in) { pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(self_in); int col = mp_obj_get_int(col_in); if (col) { @@ -401,14 +401,14 @@ STATIC mp_obj_t pyb_lcd_fill(mp_obj_t self_in, mp_obj_t col_in) { memset(self->pix_buf2, col, LCD_PIX_BUF_BYTE_SIZE); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_fill_obj, pyb_lcd_fill); +static MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_fill_obj, pyb_lcd_fill); /// \method get(x, y) /// /// Get the pixel at the position `(x, y)`. Returns 0 or 1. /// /// 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) { +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 = MP_OBJ_TO_PTR(self_in); int x = mp_obj_get_int(x_in); int y = mp_obj_get_int(y_in); @@ -420,14 +420,14 @@ STATIC mp_obj_t pyb_lcd_get(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) { } return mp_obj_new_int(0); } -STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_lcd_get_obj, pyb_lcd_get); +static MP_DEFINE_CONST_FUN_OBJ_3(pyb_lcd_get_obj, pyb_lcd_get); /// \method pixel(x, y, colour) /// /// Set the pixel at `(x, y)` to the given colour (0 or 1). /// /// 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) { +static mp_obj_t pyb_lcd_pixel(size_t n_args, const mp_obj_t *args) { 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]); @@ -441,14 +441,14 @@ STATIC mp_obj_t pyb_lcd_pixel(size_t n_args, const mp_obj_t *args) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_pixel_obj, 4, 4, pyb_lcd_pixel); +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_pixel_obj, 4, 4, pyb_lcd_pixel); /// \method text(str, x, y, colour) /// /// Draw the given text to the position `(x, y)` using the given colour (0 or 1). /// /// 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) { +static mp_obj_t pyb_lcd_text(size_t n_args, const mp_obj_t *args) { // extract arguments pyb_lcd_obj_t *self = MP_OBJ_TO_PTR(args[0]); size_t len; @@ -490,12 +490,12 @@ STATIC mp_obj_t pyb_lcd_text(size_t n_args, const mp_obj_t *args) { return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_text_obj, 5, 5, pyb_lcd_text); +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_text_obj, 5, 5, pyb_lcd_text); /// \method show() /// /// Show the hidden buffer on the screen. -STATIC mp_obj_t pyb_lcd_show(mp_obj_t self_in) { +static mp_obj_t pyb_lcd_show(mp_obj_t 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++) { @@ -508,9 +508,9 @@ STATIC mp_obj_t pyb_lcd_show(mp_obj_t self_in) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_lcd_show_obj, pyb_lcd_show); +static MP_DEFINE_CONST_FUN_OBJ_1(pyb_lcd_show_obj, pyb_lcd_show); -STATIC const mp_rom_map_elem_t pyb_lcd_locals_dict_table[] = { +static const mp_rom_map_elem_t pyb_lcd_locals_dict_table[] = { // instance methods { MP_ROM_QSTR(MP_QSTR_command), MP_ROM_PTR(&pyb_lcd_command_obj) }, { MP_ROM_QSTR(MP_QSTR_contrast), MP_ROM_PTR(&pyb_lcd_contrast_obj) }, @@ -523,7 +523,7 @@ STATIC const mp_rom_map_elem_t pyb_lcd_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&pyb_lcd_show_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(pyb_lcd_locals_dict, pyb_lcd_locals_dict_table); +static MP_DEFINE_CONST_DICT(pyb_lcd_locals_dict, pyb_lcd_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( pyb_lcd_type, |
