Prusa MINI Firmware overview
|
#include "st7789v.h"
#include <guiconfig.h>
#include <string.h>
#include <stdlib.h>
#include "stm32f4xx_hal.h"
#include "gpio.h"
|
void | st7789v_init (void) |
|
void | st7789v_done (void) |
|
void | st7789v_clear (color_t clr) |
|
void | st7789v_set_pixel (point_ui16_t pt, color_t clr) |
|
void | st7789v_clip_rect (rect_ui16_t rc) |
|
void | st7789v_draw_line (point_ui16_t pt, point_ui16_t pt1, color_t clr) |
|
void | st7789v_draw_rect (rect_ui16_t rc, color_t clr) |
|
void | st7789v_fill_rect (rect_ui16_t rc, color_t clr) |
|
void | st7789v_draw_char (point_ui16_t pt, char chr, font_t *pf, color_t clr0, color_t clr1) |
|
void | st7789v_draw_text (rect_ui16_t rc, const char *str, font_t *pf, color_t clr0, color_t clr1) |
|
void | st7789v_draw_png (point_ui16_t pt, FILE *pf) |
|
void | st7789v_gamma_set_direct (uint8_t gamma_enu) |
|
uint8_t | st7789v_read_ctrl (void) |
|
void | st7789v_ctrl_set (uint8_t ctrl) |
|
static void | st7789v_set_cs (void) |
|
static void | st7789v_clr_cs (void) |
|
static void | st7789v_set_rs (void) |
|
static void | st7789v_clr_rs (void) |
|
static void | st7789v_set_rst (void) |
|
static void | st7789v_clr_rst (void) |
|
static void | st7789v_fill_ui16 (uint16_t *p, uint16_t v, uint16_t c) |
|
static int | is_interrupt (void) |
|
void | st7789v_delay_ms (uint32_t ms) |
|
void | st7789v_spi_wr_byte (uint8_t b) |
|
void | st7789v_spi_wr_bytes (uint8_t *pb, uint16_t size) |
|
void | st7789v_spi_rd_bytes (uint8_t *pb, uint16_t size) |
|
void | st7789v_cmd (uint8_t cmd, uint8_t *pdata, uint16_t size) |
|
void | st7789v_wr (uint8_t *pdata, uint16_t size) |
|
void | st7789v_rd (uint8_t *pdata, uint16_t size) |
|
void | st7789v_cmd_slpout (void) |
|
void | st7789v_cmd_madctl (uint8_t madctl) |
|
void | st7789v_cmd_colmod (uint8_t colmod) |
|
void | st7789v_cmd_dispon (void) |
|
void | st7789v_cmd_caset (uint16_t x, uint16_t cx) |
|
void | st7789v_cmd_raset (uint16_t y, uint16_t cy) |
|
void | st7789v_cmd_ramwr (uint8_t *pdata, uint16_t size) |
|
void | st7789v_cmd_ramrd (uint8_t *pdata, uint16_t size) |
|
void | st7789v_init_ctl_pins (void) |
|
void | st7789v_reset (void) |
|
color_t | st7789v_get_pixel (point_ui16_t pt) |
|
void | st7789v_set_pixel_directColor (point_ui16_t pt, uint16_t directColor) |
|
static uint16_t | set_num_of_ones (uint8_t num_of_ones) |
|
static uint16_t | rd18bit_to_16bit (uint8_t *buff) |
|
uint16_t | st7789v_get_pixel_directColor (point_ui16_t pt) |
|
static void | rop_rgb888_invert (uint8_t *ppx888) |
|
static void | rop_rgb888_swapbw (uint8_t *ppx888) |
|
static void | rop_rgb888_disabled (uint8_t *ppx888) |
|
static void | rop_rgb8888_swapbw (uint8_t *ppx) |
|
void | st7789v_draw_png_ex (point_ui16_t pt, FILE *pf, color_t clr0, uint8_t rop) |
|
void | st7789v_draw_icon (point_ui16_t pt, uint16_t id_res, color_t clr0, uint8_t rop) |
|
void | st7789v_enable_safe_mode (void) |
| enable safe mode (direct acces + safe delay) More...
|
|
void | st7789v_spi_tx_complete (void) |
|
◆ ST7789V_COLS
◆ ST7789V_ROWS
◆ CMD_SLPIN
◆ CMD_SLPOUT
◆ CMD_INVOFF
◆ CMD_INVON
◆ CMD_GAMMA_SET
#define CMD_GAMMA_SET 0x26 |
◆ CMD_DISPOFF
◆ CMD_DISPON
◆ CMD_CASET
◆ CMD_RASET
◆ CMD_RAMWR
◆ CMD_RAMRD
◆ CMD_MADCTL
◆ CMD_COLMOD
◆ CMD_RAMWRC
◆ CMD_WRDISBV
◆ CMD_RDDISBV
◆ CMD_WRCTRLD
◆ CMD_RDCTRLD
◆ GAMMA_CURVE0
#define GAMMA_CURVE0 0x01 |
◆ GAMMA_CURVE1
#define GAMMA_CURVE1 0x02 |
◆ GAMMA_CURVE2
#define GAMMA_CURVE2 0x04 |
◆ GAMMA_CURVE3
#define GAMMA_CURVE3 0x08 |
◆ MASK_CTRLD_BCTRL
#define MASK_CTRLD_BCTRL (0x01 << 5) |
◆ MASK_CTRLD_DD
#define MASK_CTRLD_DD (0x01 << 3) |
◆ MASK_CTRLD_BL
#define MASK_CTRLD_BL (0x01 << 2) |
◆ CLR565_WHITE
#define CLR565_WHITE 0xffff |
◆ CLR565_BLACK
#define CLR565_BLACK 0x0000 |
◆ CLR565_RED
#define CLR565_RED 0xf800 |
◆ CLR565_CYAN
#define CLR565_CYAN 0x0000 |
◆ CLR565_MAGENTA
#define CLR565_MAGENTA 0x0000 |
◆ CLR565_GREEN
#define CLR565_GREEN 0x07e0 |
◆ CLR565_YELLOW
#define CLR565_YELLOW 0xffe0 |
◆ CLR565_ORANGE
#define CLR565_ORANGE 0x0000 |
◆ CLR565_GRAY
#define CLR565_GRAY 0x38e7 |
◆ CLR565_BLUE
#define CLR565_BLUE 0x001f |
◆ _COLOR_565
◆ _565_COLOR
◆ FLG_CS
◆ FLG_RS
◆ FLG_RST
◆ SWAPBW_TOLERANCE
#define SWAPBW_TOLERANCE 64 |
◆ st7789v_init()
328 #ifdef ST7789V_USE_RTOS
330 #endif //ST7789V_USE_RTOS
◆ st7789v_done()
◆ st7789v_clear()
◆ st7789v_set_pixel()
◆ st7789v_clip_rect()
◆ st7789v_draw_line()
440 int dx = pt1.
x - pt.
x;
441 int dy = pt1.
y - pt.
y;
442 int sx = (dx >= 0) ? 1 : -1;
443 int sy = (dy >= 0) ? 1 : -1;
444 int cx = (sx > 0) ? dx : -dx;
445 int cy = (sy > 0) ? dy : -dy;
448 if ((dx == 0) || (dy == 0)) {
454 for (n = dx; n > 0; n--) {
456 if ((cx -= cy) <= 0) {
463 for (n = dy; n > 0; n--) {
465 if ((cy -= cx) <= 0) {
472 for (n = dx; n > 0; n--) {
◆ st7789v_draw_rect()
◆ st7789v_fill_rect()
496 uint32_t
size = (uint32_t)rc.
w * rc.
h * 2;
507 for (
i = 0;
i < n;
i++)
◆ st7789v_draw_char()
523 uint16_t bpc = bpr * h;
530 pch = (pf->
pcs) + ((chr - pf->
asc_min) * bpc);
532 for (
i = 0;
i <= pms;
i++)
534 for (j = 0; j < h; j++) {
536 for (
i = 0;
i < w;
i++) {
537 if ((
i % ppb) == 0) {
540 crd = pch[rb + j * bpr];
545 *(p++) = clr565[crd & pms];
548 *(p++) = clr565[crd >> (8 - bpp)];
◆ st7789v_draw_text()
564 int len = strlen(str);
567 for (
i = 0;
i < len;
i++) {
572 if ((y + pf->
h) > (rc.
y + rc.
h))
577 if ((x + pf->
w) > (rc.
x + rc.
w))
◆ st7789v_draw_png()
◆ st7789v_gamma_set_direct()
◆ st7789v_read_ctrl()
◆ st7789v_ctrl_set()
◆ st7789v_set_cs()
◆ st7789v_clr_cs()
◆ st7789v_set_rs()
◆ st7789v_clr_rs()
◆ st7789v_set_rst()
◆ st7789v_clr_rst()
◆ st7789v_fill_ui16()
static void st7789v_fill_ui16 |
( |
uint16_t * |
p, |
|
|
uint16_t |
v, |
|
|
uint16_t |
c |
|
) |
| |
|
static |
◆ is_interrupt()
static int is_interrupt |
( |
void |
| ) |
|
|
static |
143 return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
◆ st7789v_delay_ms()
void st7789v_delay_ms |
( |
uint32_t |
ms | ) |
|
148 volatile uint32_t temp;
151 temp = SysTick->CTRL;
152 }
while ((temp & 0x01) && !(temp & (1 << 16)));
155 #ifdef ST7789V_USE_RTOS
◆ st7789v_spi_wr_byte()
◆ st7789v_spi_wr_bytes()
void st7789v_spi_wr_bytes |
( |
uint8_t * |
pb, |
|
|
uint16_t |
size |
|
) |
| |
169 #ifdef ST7789V_USE_RTOS
172 #endif //ST7789V_USE_RTOS
174 #ifdef ST7789V_USE_RTOS
176 #else //ST7789V_USE_RTOS
178 #endif //ST7789V_USE_RTOS
◆ st7789v_spi_rd_bytes()
void st7789v_spi_rd_bytes |
( |
uint8_t * |
pb, |
|
|
uint16_t |
size |
|
) |
| |
191 #ifdef ST7789V_USE_RTOS
194 #endif //ST7789V_USE_RTOS
196 #ifdef ST7789V_USE_RTOS
198 #endif //ST7789V_USE_RTOS
◆ st7789v_cmd()
◆ st7789v_wr()
222 if (!(pdata &&
size))
◆ st7789v_rd()
235 if (!(pdata &&
size))
◆ st7789v_cmd_slpout()
◆ st7789v_cmd_madctl()
◆ st7789v_cmd_colmod()
◆ st7789v_cmd_dispon()
◆ st7789v_cmd_caset()
void st7789v_cmd_caset |
( |
uint16_t |
x, |
|
|
uint16_t |
cx |
|
) |
| |
264 uint8_t data[4] = { x >> 8, x & 0xff, cx >> 8, cx & 0xff };
◆ st7789v_cmd_raset()
void st7789v_cmd_raset |
( |
uint16_t |
y, |
|
|
uint16_t |
cy |
|
) |
| |
269 uint8_t data[4] = { y >> 8, y & 0xff, cy >> 8, cy & 0xff };
◆ st7789v_cmd_ramwr()
void st7789v_cmd_ramwr |
( |
uint8_t * |
pdata, |
|
|
uint16_t |
size |
|
) |
| |
◆ st7789v_cmd_ramrd()
void st7789v_cmd_ramrd |
( |
uint8_t * |
pdata, |
|
|
uint16_t |
size |
|
) |
| |
◆ st7789v_init_ctl_pins()
◆ st7789v_reset()
316 volatile uint16_t
delay = 0;
317 int irq = __get_PRIMASK() & 1;
318 if (irq) __disable_irq();
321 if (irq) __enable_irq();
◆ st7789v_get_pixel()
◆ st7789v_set_pixel_directColor()
◆ set_num_of_ones()
static uint16_t set_num_of_ones |
( |
uint8_t |
num_of_ones | ) |
|
|
static |
393 return ~((uint16_t)(-1) << num_of_ones);
◆ rd18bit_to_16bit()
static uint16_t rd18bit_to_16bit |
( |
uint8_t * |
buff | ) |
|
|
static |
◆ st7789v_get_pixel_directColor()
425 enum { buff_sz = 5 };
◆ rop_rgb888_invert()
◆ rop_rgb888_swapbw()
600 if ((l0 <= r) && (r <= l1) && (l0 <= g) && (g <= l1) && (l0 <=
b) && (
b <= l1)) {
◆ rop_rgb888_disabled()
614 if ((l0 <= r) && (r <= l1) && (l0 <= g) && (g <= l1) && (l0 <=
b) && (
b <= l1)) {
◆ rop_rgb8888_swapbw()
626 if ((r == g) && (g ==
b)) {
636 }
else if ((
a < 128)) {
◆ st7789v_draw_png_ex()
◆ st7789v_draw_icon()
◆ st7789v_enable_safe_mode()
enable safe mode (direct acces + safe delay)
◆ st7789v_spi_tx_complete()
928 #ifdef ST7789V_USE_RTOS
930 #endif //ST7789V_USE_RTOS
◆ st7789v_flg
◆ st7789v_x
◆ st7789v_y
◆ st7789v_cx
◆ st7789v_cy
◆ st7789v_buff
◆ st7789v_clip
◆ st7789v_display
◆ st7789v_config
Initial value:= {
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
}
◆ st7789v_reset_delay
uint16_t st7789v_reset_delay = 0 |
#define FLG_RST
Definition: st7789v.c:73
static void st7789v_set_rs(void)
Definition: st7789v.c:117
st7789v_config_t st7789v_config
Definition: st7789v.c:905
void st7789v_wr(uint8_t *pdata, uint16_t size)
Definition: st7789v.c:221
#define CMD_DISPON
Definition: st7789v.c:24
void st7789v_cmd_madctl(uint8_t madctl)
Definition: st7789v.c:251
uint16_t y
Definition: guitypes.h:71
uint8_t h
Definition: guitypes.h:78
#define FONT_FLG_SWAP
Definition: guitypes.h:36
uint16_t w
Definition: guitypes.h:72
#define CMD_RAMWR
Definition: st7789v.c:27
#define GPIO_MODE_OUTPUT_PP
Definition: stm32f4xx_hal_gpio.h:136
static color_t color_alpha(color_t clr0, color_t clr1, uint8_t alpha)
Definition: guitypes.h:141
void st7789v_cmd_dispon(void)
Definition: st7789v.c:259
#define GPIO_SPEED_FREQ_HIGH
Definition: stm32f4xx_hal_gpio.h:160
rect_ui16_t st7789v_clip
Definition: st7789v.c:84
static int is_interrupt(void)
Definition: st7789v.c:142
void st7789v_reset(void)
Definition: st7789v.c:312
void st7789v_delay_ms(uint32_t ms)
Definition: st7789v.c:146
void st7789v_draw_text(rect_ui16_t rc, const char *str, font_t *pf, color_t clr0, color_t clr1)
Definition: st7789v.c:562
void st7789v_rd(uint8_t *pdata, uint16_t size)
Definition: st7789v.c:234
#define CMD_SLPOUT
Definition: st7789v.c:19
#define GAMMA_CURVE0
Definition: st7789v.c:43
void st7789v_clear(color_t clr)
Definition: st7789v.c:349
void * pcs
Definition: guitypes.h:81
SPI_HandleTypeDef * phspi
Definition: st7789v.h:20
#define FLG_RS
Definition: st7789v.c:72
uint8_t st7789v_flg
Definition: st7789v.c:75
void st7789v_set_pixel(point_ui16_t pt, color_t clr)
Definition: st7789v.c:364
FILE * resource_fopen(uint16_t id, const char *opentype)
Definition: guitypes.c:180
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
void st7789v_spi_rd_bytes(uint8_t *pb, uint16_t size)
Definition: st7789v.c:183
uint16_t x
Definition: guitypes.h:65
uint8_t data[8]
Definition: masstorage.h:49
uint8_t i
Definition: screen_test_graph.c:72
void st7789v_fill_rect(rect_ui16_t rc, color_t clr)
Definition: st7789v.c:490
void st7789v_done(void)
Definition: st7789v.c:346
int32_t osSignalSet(osThreadId thread_id, int32_t signal)
Set the specified Signal Flags of an active thread.
Definition: cmsis_os.c:545
void st7789v_draw_char(point_ui16_t pt, char chr, font_t *pf, color_t clr0, color_t clr1)
Definition: st7789v.c:514
uint8_t colmod
Definition: st7789v.h:25
uint8_t pinCS
Definition: st7789v.h:21
#define ST7789V_COLS
Definition: st7789v.c:14
uint8_t pinRS
Definition: st7789v.h:22
osThreadId osThreadGetId(void)
Return the thread ID of the current running thread.
Definition: cmsis_os.c:283
void st7789v_cmd_caset(uint16_t x, uint16_t cx)
Definition: st7789v.c:263
#define CMD_CASET
Definition: st7789v.c:25
void st7789v_cmd_slpout(void)
Definition: st7789v.c:247
void st7789v_draw_png_ex(point_ui16_t pt, FILE *pf, color_t clr0, uint8_t rop)
Definition: st7789v.c:885
Definition: guitypes.h:64
void st7789v_draw_line(point_ui16_t pt, point_ui16_t pt1, color_t clr)
Definition: st7789v.c:438
#define GPIO_PULLUP
Definition: stm32f4xx_hal_gpio.h:171
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
display_fill_rect_t * fill_rect
Definition: display.h:33
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32f4xx_hal_def.h:55
static int gpio_get(uint8_t pin8)
Definition: gpio.h:94
void st7789v_spi_wr_byte(uint8_t b)
Definition: st7789v.c:163
osEvent osSignalWait(int32_t signals, uint32_t millisec)
Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
Definition: cmsis_os.c:586
void st7789v_cmd_raset(uint16_t y, uint16_t cy)
Definition: st7789v.c:268
#define CMD_MADCTL
Definition: st7789v.c:29
uint16_t y
Definition: guitypes.h:66
static int rect_empty_ui16(rect_ui16_t rc)
Definition: guitypes.h:177
rect_ui16_t rect_intersect_ui16(rect_ui16_t rc, rect_ui16_t rc1)
Definition: guitypes.c:37
static void gpio_init(uint8_t pin8, uint32_t mode, uint32_t pull, uint32_t speed)
Definition: gpio.h:102
static void st7789v_set_cs(void)
Definition: st7789v.c:107
char asc_max
Definition: guitypes.h:83
uint8_t bpr
Definition: guitypes.h:79
void st7789v_cmd_colmod(uint8_t colmod)
Definition: st7789v.c:255
uint8_t st7789v_buff[ST7789V_COLS *2 *16]
Definition: st7789v.c:82
uint8_t w
Definition: guitypes.h:77
uint8_t madctl
Definition: st7789v.h:26
HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
void st7789v_init(void)
Definition: st7789v.c:327
#define GPIO_NOPULL
Definition: stm32f4xx_hal_gpio.h:170
uint8_t pinRST
Definition: st7789v.h:23
void st7789v_draw_png(point_ui16_t pt, FILE *pf)
Definition: st7789v.c:883
#define osWaitForever
wait forever timeout value
Definition: cmsis_os.h:230
list a
Definition: createSpeedLookupTable.py:29
static void st7789v_clr_rs(void)
Definition: st7789v.c:122
const uint8_t[]
Definition: 404_html.c:3
void st7789v_draw_icon(point_ui16_t pt, uint16_t id_res, color_t clr0, uint8_t rop)
Definition: st7789v.c:646
display_t * display
Definition: display.c:6
uint16_t h
Definition: guitypes.h:73
void delay(uint32_t ms)
Definition: wiring_time.c:42
#define CMD_RASET
Definition: st7789v.c:26
void st7789v_spi_wr_bytes(uint8_t *pb, uint16_t size)
Definition: st7789v.c:167
#define _565_COLOR(clr)
Definition: st7789v.c:68
#define ST7789V_FLG_DMA
Definition: st7789v.h:9
#define CMD_COLMOD
Definition: st7789v.c:32
#define ST7789V_ROWS
Definition: st7789v.c:15
#define ST7789V_FLG_SAFE
Definition: st7789v.h:11
uint32_t flg
Definition: guitypes.h:80
static void gpio_set(uint8_t pin8, int state)
Definition: gpio.h:98
#define ST7789V_SIG_SPI_TX
Definition: guiconfig.h:18
void st7789v_init_ctl_pins(void)
Definition: st7789v.c:300
uint16_t x
Definition: guitypes.h:70
void st7789v_cmd_ramrd(uint8_t *pdata, uint16_t size)
Definition: st7789v.c:277
static uint16_t set_num_of_ones(uint8_t num_of_ones)
Definition: st7789v.c:392
static void st7789v_clr_rst(void)
Definition: st7789v.c:132
#define SWAPBW_TOLERANCE
Definition: st7789v.c:592
uint16_t st7789v_reset_delay
Definition: st7789v.c:920
void st7789v_cmd(uint8_t cmd, uint8_t *pdata, uint16_t size)
Definition: st7789v.c:206
HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)
void HAL_Delay(uint32_t Delay)
This function provides minimum delay (in milliseconds) based on variable incremented.
Definition: stm32f4xx_hal.c:393
#define HAL_MAX_DELAY
Definition: stm32f4xx_hal_def.h:76
#define GPIO_MODE_INPUT
Definition: stm32f4xx_hal_gpio.h:135
#define _COLOR_565(clr)
Definition: st7789v.c:66
char asc_min
Definition: guitypes.h:82
HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)
#define FLG_CS
Definition: st7789v.c:71
static int point_in_rect_ui16(point_ui16_t pt, rect_ui16_t rc)
Definition: guitypes.h:169
#define FONT_FLG_LSBF
Definition: guitypes.h:37
uint8_t flg
Definition: st7789v.h:24
void st7789v_draw_rect(rect_ui16_t rc, color_t clr)
Definition: st7789v.c:479
#define CMD_RAMRD
Definition: st7789v.c:28
static uint16_t rd18bit_to_16bit(uint8_t *buff)
Definition: st7789v.c:418
void st7789v_cmd_ramwr(uint8_t *pdata, uint16_t size)
Definition: st7789v.c:273
list b
Definition: createSpeedLookupTable.py:30
HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
static void st7789v_set_rst(void)
Definition: st7789v.c:127
#define GPIO_SPEED_FREQ_LOW
Definition: stm32f4xx_hal_gpio.h:158
static void st7789v_clr_cs(void)
Definition: st7789v.c:112
static void st7789v_fill_ui16(uint16_t *p, uint16_t v, uint16_t c)
Definition: st7789v.c:137
static point_ui16_t point_ui16(uint16_t x, uint16_t y)
Definition: guitypes.h:154
static png_bytep size_t size
Definition: pngwrite.c:2170