VSF Documented
vsf_disp_ssd1306.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_SSD1306_H__
18#define __VSF_DISP_SSD1306_H__
19
20/*============================ INCLUDES ======================================*/
21
23
24#if VSF_USE_UI == ENABLED && VSF_DISP_USE_SSD1306 == ENABLED
25
26#include "../common/vsf_disp_solomon_systech_common.h"
27
28#if defined(__VSF_DISP_SSD1306_CLASS_IMPLEMENT)
29# undef __VSF_DISP_SSD1306_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 VSF_SSD1306_PORT_IIC 0
42#define VSF_SSD1306_PORT_SPI 1
43#define VSF_SSD1306_PORT_EBI 2
44
45#ifndef VSF_SSD1306_CFG_PORT
46# define VSF_SSD1306_CFG_PORT VSF_SSD1306_PORT_IIC
47#endif
48
49#define SSD1306_SET_DISPLAY_ON(__ON) (0xAE | ((__ON) ? 1 : 0))
50#define SSD1306_SET_DISPLAY_START_LINE(__LINE) (0x40 | ((__LINE) & 0x3F))
51#define SSD1306_SET_POAGE_START_ADDRESS(__PAGE) (0xB0 | ((__PAGE) & 0x07))
52#define SSD1306_SET_COM_OUTPUT_SCAN_DIRECTION(__DIR) (0xC0 | ((__DIR) ? 0x08 : 0x00))
53#define SSD1306_SET_CONTRAST_CONTROL (0x81)
54#define SSD1306_SET_SEGMENT_REMAP(__REMAP) (0xA0 | ((__REMAP) ? 1 : 0))
55#define SSD1306_SET_INVERSE_DISPLAY(__INVERSE) (0xA6 | ((__INVERSE) ? 1 : 0))
56#define SSD1306_SET_MULTIPLEX_RATIO (0xA8)
57#define SSD1306_SET_DISPLAY_OFFSET (0xD3)
58#define SSD1306_SET_OSC_DIV (0xD5)
59#define SSD1306_SET_PRECHARGE_PERIOD (0xD9)
60#define SSD1306_SET_COM_PIN (0xDA)
61#define SSD1306_SET_VCOMH (0xDB)
62#define SSD1306_CHARGE_PUMP (0x8D)
63
64#define SSD1306_SET_ADDRESS_MODE (0x20)
65# define SSD1306_ADDRESS_MODE_HORIZONTAL (0x00)
66# define SSD1306_ADDRESS_MODE_VERTICAL (0x01)
67# define SSD1306_ADDRESS_MODE_PAGE (0x02)
68#define SSD1306_SET_COLUMN_ADDRESS (0x21)
69#define SSD1306_SET_PAGE_ADDRESS (0x22)
70
71/*============================ MACROFIED FUNCTIONS ===========================*/
72
73// TODO: add more parameters
74#if VSF_SSD1306_CFG_PORT == VSF_SSD1306_PORT_IIC
75# define VSF_DISP_SSD1306_IIC_INIT_SEQ(__LINE, __CONTRAST, __INVERSE, __DIRECTION,\
76 __OSC_DIV, __PRECHARGE, __COM_PIN, __VCOMH, __CHARGE_PUMP) \
77 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_DISPLAY_ON(0)), \
78 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_DISPLAY_START_LINE(0)),\
79 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_COM_OUTPUT_SCAN_DIRECTION(__DIRECTION)),\
80 \
81 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_CONTRAST_CONTROL), \
82 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(__CONTRAST), \
83 \
84 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_SEGMENT_REMAP(1)), \
85 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_INVERSE_DISPLAY(__INVERSE)),\
86 \
87 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_MULTIPLEX_RATIO), \
88 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I((__LINE) - 1), \
89 \
90 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_DISPLAY_OFFSET), \
91 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(0), \
92 \
93 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_OSC_DIV), \
94 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(__OSC_DIV), \
95 \
96 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_PRECHARGE_PERIOD), \
97 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(__PRECHARGE), \
98 \
99 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_COM_PIN), \
100 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(__COM_PIN), \
101 \
102 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_VCOMH), \
103 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(__VCOMH), \
104 \
105 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_CHARGE_PUMP), \
106 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(__CHARGE_PUMP), \
107 \
108 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_DISPLAY_ON(1)), \
109 \
110 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_SET_ADDRESS_MODE), \
111 VSF_DISP_SOLOMON_SYSTECH_IIC_WRITE_I(SSD1306_ADDRESS_MODE_HORIZONTAL)
112#elif VSF_SSD1306_CFG_PORT == VSF_SSD1306_PORT_SPI
113#elif VSF_SSD1306_CFG_PORT == VSF_SSD1306_PORT_EBI
114#endif
115
116/*============================ TYPES =========================================*/
117
119 public_member(
120 implement(vk_disp_t)
121
124 const uint8_t *init_seq;
125 const uint16_t init_seq_len;
126 uint32_t clock_hz;
127#elif VSF_SSD1306_CFG_PORT == VSF_SSD1306_PORT_SPI
129#elif VSF_SSD1306_CFG_PORT == VSF_SSD1306_PORT_EBI
131#endif
132 )
133
134 private_member(
135 struct {
136 struct {
137 vk_disp_area_t area;
138 uint8_t *buffer;
139 } refresh;
140 } ctx;
141
142 bool is_inited;
143 bool is_area_set;
144#if VSF_SSD1306_CFG_PORT == VSF_SSD1306_PORT_IIC
145 bool is_ctrl_sent;
146 uint8_t ctrl_byte;
147 uint8_t set_area_cmd_buffer[6 * 2];
148#elif VSF_SSD1306_CFG_PORT == VSF_SSD1306_PORT_SPI
149#elif VSF_SSD1306_CFG_PORT == VSF_SSD1306_PORT_EBI
150#endif
152};
153
154/*============================ GLOBAL VARIABLES ==============================*/
155
157
158/*============================ PROTOTYPES ====================================*/
159
160#ifdef __cplusplus
161}
162#endif
163
164#endif // VSF_USE_UI
165#endif // __VSF_DISP_SSD1306_H__
Definition vsf_disp.h:151
Definition vsf_disp_ssd1306.h:118
Definition vsf_disp.h:181
bool is_inited
Definition driver_gptimer_port.c:88
#define vsf_class(__name)
Definition ooc_class.h:52
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_disp.h:146
Definition vsf_disp_solomon_systech_common.h:62
Definition vsf_disp_solomon_systech_common.h:45
Definition vsf_disp_solomon_systech_common.h:50
#define VSF_SSD1306_CFG_PORT
Definition vsf_disp_ssd1306.h:46
const vk_disp_drv_t vk_disp_drv_ssd1306
Definition vsf_disp_ssd1306.c:47
#define VSF_SSD1306_PORT_IIC
Definition vsf_disp_ssd1306.h:41
vsf_tgui_label_t vsf_tgui_v_button_t implement_ex(struct { uint8_t bIsCheckButton :1;uint8_t bIsChecked :1;uint8_t bIsAllowEmphasize :1;uint8_t bIsEmphasized :1;}, _)) end_def_class(vsf_tgui_button_t) extern fsm_rt_t vk_tgui_button_init(vsf_tgui_button_t *ptButton)
Generated from commit: vsfteam/vsf@3b461d0