43#define CHIP_NAME "Sitronix ST7789"
44#define MANUFACTURER_NAME "Sitronix"
45#define SUPPLY_VOLTAGE_MIN 2.4f
46#define SUPPLY_VOLTAGE_MAX 3.3f
47#define MAX_CURRENT 7.5f
48#define TEMPERATURE_MIN -30.0f
49#define TEMPERATURE_MAX 85.0f
50#define DRIVER_VERSION 1000
61#define ST7789_CMD_NOP 0x00
62#define ST7789_CMD_SWRESET 0x01
63#define ST7789_CMD_SLPIN 0x10
64#define ST7789_CMD_SLPOUT 0x11
65#define ST7789_CMD_PTLON 0x12
66#define ST7789_CMD_NORON 0x13
67#define ST7789_CMD_INVOFF 0x20
68#define ST7789_CMD_INVON 0x21
69#define ST7789_CMD_GAMSET 0x26
70#define ST7789_CMD_DISPOFF 0x28
71#define ST7789_CMD_DISPON 0x29
72#define ST7789_CMD_CASET 0x2A
73#define ST7789_CMD_RASET 0x2B
74#define ST7789_CMD_RAMWR 0x2C
75#define ST7789_CMD_PTLAR 0x30
76#define ST7789_CMD_VSCRDEF 0x33
77#define ST7789_CMD_TEOFF 0x34
78#define ST7789_CMD_TEON 0x35
79#define ST7789_CMD_MADCTL 0x36
80#define ST7789_CMD_VSCRSADD 0x37
81#define ST7789_CMD_IDMOFF 0x38
82#define ST7789_CMD_IDMON 0x39
83#define ST7789_CMD_COLMOD 0x3A
84#define ST7789_CMD_RAMWRC 0x3C
85#define ST7789_CMD_TESCAN 0x44
86#define ST7789_CMD_WRDISBV 0x51
87#define ST7789_CMD_WRCTRLD 0x53
88#define ST7789_CMD_WRCACE 0x55
89#define ST7789_CMD_WRCABCMB 0x5E
90#define ST7789_CMD_RAMCTRL 0xB0
91#define ST7789_CMD_RGBCTRL 0xB1
92#define ST7789_CMD_PORCTRL 0xB2
93#define ST7789_CMD_FRCTRL1 0xB3
94#define ST7789_CMD_PARCTRL 0xB5
95#define ST7789_CMD_GCTRL 0xB7
96#define ST7789_CMD_GTADJ 0xB8
97#define ST7789_CMD_DGMEN 0xBA
98#define ST7789_CMD_VCOMS 0xBB
99#define ST7789_CMD_LCMCTRL 0xC0
100#define ST7789_CMD_IDSET 0xC1
101#define ST7789_CMD_VDVVRHEN 0xC2
102#define ST7789_CMD_VRHS 0xC3
103#define ST7789_CMD_VDVSET 0xC4
104#define ST7789_CMD_VCMOFSET 0xC5
105#define ST7789_CMD_FRCTR2 0xC6
106#define ST7789_CMD_CABCCTRL 0xC7
107#define ST7789_CMD_REGSEL1 0xC8
108#define ST7789_CMD_REGSEL2 0xCA
109#define ST7789_CMD_PWMFRSEL 0xCC
110#define ST7789_CMD_PWCTRL1 0xD0
111#define ST7789_CMD_VAPVANEN 0xD2
112#define ST7789_CMD_CMD2EN 0xDF
113#define ST7789_CMD_PVGAMCTRL 0xE0
114#define ST7789_CMD_NVGAMCTRL 0xE1
115#define ST7789_CMD_DGMLUTR 0xE2
116#define ST7789_CMD_DGMLUTB 0xE3
117#define ST7789_CMD_GATECTRL 0xE4
118#define ST7789_CMD_SPI2EN 0xE7
119#define ST7789_CMD_PWCTRL2 0xE8
120#define ST7789_CMD_EQCTRL 0xE9
121#define ST7789_CMD_PROMCTRL 0xEC
122#define ST7789_CMD_PROMEN 0xFA
123#define ST7789_CMD_NVMSET 0xFC
124#define ST7789_CMD_PROMACT 0xFE
136static uint8_t a_st7789_write_byte(
st7789_handle_t *handle, uint8_t data, uint8_t cmd)
165static uint8_t a_st7789_write_bytes(
st7789_handle_t *handle, uint8_t *data, uint16_t len, uint8_t cmd)
206 handle->
debug_print(
"st7789: write command failed.\n");
237 handle->
debug_print(
"st7789: write command failed.\n");
269 handle->
debug_print(
"st7789: write command failed.\n");
300 handle->
debug_print(
"st7789: write command failed.\n");
332 handle->
debug_print(
"st7789: write command failed.\n");
363 handle->
debug_print(
"st7789: write command failed.\n");
394 handle->
debug_print(
"st7789: write command failed.\n");
425 handle->
debug_print(
"st7789: write command failed.\n");
457 handle->
debug_print(
"st7789: write command failed.\n");
461 if (a_st7789_write_byte(handle, gamma & 0x0F,
ST7789_DATA) != 0)
463 handle->
debug_print(
"st7789: write data failed.\n");
494 handle->
debug_print(
"st7789: write command failed.\n");
525 handle->
debug_print(
"st7789: write command failed.\n");
559 if ((start_address > 319) || (end_address > 319))
561 handle->
debug_print(
"st7789: address is invalid.\n");
565 if (start_address >= end_address)
567 handle->
debug_print(
"st7789: start_address >= end_address.\n");
574 handle->
debug_print(
"st7789: write command failed.\n");
578 buf[0] = (start_address >> 8) & 0xFF;
579 buf[1] = (start_address >> 0) & 0xFF;
580 buf[2] = (end_address >> 8) & 0xFF;
581 buf[3] = (end_address >> 0) & 0xFF;
582 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
584 handle->
debug_print(
"st7789: write data failed.\n");
618 if ((start_address > 319) || (end_address > 319))
620 handle->
debug_print(
"st7789: address is invalid.\n");
624 if (start_address >= end_address)
626 handle->
debug_print(
"st7789: start_address >= end_address.\n");
633 handle->
debug_print(
"st7789: write command failed.\n");
637 buf[0] = (start_address >> 8) & 0xFF;
638 buf[1] = (start_address >> 0) & 0xFF;
639 buf[2] = (end_address >> 8) & 0xFF;
640 buf[3] = (end_address >> 0) & 0xFF;
641 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
643 handle->
debug_print(
"st7789: write data failed.\n");
676 handle->
debug_print(
"st7789: write command failed.\n");
680 if (a_st7789_write_bytes(handle, data, len,
ST7789_DATA) != 0)
682 handle->
debug_print(
"st7789: write data failed.\n");
717 handle->
debug_print(
"st7789: write command failed.\n");
721 buf[0] = (start_row >> 8) & 0xFF;
722 buf[1] = (start_row >> 0) & 0xFF;
723 buf[2] = (end_row >> 8) & 0xFF;
724 buf[3] = (end_row >> 0) & 0xFF;
725 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
727 handle->
debug_print(
"st7789: write data failed.\n");
749 uint16_t scrolling_area, uint16_t bottom_fixed_area)
764 handle->
debug_print(
"st7789: write command failed.\n");
768 buf[0] = (top_fixed_area >> 8) & 0xFF;
769 buf[1] = (top_fixed_area >> 0) & 0xFF;
770 buf[2] = (scrolling_area >> 8) & 0xFF;
771 buf[3] = (scrolling_area >> 0) & 0xFF;
772 buf[4] = (bottom_fixed_area >> 8) & 0xFF;
773 buf[5] = (bottom_fixed_area >> 0) & 0xFF;
774 if (a_st7789_write_bytes(handle, buf, 6,
ST7789_DATA) != 0)
776 handle->
debug_print(
"st7789: write data failed.\n");
807 handle->
debug_print(
"st7789: write command failed.\n");
839 handle->
debug_print(
"st7789: write command failed.\n");
843 if (a_st7789_write_byte(handle, effect,
ST7789_DATA) != 0)
845 handle->
debug_print(
"st7789: write data failed.\n");
877 handle->
debug_print(
"st7789: write command failed.\n");
881 if (a_st7789_write_byte(handle, order,
ST7789_DATA) != 0)
883 handle->
debug_print(
"st7789: write data failed.\n");
915 if (start_address > 319)
917 handle->
debug_print(
"st7789: address is invalid.\n");
924 handle->
debug_print(
"st7789: write command failed.\n");
928 buf[0] = (start_address >> 8) & 0xFF;
929 buf[1] = (start_address >> 0) & 0xFF;
930 if (a_st7789_write_bytes(handle, buf, 2,
ST7789_DATA) != 0)
932 handle->
debug_print(
"st7789: write data failed.\n");
963 handle->
debug_print(
"st7789: write command failed.\n");
994 handle->
debug_print(
"st7789: write command failed.\n");
1030 handle->
debug_print(
"st7789: write command failed.\n");
1035 data = (rgb << 4) | (control << 0);
1036 if (a_st7789_write_byte(handle, data,
ST7789_DATA) != 0)
1038 handle->
debug_print(
"st7789: write data failed.\n");
1072 handle->
debug_print(
"st7789: write command failed.\n");
1076 if (a_st7789_write_bytes(handle, data, len,
ST7789_DATA) != 0)
1078 handle->
debug_print(
"st7789: write data failed.\n");
1112 handle->
debug_print(
"st7789: write command failed.\n");
1116 buf[0] = (l >> 8) & 0xFF;
1117 buf[1] = (l >> 0) & 0xFF;
1118 if (a_st7789_write_bytes(handle, buf, 2,
ST7789_DATA) != 0)
1120 handle->
debug_print(
"st7789: write data failed.\n");
1152 handle->
debug_print(
"st7789: write command failed.\n");
1157 if (a_st7789_write_byte(handle, brightness,
ST7789_DATA) != 0)
1159 handle->
debug_print(
"st7789: write data failed.\n");
1196 handle->
debug_print(
"st7789: write command failed.\n");
1201 data = (brightness_control_block << 5) | (display_dimming << 3)
1202 | (backlight_control << 2);
1203 if (a_st7789_write_byte(handle, data,
ST7789_DATA) != 0)
1205 handle->
debug_print(
"st7789: write data failed.\n");
1242 handle->
debug_print(
"st7789: write command failed.\n");
1247 data = (color_enhancement << 7) | (level << 4) | (mode << 0);
1248 if (a_st7789_write_byte(handle, data,
ST7789_DATA) != 0)
1250 handle->
debug_print(
"st7789: write data failed.\n");
1282 handle->
debug_print(
"st7789: write command failed.\n");
1287 if (a_st7789_write_byte(handle, brightness,
ST7789_DATA) != 0)
1289 handle->
debug_print(
"st7789: write data failed.\n");
1334 handle->
debug_print(
"st7789: write command failed.\n");
1338 buf[0] = (ram_mode << 4) | (display_mode << 0);
1339 buf[1] = (frame_type << 4) | (data_mode << 3) |
1340 (bus_width << 2) | (pixel_type << 0);
1341 if (a_st7789_write_bytes(handle, buf, 2,
ST7789_DATA) != 0)
1343 handle->
debug_print(
"st7789: write data failed.\n");
1407 handle->
debug_print(
"st7789: write command failed.\n");
1411 buf[0] = (rgb_mode << 7) | (rgb_if_mode << 5) |
1412 (vspl << 3) | (hspl << 2) | (dpl << 1) | (epl << 0);
1413 buf[1] = vbp & 0x7F;
1414 buf[2] = hbp & 0x1F;
1415 if (a_st7789_write_bytes(handle, buf, 3,
ST7789_DATA) != 0)
1417 handle->
debug_print(
"st7789: write data failed.\n");
1454 uint8_t back_porch_normal,
1455 uint8_t front_porch_normal,
1457 uint8_t back_porch_idle,
1458 uint8_t front_porch_idle,
1459 uint8_t back_porch_partial,
1460 uint8_t front_porch_partial)
1472 if (back_porch_normal > 0x7F)
1474 handle->
debug_print(
"st7789: back_porch_normal > 0x7F.\n");
1478 if (front_porch_normal > 0x7F)
1480 handle->
debug_print(
"st7789: front_porch_normal > 0x7F.\n");
1484 if (back_porch_idle > 0xF)
1486 handle->
debug_print(
"st7789: back_porch_idle > 0xF.\n");
1490 if (front_porch_idle > 0xF)
1492 handle->
debug_print(
"st7789: front_porch_idle > 0xF.\n");
1496 if (back_porch_partial > 0xF)
1498 handle->
debug_print(
"st7789: back_porch_partial > 0xF.\n");
1502 if (front_porch_partial > 0xF)
1504 handle->
debug_print(
"st7789: front_porch_partial > 0xF.\n");
1511 handle->
debug_print(
"st7789: write command failed.\n");
1515 buf[0] = back_porch_normal;
1516 buf[1] = front_porch_normal;
1517 buf[2] = separate_porch_enable;
1518 buf[3] = (back_porch_idle & 0xF) << 4 | (front_porch_idle & 0xF);
1519 buf[4] = (back_porch_partial & 0xF) << 4 | (front_porch_partial & 0xF);
1520 if (a_st7789_write_bytes(handle, buf, 5,
ST7789_DATA) != 0)
1522 handle->
debug_print(
"st7789: write data failed.\n");
1553 uint8_t idle_frame_rate,
1555 uint8_t partial_frame_rate)
1567 if (idle_frame_rate > 0x1F)
1569 handle->
debug_print(
"st7789: idle_frame_rate > 0x1F.\n");
1573 if (partial_frame_rate > 0x1F)
1575 handle->
debug_print(
"st7789: partial_frame_rate > 0x1F.\n");
1582 handle->
debug_print(
"st7789: write command failed.\n");
1586 buf[0] = (separate_fr_control << 4) | (div_control << 0);
1587 buf[1] = (idle_mode << 5) | ((idle_frame_rate & 0x1F) << 0);
1588 buf[2] = (partial_mode << 5) | ((partial_frame_rate & 0x1F) << 0);
1589 if (a_st7789_write_bytes(handle, buf, 3,
ST7789_DATA) != 0)
1591 handle->
debug_print(
"st7789: write data failed.\n");
1630 handle->
debug_print(
"st7789: write command failed.\n");
1634 reg = (level << 7) | (mode << 4) | (frequency << 0);
1635 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
1637 handle->
debug_print(
"st7789: write data failed.\n");
1672 handle->
debug_print(
"st7789: write command failed.\n");
1676 reg = (vghs << 4) | (vgls << 0);
1677 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
1679 handle->
debug_print(
"st7789: write data failed.\n");
1703 uint8_t gate_on_timing_adjustment,
1704 uint8_t gate_off_timing_adjustment_rgb,
1705 uint8_t gate_off_timing_adjustment)
1717 if (gate_on_timing_adjustment > 0x3F)
1719 handle->
debug_print(
"st7789: gate_on_timing_adjustment > 0x3F.\n");
1723 if (gate_off_timing_adjustment_rgb > 0xF)
1725 handle->
debug_print(
"st7789: gate_off_timing_adjustment_rgb > 0xF.\n");
1729 if (gate_off_timing_adjustment > 0xF)
1731 handle->
debug_print(
"st7789: gate_off_timing_adjustment > 0xF.\n");
1738 handle->
debug_print(
"st7789: write command failed.\n");
1744 buf[2] = gate_on_timing_adjustment & 0x3F;
1745 buf[3] = ((gate_off_timing_adjustment_rgb & 0xF) << 4) |
1746 ((gate_off_timing_adjustment & 0xF) << 0);
1747 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
1749 handle->
debug_print(
"st7789: write data failed.\n");
1783 handle->
debug_print(
"st7789: write command failed.\n");
1788 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
1790 handle->
debug_print(
"st7789: write data failed.\n");
1831 handle->
debug_print(
"st7789: write command failed.\n");
1836 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
1838 handle->
debug_print(
"st7789: write data failed.\n");
1868 *reg = (uint8_t)((v - 0.1f) / 0.025f);
1895 *v = (uint8_t)((
float)(reg) * 0.025f + 0.1f);
1939 handle->
debug_print(
"st7789: write command failed.\n");
1943 reg = (xmy << 6) | (xbgr << 5) | (xinv << 4) | (xmx << 3) |
1944 (xmh << 2) | (xmv << 1) | (xgs << 0);
1945 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
1947 handle->
debug_print(
"st7789: write data failed.\n");
1979 handle->
debug_print(
"st7789: write command failed.\n");
1983 if (a_st7789_write_bytes(handle,
id, 3,
ST7789_DATA) != 0)
1985 handle->
debug_print(
"st7789: write data failed.\n");
2019 handle->
debug_print(
"st7789: write command failed.\n");
2025 if (a_st7789_write_bytes(handle, buf, 2,
ST7789_DATA) != 0)
2027 handle->
debug_print(
"st7789: write data failed.\n");
2068 handle->
debug_print(
"st7789: write command failed.\n");
2073 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
2075 handle->
debug_print(
"st7789: write data failed.\n");
2105 *reg = (uint8_t)((v - 3.55f) / 0.05f);
2132 *v = (uint8_t)((
float)(reg) * 0.05f + 3.55f);
2170 handle->
debug_print(
"st7789: write command failed.\n");
2175 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
2177 handle->
debug_print(
"st7789: write data failed.\n");
2207 *reg = (uint8_t)((v + 0.8f) / 0.025f);
2234 *v = (uint8_t)((
float)(reg) * 0.025f - 0.8f);
2272 handle->
debug_print(
"st7789: write command failed.\n");
2276 reg = offset & 0x3F;
2277 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
2279 handle->
debug_print(
"st7789: write data failed.\n");
2309 *reg = (uint8_t)((v + 0.8f) / 0.025f);
2336 *v = (uint8_t)((
float)(reg) * 0.025f - 0.8f);
2368 handle->
debug_print(
"st7789: write command failed.\n");
2372 reg = (selection << 5) | (rate << 0);
2373 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
2375 handle->
debug_print(
"st7789: write data failed.\n");
2416 handle->
debug_print(
"st7789: write command failed.\n");
2420 reg = (led_on << 3) | (led_pwm_init << 2) |
2421 (led_pwm_fix << 1) | (led_pwm_polarity << 0);
2422 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
2424 handle->
debug_print(
"st7789: write data failed.\n");
2458 handle->
debug_print(
"st7789: write command failed.\n");
2463 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
2465 handle->
debug_print(
"st7789: write data failed.\n");
2501 handle->
debug_print(
"st7789: write command failed.\n");
2506 buf[1] = (avdd << 6) | (avcl << 4) | (vds << 0);
2507 if (a_st7789_write_bytes(handle, buf, 2,
ST7789_DATA) != 0)
2509 handle->
debug_print(
"st7789: write data failed.\n");
2542 handle->
debug_print(
"st7789: write command failed.\n");
2547 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
2549 handle->
debug_print(
"st7789: write data failed.\n");
2583 handle->
debug_print(
"st7789: write command failed.\n");
2591 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
2593 handle->
debug_print(
"st7789: write data failed.\n");
2625 handle->
debug_print(
"st7789: write command failed.\n");
2629 if (a_st7789_write_bytes(handle, param, 14,
ST7789_DATA) != 0)
2631 handle->
debug_print(
"st7789: write data failed.\n");
2663 handle->
debug_print(
"st7789: write command failed.\n");
2667 if (a_st7789_write_bytes(handle, param, 14,
ST7789_DATA) != 0)
2669 handle->
debug_print(
"st7789: write data failed.\n");
2701 handle->
debug_print(
"st7789: write command failed.\n");
2705 if (a_st7789_write_bytes(handle, param, 64,
ST7789_DATA) != 0)
2707 handle->
debug_print(
"st7789: write data failed.\n");
2739 handle->
debug_print(
"st7789: write command failed.\n");
2743 if (a_st7789_write_bytes(handle, param, 64,
ST7789_DATA) != 0)
2745 handle->
debug_print(
"st7789: write data failed.\n");
2771 uint8_t gate_line_number,
2772 uint8_t first_scan_line_number,
2786 if (gate_line_number > 0x3F)
2788 handle->
debug_print(
"st7789: gate_line_number > 0x3F.\n");
2792 if (first_scan_line_number > 0x3F)
2794 handle->
debug_print(
"st7789: first_scan_line_number > 0x3F.\n");
2801 handle->
debug_print(
"st7789: write command failed.\n");
2805 buf[0] = gate_line_number;
2806 buf[1] = first_scan_line_number;
2807 buf[2] = 0x10 | (mode << 2) | (direction << 0);
2808 if (a_st7789_write_bytes(handle, buf, 3,
ST7789_DATA) != 0)
2810 handle->
debug_print(
"st7789: write data failed.\n");
2840 *reg = (uint8_t)((l / 8) - 1);
2867 *l = (uint8_t)(reg * 8 + 8);
2899 handle->
debug_print(
"st7789: write command failed.\n");
2903 reg = (date_lane << 4) | (command_table_2 << 0);
2904 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
2906 handle->
debug_print(
"st7789: write data failed.\n");
2941 handle->
debug_print(
"st7789: write command failed.\n");
2945 reg = (sbclk << 4) | (stp14ck << 0);
2946 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
2948 handle->
debug_print(
"st7789: write data failed.\n");
2973 uint8_t source_equalize_time,
2974 uint8_t source_pre_drive_time,
2975 uint8_t gate_equalize_time)
2987 if (source_equalize_time > 0x1F)
2989 handle->
debug_print(
"st7789: source_equalize_time > 0x1F.\n");
2993 if (source_pre_drive_time > 0x1F)
2995 handle->
debug_print(
"st7789: source_pre_drive_time > 0x1F.\n");
2999 if (gate_equalize_time > 0xF)
3001 handle->
debug_print(
"st7789: gate_equalize_time > 0xF.\n");
3008 handle->
debug_print(
"st7789: write command failed.\n");
3012 buf[0] = source_equalize_time;
3013 buf[1] = source_pre_drive_time;
3014 buf[2] = gate_equalize_time;
3015 if (a_st7789_write_bytes(handle, buf, 3,
ST7789_DATA) != 0)
3017 handle->
debug_print(
"st7789: write data failed.\n");
3050 handle->
debug_print(
"st7789: write command failed.\n");
3055 if (a_st7789_write_byte(handle, reg,
ST7789_DATA) != 0)
3057 handle->
debug_print(
"st7789: write data failed.\n");
3091 handle->
debug_print(
"st7789: write command failed.\n");
3098 buf[3] = enable << 2;
3099 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
3101 handle->
debug_print(
"st7789: write data failed.\n");
3136 handle->
debug_print(
"st7789: write command failed.\n");
3142 if (a_st7789_write_bytes(handle, buf, 2,
ST7789_DATA) != 0)
3144 handle->
debug_print(
"st7789: write data failed.\n");
3177 handle->
debug_print(
"st7789: write command failed.\n");
3183 if (a_st7789_write_bytes(handle, buf, 2,
ST7789_DATA) != 0)
3185 handle->
debug_print(
"st7789: write data failed.\n");
3217 handle->
debug_print(
"st7789: spi_init is null.\n");
3223 handle->
debug_print(
"st7789: spi_deinit is null.\n");
3229 handle->
debug_print(
"st7789: spi_write_cmd is null.\n");
3235 handle->
debug_print(
"st7789: cmd_data_gpio_init is null.\n");
3241 handle->
debug_print(
"st7789: cmd_data_gpio_deinit is null.\n");
3247 handle->
debug_print(
"st7789: cmd_data_gpio_write is null.\n");
3253 handle->
debug_print(
"st7789: reset_gpio_init is null.\n");
3259 handle->
debug_print(
"st7789: reset_gpio_deinit is null.\n");
3265 handle->
debug_print(
"st7789: reset_gpio_write is null.\n");
3271 handle->
debug_print(
"st7789: delay_ms is null.\n");
3278 handle->
debug_print(
"st7789: cmd data gpio init failed.\n");
3284 handle->
debug_print(
"st7789: reset gpio init failed.\n");
3291 handle->
debug_print(
"st7789: reset gpio write failed.\n");
3300 handle->
debug_print(
"st7789: reset gpio write failed.\n");
3309 handle->
debug_print(
"st7789: spi init failed.\n");
3346 handle->
debug_print(
"st7789: write command failed.\n");
3352 handle->
debug_print(
"st7789: reset gpio deinit failed.\n");
3358 handle->
debug_print(
"st7789: cmd data gpio deinit failed.\n");
3364 handle->
debug_print(
"st7789: spi deinit failed.\n");
3468 handle->
debug_print(
"st7789: write command failed.\n");
3472 buf[0] = (0x00 >> 8) & 0xFF;
3473 buf[1] = (0x00 >> 0) & 0xFF;
3474 buf[2] = ((handle->
column - 1) >> 8) & 0xFF;
3475 buf[3] = ((handle->
column - 1) >> 0) & 0xFF;
3476 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
3478 handle->
debug_print(
"st7789: write data failed.\n");
3485 handle->
debug_print(
"st7789: write command failed.\n");
3489 buf[0] = (0x00 >> 8) & 0xFF;
3490 buf[1] = (0x00 >> 0) & 0xFF;
3491 buf[2] = ((handle->
row - 1) >> 8) & 0xFF;
3492 buf[3] = ((handle->
row - 1) >> 0) & 0xFF;
3493 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
3495 handle->
debug_print(
"st7789: write data failed.\n");
3502 handle->
debug_print(
"st7789: write command failed.\n");
3507 if ((handle->
format & 0x03) == 0x03)
3510 m = ((uint32_t)(handle->
row) * handle->
column * 3 / 2) /
3512 n = ((uint32_t)(handle->
row) * handle->
column * 3 / 2) %
3514 for (i = 0; i < m; i++)
3516 if (a_st7789_write_bytes(handle, handle->
buf,
3519 handle->
debug_print(
"st7789: write data failed.\n");
3526 if (a_st7789_write_bytes(handle, handle->
buf, n,
ST7789_DATA) != 0)
3528 handle->
debug_print(
"st7789: write data failed.\n");
3534 else if ((handle->
format & 0x05) == 0x05)
3539 for (i = 0; i < m; i++)
3541 if (a_st7789_write_bytes(handle, handle->
buf,
3544 handle->
debug_print(
"st7789: write data failed.\n");
3551 if (a_st7789_write_bytes(handle, handle->
buf, n,
ST7789_DATA) != 0)
3553 handle->
debug_print(
"st7789: write data failed.\n");
3559 else if ((handle->
format & 0x06) == 0x06)
3564 for (i = 0; i < m; i++)
3566 if (a_st7789_write_bytes(handle, handle->
buf,
3569 handle->
debug_print(
"st7789: write data failed.\n");
3576 if (a_st7789_write_bytes(handle, handle->
buf, n,
ST7789_DATA) != 0)
3578 handle->
debug_print(
"st7789: write data failed.\n");
3586 handle->
debug_print(
"st7789: format is invalid.\n");
3630 if (left > (handle->
column - 1))
3632 handle->
debug_print(
"st7789: left is over column.\n");
3636 if (right > (handle->
column - 1))
3638 handle->
debug_print(
"st7789: right is over column.\n");
3648 if (top > (handle->
row - 1))
3650 handle->
debug_print(
"st7789: top is over row.\n");
3654 if (bottom > (handle->
row - 1))
3656 handle->
debug_print(
"st7789: bottom is over row.\n");
3669 handle->
debug_print(
"st7789: write command failed.\n");
3673 buf[0] = (left >> 8) & 0xFF;
3674 buf[1] = (left >> 0) & 0xFF;
3675 buf[2] = ((right) >> 8) & 0xFF;
3676 buf[3] = ((right) >> 0) & 0xFF;
3677 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
3679 handle->
debug_print(
"st7789: write data failed.\n");
3686 handle->
debug_print(
"st7789: write command failed.\n");
3690 buf[0] = (top >> 8) & 0xFF;
3691 buf[1] = (top >> 0) & 0xFF;
3692 buf[2] = ((bottom) >> 8) & 0xFF;
3693 buf[3] = ((bottom) >> 0) & 0xFF;
3694 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
3696 handle->
debug_print(
"st7789: write data failed.\n");
3703 handle->
debug_print(
"st7789: write command failed.\n");
3708 if ((handle->
format & 0x03) == 0x03)
3712 handle->
buf[i] = (((color >> 8) & 0xF) << 4) |
3713 (((color >> 4) & 0xF) << 0);
3714 handle->
buf[i + 1] = (((color >> 0) & 0xF) << 4) |
3715 (((color >> 8) & 0xF) << 0);
3716 handle->
buf[i + 2] = (((color >> 4) & 0xF) << 4) |
3717 (((color >> 0) & 0xF) << 0);
3719 m = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 3 / 2) /
3721 n = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 3 / 2) %
3723 for (i = 0; i < m; i++)
3725 if (a_st7789_write_bytes(handle, handle->
buf,
3728 handle->
debug_print(
"st7789: write data failed.\n");
3735 if (a_st7789_write_bytes(handle, handle->
buf, n,
ST7789_DATA) != 0)
3737 handle->
debug_print(
"st7789: write data failed.\n");
3743 else if ((handle->
format & 0x05) == 0x05)
3747 handle->
buf[i] = (color >> 8) & 0xFF;
3748 handle->
buf[i + 1] = (color >> 0) & 0xFF;
3750 m = (uint32_t)(right - left + 1) * (bottom - top + 1) * 2 /
3752 n = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 2) %
3754 for (i = 0; i < m; i++)
3756 if (a_st7789_write_bytes(handle, handle->
buf,
3759 handle->
debug_print(
"st7789: write data failed.\n");
3766 if (a_st7789_write_bytes(handle, handle->
buf, n,
ST7789_DATA) != 0)
3768 handle->
debug_print(
"st7789: write data failed.\n");
3774 else if ((handle->
format & 0x06) == 0x06)
3778 handle->
buf[i] = ((color >> 12) & 0x3F) << 2;
3779 handle->
buf[i + 1] = ((color >> 6) & 0x3F) << 2;
3780 handle->
buf[i + 2] = ((color >> 0) & 0x3F) << 2;
3782 m = (uint32_t)(right - left + 1) * (bottom - top + 1) * 3 /
3784 n = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 3) %
3786 for (i = 0; i < m; i++)
3788 if (a_st7789_write_bytes(handle, handle->
buf,
3791 handle->
debug_print(
"st7789: write data failed.\n");
3798 if (a_st7789_write_bytes(handle, handle->
buf, n,
ST7789_DATA) != 0)
3800 handle->
debug_print(
"st7789: write data failed.\n");
3808 handle->
debug_print(
"st7789: format is invalid.\n");
3854 if (left > (handle->
column - 1))
3856 handle->
debug_print(
"st7789: left is over column.\n");
3860 if (right > (handle->
column - 1))
3862 handle->
debug_print(
"st7789: right is over column.\n");
3872 if (top > (handle->
row - 1))
3874 handle->
debug_print(
"st7789: top is over row.\n");
3878 if (bottom > (handle->
row - 1))
3880 handle->
debug_print(
"st7789: bottom is over row.\n");
3893 handle->
debug_print(
"st7789: write command failed.\n");
3897 buf[0] = (left >> 8) & 0xFF;
3898 buf[1] = (left >> 0) & 0xFF;
3899 buf[2] = ((right) >> 8) & 0xFF;
3900 buf[3] = ((right) >> 0) & 0xFF;
3901 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
3903 handle->
debug_print(
"st7789: write data failed.\n");
3910 handle->
debug_print(
"st7789: write command failed.\n");
3914 buf[0] = (top >> 8) & 0xFF;
3915 buf[1] = (top >> 0) & 0xFF;
3916 buf[2] = ((bottom) >> 8) & 0xFF;
3917 buf[3] = ((bottom) >> 0) & 0xFF;
3918 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
3920 handle->
debug_print(
"st7789: write data failed.\n");
3927 handle->
debug_print(
"st7789: write command failed.\n");
3932 if ((handle->
format & 0x03) == 0x03)
3938 c = right - left + 1;
3939 r = bottom - top + 1;
3941 m = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 3 / 2) /
3943 n = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 3 / 2) %
3945 for (i = 0; i < m; i++)
3949 color = image[(point % c) * r + (point / c)];
3950 handle->
buf[i] = (((color >> 8) & 0xF) << 4) |
3951 (((color >> 4) & 0xF) << 0);
3952 handle->
buf[i + 1] = (((color >> 0) & 0xF) << 4) |
3953 (((color >> 8) & 0xF) << 0);
3954 handle->
buf[i + 2] = (((color >> 4) & 0xF) << 4) |
3955 (((color >> 0) & 0xF) << 0);
3958 if (a_st7789_write_bytes(handle, handle->
buf,
3961 handle->
debug_print(
"st7789: write data failed.\n");
3968 for (j = 0; j < n; j += 3)
3970 color = image[(point % c) * r + (point / c)];
3971 handle->
buf[i] = (((color >> 8) & 0xF) << 4) |
3972 (((color >> 4) & 0xF) << 0);
3973 handle->
buf[i + 1] = (((color >> 0) & 0xF) << 4) |
3974 (((color >> 8) & 0xF) << 0);
3975 handle->
buf[i + 2] = (((color >> 4) & 0xF) << 4) |
3976 (((color >> 0) & 0xF) << 0);
3979 if (a_st7789_write_bytes(handle, handle->
buf, n,
ST7789_DATA) != 0)
3981 handle->
debug_print(
"st7789: write data failed.\n");
3989 handle->
debug_print(
"st7789: format is invalid.\n");
4035 if (left > (handle->
column - 1))
4037 handle->
debug_print(
"st7789: left is over column.\n");
4041 if (right > (handle->
column - 1))
4043 handle->
debug_print(
"st7789: right is over column.\n");
4053 if (top > (handle->
row - 1))
4055 handle->
debug_print(
"st7789: top is over row.\n");
4059 if (bottom > (handle->
row - 1))
4061 handle->
debug_print(
"st7789: bottom is over row.\n");
4074 handle->
debug_print(
"st7789: write command failed.\n");
4078 buf[0] = (left >> 8) & 0xFF;
4079 buf[1] = (left >> 0) & 0xFF;
4080 buf[2] = ((right) >> 8) & 0xFF;
4081 buf[3] = ((right) >> 0) & 0xFF;
4082 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
4084 handle->
debug_print(
"st7789: write data failed.\n");
4091 handle->
debug_print(
"st7789: write command failed.\n");
4095 buf[0] = (top >> 8) & 0xFF;
4096 buf[1] = (top >> 0) & 0xFF;
4097 buf[2] = ((bottom) >> 8) & 0xFF;
4098 buf[3] = ((bottom) >> 0) & 0xFF;
4099 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
4101 handle->
debug_print(
"st7789: write data failed.\n");
4108 handle->
debug_print(
"st7789: write command failed.\n");
4113 if ((handle->
format & 0x05) == 0x05)
4119 c = right - left + 1;
4120 r = bottom - top + 1;
4122 m = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 2) /
4124 n = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 2) %
4126 for (i = 0; i < m; i++)
4130 color = image[(point % c) * r + (point / c)];
4131 handle->
buf[j] = (color >> 8) & 0xFF;
4132 handle->
buf[j + 1] = (color >> 0) & 0xFF;
4135 if (a_st7789_write_bytes(handle, handle->
buf,
4138 handle->
debug_print(
"st7789: write data failed.\n");
4145 for (j = 0; j < n; j += 2)
4147 color = image[(point % c) * r + (point / c)];
4148 handle->
buf[j] = (color >> 8) & 0xFF;
4149 handle->
buf[j + 1] = (color >> 0) & 0xFF;
4152 if (a_st7789_write_bytes(handle, handle->
buf, n,
ST7789_DATA) != 0)
4154 handle->
debug_print(
"st7789: write data failed.\n");
4162 handle->
debug_print(
"st7789: format is invalid.\n");
4208 if (left > (handle->
column - 1))
4210 handle->
debug_print(
"st7789: left is over column.\n");
4214 if (right > (handle->
column - 1))
4216 handle->
debug_print(
"st7789: right is over column.\n");
4226 if (top > (handle->
row - 1))
4228 handle->
debug_print(
"st7789: top is over row.\n");
4232 if (bottom > (handle->
row - 1))
4234 handle->
debug_print(
"st7789: bottom is over row.\n");
4247 handle->
debug_print(
"st7789: write command failed.\n");
4251 buf[0] = (left >> 8) & 0xFF;
4252 buf[1] = (left >> 0) & 0xFF;
4253 buf[2] = ((right) >> 8) & 0xFF;
4254 buf[3] = ((right) >> 0) & 0xFF;
4255 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
4257 handle->
debug_print(
"st7789: write data failed.\n");
4264 handle->
debug_print(
"st7789: write command failed.\n");
4268 buf[0] = (top >> 8) & 0xFF;
4269 buf[1] = (top >> 0) & 0xFF;
4270 buf[2] = ((bottom) >> 8) & 0xFF;
4271 buf[3] = ((bottom) >> 0) & 0xFF;
4272 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
4274 handle->
debug_print(
"st7789: write data failed.\n");
4281 handle->
debug_print(
"st7789: write command failed.\n");
4286 if ((handle->
format & 0x06) == 0x06)
4292 c = right - left + 1;
4293 r = bottom - top + 1;
4295 m = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 3) /
4297 n = ((uint32_t)(right - left + 1) * (bottom - top + 1) * 3) %
4299 for (i = 0; i < m; i++)
4303 color = image[(point % c) * r + (point / c)];
4304 handle->
buf[j] = ((color >> 12) & 0x3F) << 2;
4305 handle->
buf[j + 1] = ((color >> 6) & 0x3F) << 2;
4306 handle->
buf[j + 2] = ((color >> 0) & 0x3F) << 2;
4309 if (a_st7789_write_bytes(handle, handle->
buf,
4312 handle->
debug_print(
"st7789: write data failed.\n");
4319 for (j = 0; j < n; j += 3)
4321 color = image[(point % c) * r + (point / c)];
4322 handle->
buf[j] = ((color >> 12) & 0x3F) << 2;
4323 handle->
buf[j + 1] = ((color >> 6) & 0x3F) << 2;
4324 handle->
buf[j + 2] = ((color >> 0) & 0x3F) << 2;
4327 if (a_st7789_write_bytes(handle, handle->
buf, n,
ST7789_DATA) != 0)
4329 handle->
debug_print(
"st7789: write data failed.\n");
4337 handle->
debug_print(
"st7789: format is invalid.\n");
4356static uint8_t a_st7789_draw_point(
st7789_handle_t *handle, uint16_t x, uint16_t y, uint32_t color)
4362 handle->
debug_print(
"st7789: write command failed.\n");
4366 buf[0] = (x >> 8) & 0xFF;
4367 buf[1] = (x >> 0) & 0xFF;
4368 buf[2] = (x >> 8) & 0xFF;
4369 buf[3] = (x >> 0) & 0xFF;
4370 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
4372 handle->
debug_print(
"st7789: write data failed.\n");
4379 handle->
debug_print(
"st7789: write command failed.\n");
4383 buf[0] = (y >> 8) & 0xFF;
4384 buf[1] = (y >> 0) & 0xFF;
4385 buf[2] = (y >> 8) & 0xFF;
4386 buf[3] = (y >> 0) & 0xFF;
4387 if (a_st7789_write_bytes(handle, buf, 4,
ST7789_DATA) != 0)
4389 handle->
debug_print(
"st7789: write data failed.\n");
4396 handle->
debug_print(
"st7789: write command failed.\n");
4401 if ((handle->
format & 0x03) == 0x03)
4403 handle->
buf[0] = (((color >> 8) & 0xF) << 4) |
4404 (((color >> 4) & 0xF) << 0);
4405 handle->
buf[1] = (((color >> 0) & 0xF) << 4);
4406 if (a_st7789_write_bytes(handle, handle->
buf,
4409 handle->
debug_print(
"st7789: write data failed.\n");
4414 else if ((handle->
format & 0x05) == 0x05)
4416 handle->
buf[0] = (color >> 8) & 0xFF;
4417 handle->
buf[1] = (color >> 0) & 0xFF;
4418 if (a_st7789_write_bytes(handle, handle->
buf,
4421 handle->
debug_print(
"st7789: write data failed.\n");
4426 else if ((handle->
format & 0x06) == 0x06)
4428 handle->
buf[0] = ((color >> 12) & 0x3F) << 2;
4429 handle->
buf[1] = ((color >> 6) & 0x3F) << 2;
4430 handle->
buf[2] = ((color >> 0) & 0x3F) << 2;
4431 if (a_st7789_write_bytes(handle, handle->
buf,
4434 handle->
debug_print(
"st7789: write data failed.\n");
4441 handle->
debug_print(
"st7789: format is invalid.\n");
4462static uint8_t a_st7789_show_char(
st7789_handle_t *handle, uint16_t x, uint16_t y, uint8_t chr, uint8_t size, uint32_t color)
4464 uint8_t temp, t, t1;
4466 uint8_t csize = (size / 8 + ((size % 8) ? 1 : 0)) * (size / 2);
4469 for (t = 0; t < csize; t++)
4473 temp = gsc_st7789_ascii_1206[chr][t];
4475 else if (size == 16)
4477 temp = gsc_st7789_ascii_1608[chr][t];
4481 temp = gsc_st7789_ascii_2412[chr][t];
4487 for (t1 = 0; t1 < 8; t1++)
4489 if ((temp & 0x80) != 0)
4491 if (a_st7789_draw_point(handle, x, y, color) != 0)
4498 if ((y - y0) == size)
4538 if((x >= handle->
column) || (y >= handle->
row))
4540 handle->
debug_print(
"ssd1351: x or y is invalid.\n");
4545 while ((len != 0) && (*str <=
'~') && (*str >=
' '))
4547 if (x >= (handle->
column - (font / 2)))
4552 if (y >= (handle->
row - font))
4556 if (a_st7789_show_char(handle, x, y, *str, font, color) != 0)
4560 x += (uint8_t)(font / 2);
4595 handle->
debug_print(
"ssd1351: x is over column.\n");
4599 if (y >= handle->
row)
4606 return a_st7789_draw_point(handle, x, y, color);
4631 return a_st7789_write_byte(handle, cmd,
ST7789_CMD);
4656 return a_st7789_write_byte(handle, data,
ST7789_DATA);
#define ST7789_CMD_GAMSET
#define ST7789_CMD_RGBCTRL
#define ST7789_CMD_PORCTRL
#define ST7789_CMD_DISPON
#define ST7789_CMD_IDMOFF
#define ST7789_CMD_PVGAMCTRL
#define ST7789_CMD_WRCABCMB
#define ST7789_CMD_COLMOD
#define ST7789_CMD_EQCTRL
#define ST7789_CMD_PROMCTRL
#define SUPPLY_VOLTAGE_MAX
#define ST7789_CMD_PROMEN
#define ST7789_CMD_WRDISBV
#define ST7789_CMD_CMD2EN
#define ST7789_CMD_WRCACE
#define ST7789_CMD_WRCTRLD
#define ST7789_CMD_GATECTRL
#define ST7789_CMD_PWMFRSEL
#define ST7789_CMD_SWRESET
#define ST7789_CMD_PWCTRL2
#define ST7789_CMD_RAMWRC
#define ST7789_CMD_PARCTRL
#define ST7789_CMD_VSCRSADD
#define ST7789_CMD_VSCRDEF
#define ST7789_CMD_VDVVRHEN
#define ST7789_CMD_DGMLUTR
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define ST7789_CMD_MADCTL
#define ST7789_CMD_NVGAMCTRL
#define ST7789_CMD_PROMACT
#define ST7789_CMD_NOP
chip command definition
#define ST7789_CMD_RAMCTRL
#define ST7789_CMD_FRCTR2
#define ST7789_CMD_LCMCTRL
#define ST7789_CMD_SLPOUT
#define ST7789_CMD_PWCTRL1
#define ST7789_CMD_VAPVANEN
#define ST7789_CMD_VCMOFSET
#define ST7789_CMD
command data type definition
#define ST7789_CMD_INVOFF
#define ST7789_CMD_DGMLUTB
#define ST7789_CMD_SPI2EN
#define ST7789_CMD_NVMSET
#define CHIP_NAME
chip information definition
#define ST7789_CMD_CABCCTRL
#define ST7789_CMD_DISPOFF
#define ST7789_CMD_VDVSET
#define ST7789_CMD_FRCTRL1
#define ST7789_CMD_TESCAN
driver st7789 header file
driver st7789 font header file
st7789_frame_rate_t
st7789 frame rate enumeration definition
st7789_vds_t
st7789 vds enumeration definition
uint8_t st7789_set_id_code_setting(st7789_handle_t *handle, uint8_t id[3])
set id code setting
uint8_t st7789_vrhs_convert_to_register(st7789_handle_t *handle, float v, uint8_t *reg)
convert the vrhs to the register raw data
st7789_rgb_bus_width_t
st7789 rgb bus width enumeration definition
uint8_t st7789_gate_line_convert_to_data(st7789_handle_t *handle, uint8_t reg, uint16_t *l)
convert the register raw data to the gate line
st7789_avdd_t
st7789 avdd enumeration definition
uint8_t st7789_enable_vap_van_signal_output(st7789_handle_t *handle)
enable vap van signal output
uint8_t st7789_set_program_action(st7789_handle_t *handle)
set program action
uint8_t st7789_set_gate_on_timing_adjustment(st7789_handle_t *handle, uint8_t gate_on_timing_adjustment, uint8_t gate_off_timing_adjustment_rgb, uint8_t gate_off_timing_adjustment)
set gate on timing adjustment
st7789_stp14ck_div_t
st7789 stp14ck div enumeration definition
st7789_vdv_vrh_from_t
st7789 vdv vrh from enumeration definition
uint8_t st7789_set_nvm_setting(st7789_handle_t *handle, uint8_t addr, uint8_t data)
set nvm setting
st7789_frame_rate_divided_control_t
st7789 frame rate divided control enumeration definition
st7789_pixel_type_t
st7789 pixel type enumeration definition
uint8_t st7789_vcoms_offset_convert_to_data(st7789_handle_t *handle, uint8_t reg, float *v)
convert the register raw data to the vcoms offset
uint8_t st7789_vdv_convert_to_register(st7789_handle_t *handle, float v, uint8_t *reg)
convert the vdv to the register raw data
uint8_t st7789_set_vcoms_offset(st7789_handle_t *handle, uint8_t offset)
set vcoms offset
uint8_t st7789_set_rgb_interface_control(st7789_handle_t *handle, st7789_direct_rgb_mode_t rgb_mode, st7789_rgb_if_enable_mode_t rgb_if_mode, st7789_pin_level_t vspl, st7789_pin_level_t hspl, st7789_pin_level_t dpl, st7789_pin_level_t epl, uint8_t vbp, uint8_t hbp)
set rgb interface control
uint8_t st7789_set_program_mode_enable(st7789_handle_t *handle, st7789_bool_t enable)
enable or disable program mode
uint8_t st7789_vcom_convert_to_data(st7789_handle_t *handle, uint8_t reg, float *v)
convert the register raw data to the vcom
uint8_t st7789_set_command_2_enable(st7789_handle_t *handle, st7789_bool_t enable)
enable or disable command 2
st7789_inversion_selection_t
st7789 inversion selection enumeration definition
uint8_t st7789_set_equalize_time_control(st7789_handle_t *handle, uint8_t source_equalize_time, uint8_t source_pre_drive_time, uint8_t gate_equalize_time)
set equalize time control
st7789_pin_level_t
st7789 pin level enumeration definition
st7789_vgls_t
st7789 vgls enumeration definition
st7789_inversion_partial_mode_t
st7789 inversion partial mode enumeration definition
st7789_non_display_frame_frequency_t
st7789 non display frame frequency enumeration definition
uint8_t st7789_set_positive_voltage_gamma_control(st7789_handle_t *handle, uint8_t param[14])
set positive voltage gamma control
st7789_avcl_t
st7789 avcl enumeration definition
uint8_t st7789_set_program_mode_control(st7789_handle_t *handle)
set program mode control
st7789_pwm_frequency_t
st7789 pwm frequency enumeration definition
uint8_t st7789_set_vdv_vrh_from(st7789_handle_t *handle, st7789_vdv_vrh_from_t from)
set vdv vrh from
uint8_t st7789_set_vcoms(st7789_handle_t *handle, uint8_t vcoms)
set vcoms
uint8_t st7789_set_digital_gamma(st7789_handle_t *handle, st7789_bool_t enable)
enable or disable digital gamma
st7789_sbclk_div_t
st7789 sbclk div enumeration definition
uint8_t st7789_set_frame_rate(st7789_handle_t *handle, st7789_inversion_selection_t selection, st7789_frame_rate_t rate)
set frame rate
uint8_t st7789_set_negative_voltage_gamma_control(st7789_handle_t *handle, uint8_t param[14])
set negative voltage gamma control
uint8_t st7789_set_lcm_control(st7789_handle_t *handle, st7789_bool_t xmy, st7789_bool_t xbgr, st7789_bool_t xinv, st7789_bool_t xmx, st7789_bool_t xmh, st7789_bool_t xmv, st7789_bool_t xgs)
set lcm control
uint8_t st7789_set_power_control_1(st7789_handle_t *handle, st7789_avdd_t avdd, st7789_avcl_t avcl, st7789_vds_t vds)
set power control 1
uint8_t st7789_vrhs_convert_to_data(st7789_handle_t *handle, uint8_t reg, float *v)
convert the register raw data to the vrhs
st7789_frame_type_t
st7789 frame type enumeration definition
uint8_t st7789_set_frame_rate_control(st7789_handle_t *handle, st7789_bool_t separate_fr_control, st7789_frame_rate_divided_control_t div_control, st7789_inversion_idle_mode_t idle_mode, uint8_t idle_frame_rate, st7789_inversion_partial_mode_t partial_mode, uint8_t partial_frame_rate)
set frame rate control
st7789_vghs_t
st7789 vghs enumeration definition
st7789_non_display_source_output_level_t
st7789 non display source output level enumeration definition
st7789_data_mode_t
st7789 data mode enumeration definition
uint8_t st7789_set_ram_control(st7789_handle_t *handle, st7789_ram_access_t ram_mode, st7789_display_mode_t display_mode, st7789_frame_type_t frame_type, st7789_data_mode_t data_mode, st7789_rgb_bus_width_t bus_width, st7789_pixel_type_t pixel_type)
set ram control
uint8_t st7789_vcoms_offset_convert_to_register(st7789_handle_t *handle, float v, uint8_t *reg)
convert the vcoms offset to the register raw data
uint8_t st7789_set_gate(st7789_handle_t *handle, uint8_t gate_line_number, uint8_t first_scan_line_number, st7789_gate_scan_mode_t mode, st7789_gate_scan_direction_t direction)
set gate
st7789_inversion_idle_mode_t
st7789 inversion idle mode enumeration definition
uint8_t st7789_set_gate_control(st7789_handle_t *handle, st7789_vghs_t vghs, st7789_vgls_t vgls)
set gate control
uint8_t st7789_set_cabc_control(st7789_handle_t *handle, st7789_bool_t led_on, st7789_bool_t led_pwm_init, st7789_bool_t led_pwm_fix, st7789_bool_t led_pwm_polarity)
set cabc control
st7789_direct_rgb_mode_t
st7789 direct rgb mode enumeration definition
uint8_t st7789_set_partial_mode_control(st7789_handle_t *handle, st7789_non_display_source_output_level_t level, st7789_non_display_area_scan_mode_t mode, st7789_non_display_frame_frequency_t frequency)
set partial mode control
uint8_t st7789_vdv_convert_to_data(st7789_handle_t *handle, uint8_t reg, float *v)
convert the register raw data to the vdv
st7789_non_display_area_scan_mode_t
st7789 non display area scan mode enumeration definition
st7789_rgb_if_enable_mode_t
st7789 rgb if enable mode enumeration definition
st7789_ram_access_t
st7789 ram access enumeration definition
uint8_t st7789_set_pwm_frequency(st7789_handle_t *handle, st7789_pwm_frequency_t frequency)
set pwm frequency
uint8_t st7789_set_spi2_enable(st7789_handle_t *handle, st7789_bool_t date_lane, st7789_bool_t command_table_2)
set spi2 enable
uint8_t st7789_set_porch(st7789_handle_t *handle, uint8_t back_porch_normal, uint8_t front_porch_normal, st7789_bool_t separate_porch_enable, uint8_t back_porch_idle, uint8_t front_porch_idle, uint8_t back_porch_partial, uint8_t front_porch_partial)
set porch
uint8_t st7789_set_power_control_2(st7789_handle_t *handle, st7789_sbclk_div_t sbclk, st7789_stp14ck_div_t stp14ck)
set power control 2
uint8_t st7789_vcom_convert_to_register(st7789_handle_t *handle, float v, uint8_t *reg)
convert the vcom to the register raw data
uint8_t st7789_set_vdv(st7789_handle_t *handle, uint8_t vdv)
set vdv
st7789_gate_scan_direction_t
st7789 gate scan direction enumeration definition
st7789_gate_scan_mode_t
st7789 gate scan mode enumeration definition
uint8_t st7789_set_vrhs(st7789_handle_t *handle, uint8_t vrhs)
set vrhs
uint8_t st7789_set_digital_gamma_look_up_table_blue(st7789_handle_t *handle, uint8_t param[64])
set blue digital gamma look up table
uint8_t st7789_set_digital_gamma_look_up_table_red(st7789_handle_t *handle, uint8_t param[64])
set red digital gamma look up table
uint8_t st7789_gate_line_convert_to_register(st7789_handle_t *handle, uint16_t l, uint8_t *reg)
convert the gate line to the register raw data
st7789_display_mode_t
st7789 display mode enumeration definition
uint8_t st7789_display_inversion_off(st7789_handle_t *handle)
display inversion off
st7789_font_t
st7789 font size enumeration definition
uint8_t st7789_draw_picture_18bits(st7789_handle_t *handle, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint32_t *image)
draw a picture
uint8_t st7789_set_vertical_scrolling(st7789_handle_t *handle, uint16_t top_fixed_area, uint16_t scrolling_area, uint16_t bottom_fixed_area)
set vertical scrolling
uint8_t st7789_display_on(st7789_handle_t *handle)
display on
uint8_t st7789_tearing_effect_line_on(st7789_handle_t *handle, st7789_tearing_effect_t effect)
tearing effect line on
uint8_t st7789_set_vertical_scroll_start_address(st7789_handle_t *handle, uint16_t start_address)
set the vertical scroll start address
uint8_t st7789_init(st7789_handle_t *handle)
initialize the chip
uint8_t st7789_set_tear_scanline(st7789_handle_t *handle, uint16_t l)
set tear scanline
uint8_t st7789_draw_picture_12bits(st7789_handle_t *handle, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint16_t *image)
draw a picture
st7789_color_enhancement_mode_t
st7789 color enhancement mode enumeration definition
uint8_t st7789_set_column_address(st7789_handle_t *handle, uint16_t start_address, uint16_t end_address)
set the column address
struct st7789_handle_s st7789_handle_t
st7789 handle structure definition
#define ST7789_BUFFER_SIZE
st7789 buffer size definition
uint8_t st7789_set_row(st7789_handle_t *handle, uint16_t row)
set row
uint8_t st7789_normal_display_mode_on(st7789_handle_t *handle)
normal display mode on
uint8_t st7789_write_string(st7789_handle_t *handle, uint16_t x, uint16_t y, char *str, uint16_t len, uint32_t color, st7789_font_t font)
write a string in the display
uint8_t st7789_software_reset(st7789_handle_t *handle)
software reset
uint8_t st7789_set_partial_areas(st7789_handle_t *handle, uint16_t start_row, uint16_t end_row)
set partial areas
st7789_rgb_interface_color_format_t
st7789 rgb interface color format enumeration definition
uint8_t st7789_set_display_control(st7789_handle_t *handle, st7789_bool_t brightness_control_block, st7789_bool_t display_dimming, st7789_bool_t backlight_control)
set display control
uint8_t st7789_fill_rect(st7789_handle_t *handle, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint32_t color)
fill the rect
uint8_t st7789_set_cabc_minimum_brightness(st7789_handle_t *handle, uint8_t brightness)
set cabc minimum brightness
uint8_t st7789_tearing_effect_line_off(st7789_handle_t *handle)
tearing effect line off
uint8_t st7789_set_interface_pixel_format(st7789_handle_t *handle, st7789_rgb_interface_color_format_t rgb, st7789_control_interface_color_format_t control)
set interface pixel format
uint8_t st7789_idle_mode_off(st7789_handle_t *handle)
idle mode off
uint8_t st7789_idle_mode_on(st7789_handle_t *handle)
idle mode on
uint8_t st7789_deinit(st7789_handle_t *handle)
close the chip
uint8_t st7789_nop(st7789_handle_t *handle)
nop
uint8_t st7789_partial_display_mode_on(st7789_handle_t *handle)
partial display mode on
uint8_t st7789_set_brightness_control_and_color_enhancement(st7789_handle_t *handle, st7789_bool_t color_enhancement, st7789_color_enhancement_mode_t mode, st7789_color_enhancement_level_t level)
set brightness control and color enhancement
uint8_t st7789_info(st7789_info_t *info)
get chip's information
st7789_color_enhancement_level_t
st7789 color enhancement level enumeration definition
uint8_t st7789_draw_picture_16bits(st7789_handle_t *handle, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint16_t *image)
draw a picture
uint8_t st7789_clear(st7789_handle_t *handle)
clear the display
uint8_t st7789_memory_continue_write(st7789_handle_t *handle, uint8_t *data, uint16_t len)
memory continue write
uint8_t st7789_display_off(st7789_handle_t *handle)
display off
st7789_bool_t
st7789 bool enumeration definition
uint8_t st7789_set_row_address(st7789_handle_t *handle, uint16_t start_address, uint16_t end_address)
set the row address
uint8_t st7789_memory_write(st7789_handle_t *handle, uint8_t *data, uint16_t len)
memory write
st7789_tearing_effect_t
st7789 tearing effect enumeration definition
struct st7789_info_s st7789_info_t
st7789 information structure definition
uint8_t st7789_sleep_in(st7789_handle_t *handle)
sleep in
uint8_t st7789_set_gamma(st7789_handle_t *handle, uint8_t gamma)
set gamma
st7789_control_interface_color_format_t
st7789 control interface color format enumeration definition
uint8_t st7789_set_display_brightness(st7789_handle_t *handle, uint8_t brightness)
set display brightness
uint8_t st7789_set_column(st7789_handle_t *handle, uint16_t column)
set column
uint8_t st7789_display_inversion_on(st7789_handle_t *handle)
display inversion on
uint8_t st7789_draw_point(st7789_handle_t *handle, uint16_t x, uint16_t y, uint32_t color)
draw a point in the display
uint8_t st7789_sleep_out(st7789_handle_t *handle)
sleep out
uint8_t st7789_set_memory_data_access_control(st7789_handle_t *handle, uint8_t order)
set memory data access control
uint8_t st7789_write_data(st7789_handle_t *handle, uint8_t data)
write the data
uint8_t st7789_write_cmd(st7789_handle_t *handle, uint8_t cmd)
write the command
uint8_t(* spi_init)(void)
uint8_t(* cmd_data_gpio_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* cmd_data_gpio_deinit)(void)
uint8_t(* reset_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_deinit)(void)
uint8_t(* reset_gpio_init)(void)
uint8_t(* cmd_data_gpio_write)(uint8_t value)
uint8_t(* spi_write_cmd)(uint8_t *buf, uint16_t len)
uint8_t buf[ST7789_BUFFER_SIZE+8]
uint8_t(* reset_gpio_write)(uint8_t value)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v