VSF Documented
vsf_disp_st7735.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17#ifndef __VSF_DISP_ST7735_H__
18#define __VSF_DISP_ST7735_H__
19
20/*============================ INCLUDES ======================================*/
21
23
24#if VSF_USE_UI == ENABLED && VSF_DISP_USE_ST7735 == ENABLED
25
26#include "../common/vsf_disp_sitronix_common.h"
27
28#if defined(__VSF_DISP_ST7735_CLASS_IMPLEMENT)
29# undef __VSF_DISP_ST7735_CLASS_IMPLEMENT
30# define __VSF_CLASS_IMPLEMENT__
31#endif
32
33#include "utilities/ooc_class.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*============================ MACROS ========================================*/
40
41#define ST7735_SLPIN (0x10)
42#define ST7735_SLPOUT (0x11)
43
44#define ST7735_INV(__ON) (0x20 | ((__ON) ? 1 : 0))
45#define ST7735_DISP(__ON) (0x28 | ((__ON) ? 1 : 0))
46#define ST7735_CASET (0x2A)
47#define ST7735_RASET (0x2B)
48#define ST7735_RAMWR (0x2C)
49
50#define ST7735_MADCTL (0x36)
51# define ST7735_MADCTL_COLOR_RGB (0 << 3)
52# define ST7735_MADCTL_COLOR_BGR (1 << 3)
53# define ST7735_MADCTL_MV (1 << 5)
54# define ST7735_MADCTL_MX (1 << 6)
55# define ST7735_MADCTL_MY (1 << 7)
56
57#define ST7735_COLMOD (0x3A)
58# define ST7735_COLMOD_PIXEL_12B (3 << 0)
59# define ST7735_COLMOD_PIXEL_16B (5 << 0)
60# define ST7735_COLMOD_PIXEL_18B (6 << 0)
61
62#define ST7735_DISPLAY_SETTING_COLOR_RGB ST7735_MADCTL_COLOR_RGB
63#define ST7735_DISPLAY_SETTING_COLOR_BGR ST7735_MADCTL_COLOR_BGR
64#define ST7735_DISPLAY_SETTING_XY_EXCHANGE ST7735_MADCTL_MV
65#define ST7735_DISPLAY_SETTING_X_REVERSE ST7735_MADCTL_MX
66#define ST7735_DISPLAY_SETTING_Y_REVERSE ST7735_MADCTL_MY
67
68#define ST7735_PIXEL_12B ST7735_COLMOD_PIXEL_12B
69#define ST7735_PIXEL_16B ST7735_COLMOD_PIXEL_16B
70#define ST7735_PIXEL_18B ST7735_COLMOD_PIXEL_18B
71
72/*============================ MACROFIED FUNCTIONS ===========================*/
73
74#define VSF_DISP_ST7735_INIT_SEQ(__PIXEL_FORMAT, __DISPLAY_SETTING, __INVERSE) \
75 VSF_DISP_SITRONIX_WRITE(0xB1, 3, 0x05, 0x3C, 0x3C), \
76 VSF_DISP_SITRONIX_WRITE(0xB2, 3, 0x05, 0x3C, 0x3C), \
77 VSF_DISP_SITRONIX_WRITE(0xB3, 6, 0x05, 0x3C, 0x3C, 0x05, 0x3C, 0x3C),\
78 VSF_DISP_SITRONIX_WRITE(0xB4, 1, 0x03), \
79 VSF_DISP_SITRONIX_WRITE(0xC0, 3, 0xAB, 0x0B, 0x04), \
80 VSF_DISP_SITRONIX_WRITE(0xC1, 1, 0xC5), \
81 VSF_DISP_SITRONIX_WRITE(0xC2, 2, 0x0D, 0x00), \
82 VSF_DISP_SITRONIX_WRITE(0xC3, 2, 0x8D, 0x6A), \
83 VSF_DISP_SITRONIX_WRITE(0xC4, 2, 0x8D, 0xEE), \
84 VSF_DISP_SITRONIX_WRITE(0xC5, 1, 0x0F), \
85 VSF_DISP_SITRONIX_WRITE(0xE0, 16, 0x07, 0x0E, 0x08, 0x07, 0x10, 0x07, 0x02, 0x07, 0x09, 0x0F, 0x25, 0x36, 0x00, 0x08, 0x04, 0x10),\
86 VSF_DISP_SITRONIX_WRITE(0xE1, 16, 0x0A, 0x0D, 0x08, 0x07, 0x0F, 0x07, 0x02, 0x07, 0x09, 0x0F, 0x25, 0x35, 0x00, 0x09, 0x04, 0x10),\
87 VSF_DISP_SITRONIX_WRITE(0xFC, 1, 0x80), \
88 VSF_DISP_SITRONIX_WRITE(0xF0, 1, 0x11), \
89 VSF_DISP_SITRONIX_WRITE(0xD6, 1, 0xCB), \
90 VSF_DISP_SITRONIX_WRITE(ST7735_COLMOD, 1, __PIXEL_FORMAT), \
91 VSF_DISP_SITRONIX_WRITE(ST7735_MADCTL, 1, __DISPLAY_SETTING), \
92 VSF_DISP_SITRONIX_WRITE(ST7735_INV(__INVERSE), 0), \
93 VSF_DISP_SITRONIX_WRITE(ST7735_DISP(1), 0)
94
95/*============================ TYPES =========================================*/
96
98 public_member(
99 implement(vk_disp_sitronix_t);
100
101 const uint8_t *init_seq;
102 const uint16_t init_seq_len;
103 const uint8_t colume_offset;
104 const uint8_t page_offset;
106 private_member(
107 vsf_teda_t teda;
108 struct {
109 struct {
110 vk_disp_area_t area;
111 uint8_t *buffer;
112 } refresh;
113 } ctx;
114
116 bool is_inited;
117 bool is_area_set;
118 uint8_t set_area_cmd_buffer[12];
120};
121
122/*============================ GLOBAL VARIABLES ==============================*/
123
125
126/*============================ PROTOTYPES ====================================*/
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif // VSF_USE_UI
133#endif // __VSF_DISP_ST7735_H__
Definition vsf_disp.h:149
Definition vsf_disp_sitronix_common.h:58
Definition vsf_disp_st7735.h:97
Definition vsf_eda.h:834
#define vsf_class(__name)
Definition ooc_class.h:48
unsigned short uint16_t
Definition stdint.h:7
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_disp.h:144
const vk_disp_drv_t vk_disp_drv_st7735
Definition vsf_disp_st7735.c:49
uint8_t state
Definition vsf_msg_tree.h:247