ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
st7567.h
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef __FW_ST7567__
16#define __FW_ST7567__
17
18#include "fw_hal.h"
19
28#define ST7567_MODEL ST7567_MODEL_ST7567
29
30#define ST7567_CS P35
31#define ST7567_MOSI P34
32#define ST7567_SCK P32
33#define ST7567_RES P37
34#define ST7567_DC P36
35#define ST7567_BL P12
36
37// X width
38#define ST7567_WIDTH 128
39// Y height
40#define ST7567_HEIGHT 64
41// Display RAM Columns
42#define ST7567_COLUMN_EXPAND 4
43// Display RAM Pages (8x8bit + 1bit)
44#define ST7567_PAGES 8
45// X orientation
46#define ST7567_X_ORIENT ST7567_SEG_DIRECTION_NORMAL
47// Y orientation
48#define ST7567_Y_ORIENT ST7567_COM_DIRECTION_NORMAL
49
50#define ST7567_MODEL_ST7565 0
51#define ST7567_MODEL_ST7567 1
52
53/* ST7567 commands definitions */
54#define ST7567_DISPLAY_OFF 0xAE /* 0xae: Display OFF (sleep mode), default */
55#define ST7567_DISPLAY_ON 0xAF /* 0xaf: Display ON in normal mode */
56
57#define ST7567_SET_START_LINE 0x40 /* 0x40-7f: Set display start line */
58#define ST7567_SET_START_LINE_MASK 0x3f
59
60#define ST7567_SET_PAGE_ADDRESS 0xB0 /* 0xb0-b7: Set page start address, 0 - 8 */
61#define ST7567_SET_PAGE_ADDRESS_MASK 0x07
62
63#define ST7567_SET_COLUMN_ADDRESS_MSB 0x10 /* 0x10-0x1f: Set 8bit column address - high 4 bits of 0 - 131 */
64#define ST7567_SET_COLUMN_ADDRESS_MSB_MASK 0x0F
65
66#define ST7567_SET_COLUMN_ADDRESS_LSB 0x00 /* 0x00-0x0f: Set 8bit column address - low 4 bits of 0 - 131 */
67#define ST7567_SET_COLUMN_ADDRESS_LSB_MASK 0x0F
68
69#define ST7567_SEG_DIRECTION_NORMAL 0xA0 /* 0xa0: Column address 0 is mapped to SEG0, default*/
70#define ST7567_SEG_DIRECTION_REVERSE 0xA1 /* 0xa1: Column address 83H(131) is mapped to SEG0 */
71
72#define ST7567_COM_DIRECTION_NORMAL 0xC0 /* 0xc0: Set COM output direction, normal mode */
73#define ST7567_COM_DIRECTION_REVERSE 0xC8 /* 0xc8: Set COM output direction, reverse mode */
74
75#define ST7567_INVERSE_DISPLAY_OFF 0xA6 /* 0xa6: Normal display */
76#define ST7567_INVERSE_DISPLAY_ON 0xA7 /* 0xa7: Inverse display */
77
78#define ST7567_ALL_PIXEL_ON 0xA5 /* 0xa5: Entire display ON */
79#define ST7567_ALL_PIXEL_NORMAL 0xA4 /* 0xa4: Resume to RAM content display */
80
81 /* LCD bias set */
82#define ST7567_BIAS_1_9 0xA2 /* 0xa2: Select BIAS setting 1/9 */
83#define ST7567_BIAS_1_7 0xA3 /* 0xa3: Select BIAS setting 1/7 */
84
85#define ST7567_READ_MODIFY_WRITE_START 0xE0 /* 0xe0: Enter the Read Modify Write mode */
86#define ST7567_READ_MODIFY_WRITE_END 0xEE /* 0xee: Leave the Read Modify Write mode */
87
88#define ST7567_RESET 0xE2 /* 0xe2: Software RESET */
89
94#define ST7567_POWER_CONTROL 0x28
95#define ST7567_POWER_CONTROL_VF 0x01
96#define ST7567_POWER_CONTROL_VR 0x02
97#define ST7567_POWER_CONTROL_VB 0x04
98
105#define ST7567_REGULATION_RATIO 0x20
106#define ST7567_REGULATION_RATIO_3_0 0x00
107#define ST7567_REGULATION_RATIO_3_5 0x01
108#define ST7567_REGULATION_RATIO_4_0 0x02
109#define ST7567_REGULATION_RATIO_4_5 0x03
110#define ST7567_REGULATION_RATIO_5_0 0x04 /* Default */
111#define ST7567_REGULATION_RATIO_5_5 0x05
112#define ST7567_REGULATION_RATIO_6_0 0x06
113#define ST7567_REGULATION_RATIO_6_5 0x07
114
121#define ST7567_SET_EV 0x81
122#define ST7567_SET_EV_MASK 0x3F
123
124#if (ST7567_MODEL == ST7567_MODEL_ST7565)
125 #define ST7567_MODE_SLEEP 0xAC
126 #define ST7567_MODE_NORMAL 0xAD
127#endif
128
129#define ST7567_SET_BOOSTER 0xF8 /* Set booster level */
130#define ST7567_SET_BOOSTER_4X 0x00
131#define ST7567_SET_BOOSTER_5X 0x01
132#define ST7567_SET_BOOSTER_6X 0x11
133
134#define ST7567_NOP 0xE3
135#define ST7567_TEST 0xFE
136
137
138#ifndef ST7567_TIMEOUT
139#define ST7567_TIMEOUT 20000
140#endif
141
143#define ST7567_COLOR_FRONT 1U
145#define ST7567_COLOR_BACK 0U
146
147
148typedef struct {
149 uint8_t width;
150 uint8_t height;
151 uint8_t order;
152 uint8_t bytes;
153 const uint8_t *dat;
154} FontDef_t;
155
156extern __CODE FontDef_t Font_3x5;
157extern __CODE FontDef_t Font_5x7;
158
166
172void ST7567_WriteCommand(uint8_t command);
173
179void ST7567_Reset(void);
180
186void ST7567_Init(void);
187
194
195
202
209
216void ST7567_UpdateScreen(void);
217
224void ST7567_ToggleInvert(void);
225
232void ST7567_Fill(uint8_t Color);
233
243
251
260char ST7567_Putc(char ch, FontDef_t* Font, uint8_t color);
261
270char ST7567_Puts(char* str, FontDef_t* Font, uint8_t color);
271
283
284#endif // __ST7567_H_
return ch
__CODE int8_t dat[20]
unsigned long uint32_t
Definition: fw_types.h:20
unsigned short uint16_t
Definition: fw_types.h:19
HAL_State_t
Definition: fw_types.h:69
unsigned char uint8_t
Definition: fw_types.h:18
uint8_t val[MAX7219_BLOCKS]
volatile int16_t y
Definition: main.c:34
volatile int16_t x
Definition: main.c:34
void ST7567_SetContrast(uint8_t val)
Turn ST7567 LCD backlight off.
Definition: st7567.c:126
void ST7567_WriteCommand(uint8_t command)
Write a single byte command to ST7567.
Definition: st7567.c:44
void ST7567_GotoXY(uint16_t x, uint16_t y)
Sets cursor pointer to desired location for strings.
Definition: st7567.c:183
void ST7567_WriteSameData(uint8_t dat, uint32_t size)
Definition: st7567.c:34
void ST7567_SetPowerSaveMode(HAL_State_t state)
Powersave mode control.
Definition: st7567.c:100
void ST7567_DrawPixel(uint8_t x, uint8_t y, uint8_t color)
Draws pixel at desired location.
Definition: st7567.c:164
void ST7567_Fill(uint8_t Color)
Fills entire LCD with specified color.
Definition: st7567.c:158
void ST7567_DrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t c)
Draws line on LCD.
Definition: st7567.c:257
void ST7567_ToggleInvert(void)
Toggles pixels invertion inside internal RAM.
Definition: st7567.c:144
char ST7567_Puts(char *str, FontDef_t *Font, uint8_t color)
Puts string to internal RAM.
Definition: st7567.c:237
void ST7567_Reset(void)
Hardware reset ST7567 LCD.
Definition: st7567.c:61
char ST7567_Putc(char ch, FontDef_t *Font, uint8_t color)
Puts character to internal RAM.
Definition: st7567.c:190
void ST7567_SetBackLightState(HAL_State_t state)
Turn ST7567 LCD backlight on or off.
Definition: st7567.c:121
void ST7567_Init(void)
Initializes ST7567 LCD.
Definition: st7567.c:68
void ST7567_WriteData(uint8_t dat)
Write a single byte data to ST7567.
Definition: st7567.c:27
__CODE FontDef_t Font_5x7
Definition: pcd8544.c:548
__CODE FontDef_t Font_3x5
Definition: pcd8544.c:547
void ST7567_UpdateScreen(void)
Update LCD display with buffer changes.
Definition: st7567.c:132