ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
st7567.h File Reference
#include "fw_hal.h"

Go to the source code of this file.

Data Structures

struct  FontDef_t
 

Macros

#define ST7567_MODEL   ST7567_MODEL_ST7567
 
#define ST7567_CS   P35
 
#define ST7567_MOSI   P34
 
#define ST7567_SCK   P32
 
#define ST7567_RES   P37
 
#define ST7567_DC   P36
 
#define ST7567_BL   P12
 
#define ST7567_WIDTH   128
 
#define ST7567_HEIGHT   64
 
#define ST7567_COLUMN_EXPAND   4
 
#define ST7567_PAGES   8
 
#define ST7567_X_ORIENT   ST7567_SEG_DIRECTION_NORMAL
 
#define ST7567_Y_ORIENT   ST7567_COM_DIRECTION_NORMAL
 
#define ST7567_MODEL_ST7565   0
 
#define ST7567_MODEL_ST7567   1
 
#define ST7567_DISPLAY_OFF   0xAE /* 0xae: Display OFF (sleep mode), default */
 
#define ST7567_DISPLAY_ON   0xAF /* 0xaf: Display ON in normal mode */
 
#define ST7567_SET_START_LINE   0x40 /* 0x40-7f: Set display start line */
 
#define ST7567_SET_START_LINE_MASK   0x3f
 
#define ST7567_SET_PAGE_ADDRESS   0xB0 /* 0xb0-b7: Set page start address, 0 - 8 */
 
#define ST7567_SET_PAGE_ADDRESS_MASK   0x07
 
#define ST7567_SET_COLUMN_ADDRESS_MSB   0x10 /* 0x10-0x1f: Set 8bit column address - high 4 bits of 0 - 131 */
 
#define ST7567_SET_COLUMN_ADDRESS_MSB_MASK   0x0F
 
#define ST7567_SET_COLUMN_ADDRESS_LSB   0x00 /* 0x00-0x0f: Set 8bit column address - low 4 bits of 0 - 131 */
 
#define ST7567_SET_COLUMN_ADDRESS_LSB_MASK   0x0F
 
#define ST7567_SEG_DIRECTION_NORMAL   0xA0 /* 0xa0: Column address 0 is mapped to SEG0, default*/
 
#define ST7567_SEG_DIRECTION_REVERSE   0xA1 /* 0xa1: Column address 83H(131) is mapped to SEG0 */
 
#define ST7567_COM_DIRECTION_NORMAL   0xC0 /* 0xc0: Set COM output direction, normal mode */
 
#define ST7567_COM_DIRECTION_REVERSE   0xC8 /* 0xc8: Set COM output direction, reverse mode */
 
#define ST7567_INVERSE_DISPLAY_OFF   0xA6 /* 0xa6: Normal display */
 
#define ST7567_INVERSE_DISPLAY_ON   0xA7 /* 0xa7: Inverse display */
 
#define ST7567_ALL_PIXEL_ON   0xA5 /* 0xa5: Entire display ON */
 
#define ST7567_ALL_PIXEL_NORMAL   0xA4 /* 0xa4: Resume to RAM content display */
 
#define ST7567_BIAS_1_9   0xA2 /* 0xa2: Select BIAS setting 1/9 */
 
#define ST7567_BIAS_1_7   0xA3 /* 0xa3: Select BIAS setting 1/7 */
 
#define ST7567_READ_MODIFY_WRITE_START   0xE0 /* 0xe0: Enter the Read Modify Write mode */
 
#define ST7567_READ_MODIFY_WRITE_END   0xEE /* 0xee: Leave the Read Modify Write mode */
 
#define ST7567_RESET   0xE2 /* 0xe2: Software RESET */
 
#define ST7567_POWER_CONTROL   0x28
 
#define ST7567_POWER_CONTROL_VF   0x01
 
#define ST7567_POWER_CONTROL_VR   0x02
 
#define ST7567_POWER_CONTROL_VB   0x04
 
#define ST7567_REGULATION_RATIO   0x20
 
#define ST7567_REGULATION_RATIO_3_0   0x00
 
#define ST7567_REGULATION_RATIO_3_5   0x01
 
#define ST7567_REGULATION_RATIO_4_0   0x02
 
#define ST7567_REGULATION_RATIO_4_5   0x03
 
#define ST7567_REGULATION_RATIO_5_0   0x04 /* Default */
 
#define ST7567_REGULATION_RATIO_5_5   0x05
 
#define ST7567_REGULATION_RATIO_6_0   0x06
 
#define ST7567_REGULATION_RATIO_6_5   0x07
 
#define ST7567_SET_EV   0x81
 
#define ST7567_SET_EV_MASK   0x3F
 
#define ST7567_SET_BOOSTER   0xF8 /* Set booster level */
 
#define ST7567_SET_BOOSTER_4X   0x00
 
#define ST7567_SET_BOOSTER_5X   0x01
 
#define ST7567_SET_BOOSTER_6X   0x11
 
#define ST7567_NOP   0xE3
 
#define ST7567_TEST   0xFE
 
#define ST7567_TIMEOUT   20000
 
#define ST7567_COLOR_FRONT   1U
 
#define ST7567_COLOR_BACK   0U
 

Functions

void ST7567_WriteData (uint8_t dat)
 Write a single byte data to ST7567.
 
void ST7567_WriteSameData (uint8_t dat, uint32_t size)
 
void ST7567_WriteCommand (uint8_t command)
 Write a single byte command to ST7567.
 
void ST7567_Reset (void)
 Hardware reset ST7567 LCD.
 
void ST7567_Init (void)
 Initializes ST7567 LCD.
 
void ST7567_SetPowerSaveMode (HAL_State_t state)
 Powersave mode control.
 
void ST7567_SetBackLightState (HAL_State_t state)
 Turn ST7567 LCD backlight on or off.
 
void ST7567_SetContrast (uint8_t val)
 Turn ST7567 LCD backlight off.
 
void ST7567_UpdateScreen (void)
 Update LCD display with buffer changes.
 
void ST7567_ToggleInvert (void)
 Toggles pixels invertion inside internal RAM.
 
void ST7567_Fill (uint8_t Color)
 Fills entire LCD with specified color.
 
void ST7567_DrawPixel (uint8_t x, uint8_t y, uint8_t color)
 Draws pixel at desired location.
 
void ST7567_GotoXY (uint16_t x, uint16_t y)
 Sets cursor pointer to desired location for strings.
 
char ST7567_Putc (char ch, FontDef_t *Font, uint8_t color)
 Puts character to internal RAM.
 
char ST7567_Puts (char *str, FontDef_t *Font, uint8_t color)
 Puts string to internal RAM.
 
void ST7567_DrawLine (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t c)
 Draws line on LCD.
 

Variables

__CODE FontDef_t Font_3x5
 
__CODE FontDef_t Font_5x7
 

Macro Definition Documentation

◆ ST7567_ALL_PIXEL_NORMAL

#define ST7567_ALL_PIXEL_NORMAL   0xA4 /* 0xa4: Resume to RAM content display */

Definition at line 79 of file st7567.h.

◆ ST7567_ALL_PIXEL_ON

#define ST7567_ALL_PIXEL_ON   0xA5 /* 0xa5: Entire display ON */

Definition at line 78 of file st7567.h.

◆ ST7567_BIAS_1_7

#define ST7567_BIAS_1_7   0xA3 /* 0xa3: Select BIAS setting 1/7 */

Definition at line 83 of file st7567.h.

◆ ST7567_BIAS_1_9

#define ST7567_BIAS_1_9   0xA2 /* 0xa2: Select BIAS setting 1/9 */

Definition at line 82 of file st7567.h.

◆ ST7567_BL

#define ST7567_BL   P12

Definition at line 35 of file st7567.h.

◆ ST7567_COLOR_BACK

#define ST7567_COLOR_BACK   0U

Background color

Definition at line 145 of file st7567.h.

◆ ST7567_COLOR_FRONT

#define ST7567_COLOR_FRONT   1U

Front color

Definition at line 143 of file st7567.h.

◆ ST7567_COLUMN_EXPAND

#define ST7567_COLUMN_EXPAND   4

Definition at line 42 of file st7567.h.

◆ ST7567_COM_DIRECTION_NORMAL

#define ST7567_COM_DIRECTION_NORMAL   0xC0 /* 0xc0: Set COM output direction, normal mode */

Definition at line 72 of file st7567.h.

◆ ST7567_COM_DIRECTION_REVERSE

#define ST7567_COM_DIRECTION_REVERSE   0xC8 /* 0xc8: Set COM output direction, reverse mode */

Definition at line 73 of file st7567.h.

◆ ST7567_CS

#define ST7567_CS   P35

Definition at line 30 of file st7567.h.

◆ ST7567_DC

#define ST7567_DC   P36

Definition at line 34 of file st7567.h.

◆ ST7567_DISPLAY_OFF

#define ST7567_DISPLAY_OFF   0xAE /* 0xae: Display OFF (sleep mode), default */

Definition at line 54 of file st7567.h.

◆ ST7567_DISPLAY_ON

#define ST7567_DISPLAY_ON   0xAF /* 0xaf: Display ON in normal mode */

Definition at line 55 of file st7567.h.

◆ ST7567_HEIGHT

#define ST7567_HEIGHT   64

Definition at line 40 of file st7567.h.

◆ ST7567_INVERSE_DISPLAY_OFF

#define ST7567_INVERSE_DISPLAY_OFF   0xA6 /* 0xa6: Normal display */

Definition at line 75 of file st7567.h.

◆ ST7567_INVERSE_DISPLAY_ON

#define ST7567_INVERSE_DISPLAY_ON   0xA7 /* 0xa7: Inverse display */

Definition at line 76 of file st7567.h.

◆ ST7567_MODEL

#define ST7567_MODEL   ST7567_MODEL_ST7567

ST7565, ST7567

Display Data RAM has a matrix of 65 by 132 bits. The address ranges are: X=0~131(83H) (column address), Y=0~8 (page address)

Definition at line 28 of file st7567.h.

◆ ST7567_MODEL_ST7565

#define ST7567_MODEL_ST7565   0

Definition at line 50 of file st7567.h.

◆ ST7567_MODEL_ST7567

#define ST7567_MODEL_ST7567   1

Definition at line 51 of file st7567.h.

◆ ST7567_MOSI

#define ST7567_MOSI   P34

Definition at line 31 of file st7567.h.

◆ ST7567_NOP

#define ST7567_NOP   0xE3

Definition at line 134 of file st7567.h.

◆ ST7567_PAGES

#define ST7567_PAGES   8

Definition at line 44 of file st7567.h.

◆ ST7567_POWER_CONTROL

#define ST7567_POWER_CONTROL   0x28

This instruction controls the built-in power circuits. Typically, these 3 flags are turned ON at the same time.

Definition at line 94 of file st7567.h.

◆ ST7567_POWER_CONTROL_VB

#define ST7567_POWER_CONTROL_VB   0x04

Definition at line 97 of file st7567.h.

◆ ST7567_POWER_CONTROL_VF

#define ST7567_POWER_CONTROL_VF   0x01

Definition at line 95 of file st7567.h.

◆ ST7567_POWER_CONTROL_VR

#define ST7567_POWER_CONTROL_VR   0x02

Definition at line 96 of file st7567.h.

◆ ST7567_READ_MODIFY_WRITE_END

#define ST7567_READ_MODIFY_WRITE_END   0xEE /* 0xee: Leave the Read Modify Write mode */

Definition at line 86 of file st7567.h.

◆ ST7567_READ_MODIFY_WRITE_START

#define ST7567_READ_MODIFY_WRITE_START   0xE0 /* 0xe0: Enter the Read Modify Write mode */

Definition at line 85 of file st7567.h.

◆ ST7567_REGULATION_RATIO

#define ST7567_REGULATION_RATIO   0x20

The operation voltage (V0) calculation formula is shown below: (RR comes from Regulation Ratio, EV comes from EV[5:0]) V0 = RR X [ 1 – (63 – EV) / 162 ] X 2.1, or V0 = RR X [ ( 99 + EV ) / 162 ] X 2.1

Definition at line 105 of file st7567.h.

◆ ST7567_REGULATION_RATIO_3_0

#define ST7567_REGULATION_RATIO_3_0   0x00

Definition at line 106 of file st7567.h.

◆ ST7567_REGULATION_RATIO_3_5

#define ST7567_REGULATION_RATIO_3_5   0x01

Definition at line 107 of file st7567.h.

◆ ST7567_REGULATION_RATIO_4_0

#define ST7567_REGULATION_RATIO_4_0   0x02

Definition at line 108 of file st7567.h.

◆ ST7567_REGULATION_RATIO_4_5

#define ST7567_REGULATION_RATIO_4_5   0x03

Definition at line 109 of file st7567.h.

◆ ST7567_REGULATION_RATIO_5_0

#define ST7567_REGULATION_RATIO_5_0   0x04 /* Default */

Definition at line 110 of file st7567.h.

◆ ST7567_REGULATION_RATIO_5_5

#define ST7567_REGULATION_RATIO_5_5   0x05

Definition at line 111 of file st7567.h.

◆ ST7567_REGULATION_RATIO_6_0

#define ST7567_REGULATION_RATIO_6_0   0x06

Definition at line 112 of file st7567.h.

◆ ST7567_REGULATION_RATIO_6_5

#define ST7567_REGULATION_RATIO_6_5   0x07

Definition at line 113 of file st7567.h.

◆ ST7567_RES

#define ST7567_RES   P37

Definition at line 33 of file st7567.h.

◆ ST7567_RESET

#define ST7567_RESET   0xE2 /* 0xe2: Software RESET */

Definition at line 88 of file st7567.h.

◆ ST7567_SCK

#define ST7567_SCK   P32

Definition at line 32 of file st7567.h.

◆ ST7567_SEG_DIRECTION_NORMAL

#define ST7567_SEG_DIRECTION_NORMAL   0xA0 /* 0xa0: Column address 0 is mapped to SEG0, default*/

Definition at line 69 of file st7567.h.

◆ ST7567_SEG_DIRECTION_REVERSE

#define ST7567_SEG_DIRECTION_REVERSE   0xA1 /* 0xa1: Column address 83H(131) is mapped to SEG0 */

Definition at line 70 of file st7567.h.

◆ ST7567_SET_BOOSTER

#define ST7567_SET_BOOSTER   0xF8 /* Set booster level */

Definition at line 129 of file st7567.h.

◆ ST7567_SET_BOOSTER_4X

#define ST7567_SET_BOOSTER_4X   0x00

Definition at line 130 of file st7567.h.

◆ ST7567_SET_BOOSTER_5X

#define ST7567_SET_BOOSTER_5X   0x01

Definition at line 131 of file st7567.h.

◆ ST7567_SET_BOOSTER_6X

#define ST7567_SET_BOOSTER_6X   0x11

Definition at line 132 of file st7567.h.

◆ ST7567_SET_COLUMN_ADDRESS_LSB

#define ST7567_SET_COLUMN_ADDRESS_LSB   0x00 /* 0x00-0x0f: Set 8bit column address - low 4 bits of 0 - 131 */

Definition at line 66 of file st7567.h.

◆ ST7567_SET_COLUMN_ADDRESS_LSB_MASK

#define ST7567_SET_COLUMN_ADDRESS_LSB_MASK   0x0F

Definition at line 67 of file st7567.h.

◆ ST7567_SET_COLUMN_ADDRESS_MSB

#define ST7567_SET_COLUMN_ADDRESS_MSB   0x10 /* 0x10-0x1f: Set 8bit column address - high 4 bits of 0 - 131 */

Definition at line 63 of file st7567.h.

◆ ST7567_SET_COLUMN_ADDRESS_MSB_MASK

#define ST7567_SET_COLUMN_ADDRESS_MSB_MASK   0x0F

Definition at line 64 of file st7567.h.

◆ ST7567_SET_EV

#define ST7567_SET_EV   0x81

This is double byte instruction. The first byte set ST7567 into EV adjust mode and the following instruction will change the EV setting. That means these 2 bytes must be used together. They control the electronic volume to adjust a suitable V0 voltage for the LCD.

Definition at line 121 of file st7567.h.

◆ ST7567_SET_EV_MASK

#define ST7567_SET_EV_MASK   0x3F

Definition at line 122 of file st7567.h.

◆ ST7567_SET_PAGE_ADDRESS

#define ST7567_SET_PAGE_ADDRESS   0xB0 /* 0xb0-b7: Set page start address, 0 - 8 */

Definition at line 60 of file st7567.h.

◆ ST7567_SET_PAGE_ADDRESS_MASK

#define ST7567_SET_PAGE_ADDRESS_MASK   0x07

Definition at line 61 of file st7567.h.

◆ ST7567_SET_START_LINE

#define ST7567_SET_START_LINE   0x40 /* 0x40-7f: Set display start line */

Definition at line 57 of file st7567.h.

◆ ST7567_SET_START_LINE_MASK

#define ST7567_SET_START_LINE_MASK   0x3f

Definition at line 58 of file st7567.h.

◆ ST7567_TEST

#define ST7567_TEST   0xFE

Definition at line 135 of file st7567.h.

◆ ST7567_TIMEOUT

#define ST7567_TIMEOUT   20000

Definition at line 139 of file st7567.h.

◆ ST7567_WIDTH

#define ST7567_WIDTH   128

Definition at line 38 of file st7567.h.

◆ ST7567_X_ORIENT

#define ST7567_X_ORIENT   ST7567_SEG_DIRECTION_NORMAL

Definition at line 46 of file st7567.h.

◆ ST7567_Y_ORIENT

#define ST7567_Y_ORIENT   ST7567_COM_DIRECTION_NORMAL

Definition at line 48 of file st7567.h.

Function Documentation

◆ ST7567_DrawLine()

void ST7567_DrawLine ( uint16_t  x0,
uint16_t  y0,
uint16_t  x1,
uint16_t  y1,
uint8_t  c 
)

Draws line on LCD.

Note
ST7567_UpdateScreen() must be called after that in order to see updated LCD screen
Parameters
x0Line X start point. Valid input is 0 to ST7567_WIDTH - 1
y0Line Y start point. Valid input is 0 to ST7567_HEIGHT - 1
x1Line X end point. Valid input is 0 to ST7567_WIDTH - 1
y1Line Y end point. Valid input is 0 to ST7567_HEIGHT - 1
cColor to be used. This parameter can be a value of ST7567_COLOR_t enumeration
Return values
None

Definition at line 257 of file st7567.c.

258{
259 int16_t dx, dy, sx, sy, err, e2, i, tmp;
260
261 /* Check for overflow */
262 if (x0 >= ST7567_WIDTH)
263 {
264 x0 = ST7567_WIDTH - 1;
265 }
266 if (x1 >= ST7567_WIDTH)
267 {
268 x1 = ST7567_WIDTH - 1;
269 }
270 if (y0 >= ST7567_HEIGHT)
271 {
272 y0 = ST7567_HEIGHT - 1;
273 }
274 if (y1 >= ST7567_HEIGHT)
275 {
276 y1 = ST7567_HEIGHT - 1;
277 }
278
279 dx = (x0 < x1) ? (x1 - x0) : (x0 - x1);
280 dy = (y0 < y1) ? (y1 - y0) : (y0 - y1);
281 sx = (x0 < x1) ? 1 : -1;
282 sy = (y0 < y1) ? 1 : -1;
283 err = ((dx > dy) ? dx : -dy) / 2;
284
285 if (dx == 0)
286 {
287 if (y1 < y0)
288 {
289 tmp = y1;
290 y1 = y0;
291 y0 = tmp;
292 }
293
294 if (x1 < x0)
295 {
296 tmp = x1;
297 x1 = x0;
298 x0 = tmp;
299 }
300
301 /* Vertical line */
302 for (i = y0; i <= y1; i++)
303 {
304 ST7567_DrawPixel(x0, i, c);
305 }
306
307 /* Return from function */
308 return;
309 }
310
311 if (dy == 0)
312 {
313 if (y1 < y0)
314 {
315 tmp = y1;
316 y1 = y0;
317 y0 = tmp;
318 }
319
320 if (x1 < x0)
321 {
322 tmp = x1;
323 x1 = x0;
324 x0 = tmp;
325 }
326
327 /* Horizontal line */
328 for (i = x0; i <= x1; i++)
329 {
330 ST7567_DrawPixel(i, y0, c);
331 }
332
333 /* Return from function */
334 return;
335 }
336
337 while (1)
338 {
339 ST7567_DrawPixel(x0, y0, c);
340 if (x0 == x1 && y0 == y1)
341 {
342 break;
343 }
344 e2 = err;
345 if (e2 > -dx)
346 {
347 err -= dy;
348 x0 += sx;
349 }
350 if (e2 < dy)
351 {
352 err += dx;
353 y0 += sy;
354 }
355 }
356}
short int16_t
Definition: fw_types.h:24
uint8_t __XDATA i
void ST7567_DrawPixel(uint8_t x, uint8_t y, uint8_t color)
Draws pixel at desired location.
Definition: st7567.c:164
#define ST7567_WIDTH
Definition: st7567.h:38
#define ST7567_HEIGHT
Definition: st7567.h:40

◆ ST7567_DrawPixel()

void ST7567_DrawPixel ( uint8_t  x,
uint8_t  y,
uint8_t  color 
)

Draws pixel at desired location.

Note
ST7567_UpdateScreen() must called after that in order to see updates
Parameters
xX location. This parameter can be a value between 0 and ST7567_WIDTH - 1
yY location. This parameter can be a value between 0 and ST7567_HEIGHT - 1
colorColor to be used for screen fill. This parameter can be a value of ST7567_COLOR_t enumeration
Return values
None

Definition at line 164 of file st7567.c.

165{
166 uint8_t page, column;
167 if (x >= ST7567_WIDTH || y >= ST7567_HEIGHT)
168 {
169 /* Error */
170 return;
171 }
172
173 if (color == ST7567_COLOR_FRONT)
174 {
175 ST7567_Buffer_all[x + (y / 8) * ST7567_WIDTH] |= 1 << (y % 8);
176 }
177 else
178 {
179 ST7567_Buffer_all[x + (y / 8) * ST7567_WIDTH] &= ~(1 << (y % 8));
180 }
181}
unsigned char uint8_t
Definition: fw_types.h:18
volatile int16_t y
Definition: main.c:34
volatile int16_t x
Definition: main.c:34
static __XDATA uint8_t ST7567_Buffer_all[ST7567_WIDTH *ST7567_PAGES]
Definition: st7567.c:25
#define ST7567_COLOR_FRONT
Definition: st7567.h:143

◆ ST7567_Fill()

void ST7567_Fill ( uint8_t  Color)

Fills entire LCD with specified color.

Note
ST7567_UpdateScreen() must be called after that in order to see updates
Parameters
ColorColor to be used for screen fill, ST7567_COLOR_FRONT or ST7567_COLOR_BACK
Return values
None

Definition at line 158 of file st7567.c.

159{
160 /* Set memory */
161 memset((uint8_t *)ST7567_Buffer_all, (color == ST7567_COLOR_BACK) ? 0x00 : 0xFF, sizeof(ST7567_Buffer_all));
162}
#define ST7567_COLOR_BACK
Definition: st7567.h:145

◆ ST7567_GotoXY()

void ST7567_GotoXY ( uint16_t  x,
uint16_t  y 
)

Sets cursor pointer to desired location for strings.

Parameters
xX location. This parameter can be a value between 0 and ST7567_WIDTH - 1
yY location. This parameter can be a value between 0 and ST7567_HEIGHT - 1
Return values
None

Definition at line 183 of file st7567.c.

184{
185 /* Set write pointers */
188}
uint8_t ST7567_currentY
Definition: st7567.c:24
uint8_t ST7567_currentX
Definition: st7567.c:23

◆ ST7567_Init()

void ST7567_Init ( void  )

Initializes ST7567 LCD.

Parameters
None
Return values
None

Definition at line 68 of file st7567.c.

69{
72
74 // adjust contrast
77 // adjust regular voltage. LCD may fail to display if it is set too low.
83 // Start from line 0
85 // Start from page 0
87 // Start from column 0
90 // power control, LCD may fail to display if it is not properly set.
91 // recommend to set them all
98}
@ HAL_State_ON
Definition: fw_types.h:71
void ST7567_WriteCommand(uint8_t command)
Write a single byte command to ST7567.
Definition: st7567.c:44
void ST7567_Reset(void)
Hardware reset ST7567 LCD.
Definition: st7567.c:61
void ST7567_SetBackLightState(HAL_State_t state)
Turn ST7567 LCD backlight on or off.
Definition: st7567.c:121
#define ST7567_DISPLAY_ON
Definition: st7567.h:55
#define ST7567_REGULATION_RATIO_5_0
Definition: st7567.h:110
#define ST7567_POWER_CONTROL
Definition: st7567.h:94
#define ST7567_X_ORIENT
Definition: st7567.h:46
#define ST7567_POWER_CONTROL_VR
Definition: st7567.h:96
#define ST7567_SET_PAGE_ADDRESS
Definition: st7567.h:60
#define ST7567_Y_ORIENT
Definition: st7567.h:48
#define ST7567_SET_START_LINE_MASK
Definition: st7567.h:58
#define ST7567_REGULATION_RATIO
Definition: st7567.h:105
#define ST7567_SET_PAGE_ADDRESS_MASK
Definition: st7567.h:61
#define ST7567_ALL_PIXEL_NORMAL
Definition: st7567.h:79
#define ST7567_SET_COLUMN_ADDRESS_MSB
Definition: st7567.h:63
#define ST7567_POWER_CONTROL_VF
Definition: st7567.h:95
#define ST7567_SET_COLUMN_ADDRESS_MSB_MASK
Definition: st7567.h:64
#define ST7567_BIAS_1_9
Definition: st7567.h:82
#define ST7567_SET_EV_MASK
Definition: st7567.h:122
#define ST7567_SET_EV
Definition: st7567.h:121
#define ST7567_SET_COLUMN_ADDRESS_LSB_MASK
Definition: st7567.h:67
#define ST7567_RESET
Definition: st7567.h:88
#define ST7567_POWER_CONTROL_VB
Definition: st7567.h:97
#define ST7567_SET_START_LINE
Definition: st7567.h:57
#define ST7567_INVERSE_DISPLAY_OFF
Definition: st7567.h:75
#define ST7567_SET_COLUMN_ADDRESS_LSB
Definition: st7567.h:66

◆ ST7567_Putc()

char ST7567_Putc ( char  ch,
FontDef_t Font,
uint8_t  color 
)

Puts character to internal RAM.

Note
ST7567_UpdateScreen() must be called after that in order to see updated LCD screen
Parameters
chCharacter to be written
*FontPointer to FontDef_t structure with used font
colorColor used for drawing. This parameter can be a value of ST7567_COLOR_t enumeration
Return values
Characterwritten

Definition at line 190 of file st7567.c.

191{
192 uint32_t i, b, j, k;
193
194 for (i = 0; i < font->height; i++)
195 {
196 for (j = 0; j < font->bytes; j++)
197 {
198 b = font->dat[((ch - 32) * font->height + i) * font->bytes + j];
199 if (font->order == 0)
200 {
201 for (k = 0; k < 8 && k < font->width - j * 8; k++)
202 {
203 if ((b << k) & 0x80)
204 {
205 ST7567_DrawPixel(ST7567_currentX + (j * 8) + k, (ST7567_currentY + i), (uint8_t) color);
206 }
207 else
208 {
209 ST7567_DrawPixel(ST7567_currentX + (j * 8) + k, (ST7567_currentY + i), (uint8_t) !color);
210 }
211 }
212 }
213 else
214 {
215 for (k = 0; k < 8 && k < font->width - j * 8; k++)
216 {
217 if (b & (0x0001 << k))
218 {
219 ST7567_DrawPixel(ST7567_currentX + (j * 8) + k, (ST7567_currentY + i), (uint8_t) color);
220 }
221 else
222 {
223 ST7567_DrawPixel(ST7567_currentX + (j * 8) + k, (ST7567_currentY + i), (uint8_t) !color);
224 }
225 }
226 }
227 }
228 }
229
230 /* Increase pointer */
231 ST7567_currentX += font->width + 1;
232
233 /* Return character written */
234 return ch;
235}
return ch
unsigned long uint32_t
Definition: fw_types.h:20

◆ ST7567_Puts()

char ST7567_Puts ( char *  str,
FontDef_t Font,
uint8_t  color 
)

Puts string to internal RAM.

Note
ST7567_UpdateScreen() must be called after that in order to see updated LCD screen
Parameters
*strString to be written
*FontPointer to FontDef_t structure with used font
colorColor used for drawing. This parameter can be a value of ST7567_COLOR_t enumeration
Return values
Zeroon success or character value when function failed

Definition at line 237 of file st7567.c.

238{
239 /* Write characters */
240 while (*str)
241 {
242 /* Write character by character */
243 if (ST7567_Putc(*str, Font, color) != *str)
244 {
245 /* Return error */
246 return *str;
247 }
248
249 /* Increase string pointer */
250 str++;
251 }
252
253 /* Everything OK, zero should be returned */
254 return *str;
255}
char ST7567_Putc(char ch, FontDef_t *font, uint8_t color)
Puts character to internal RAM.
Definition: st7567.c:190

◆ ST7567_Reset()

void ST7567_Reset ( void  )

Hardware reset ST7567 LCD.

Parameters
None
Return values
None

Definition at line 61 of file st7567.c.

62{
63 ST7567_RES = 0;
64 SYS_Delay(5);
65 ST7567_RES = 1;
66}
void SYS_Delay(uint16_t t)
Definition: fw_sys.c:65
#define ST7567_RES
Definition: st7567.h:33

◆ ST7567_SetBackLightState()

void ST7567_SetBackLightState ( HAL_State_t  state)

Turn ST7567 LCD backlight on or off.

Parameters
stateHAL_State_ON:on, HAL_State_OFF:off
Return values
None

Definition at line 121 of file st7567.c.

122{
123 ST7567_BL = (state == HAL_State_ON)? SET : RESET;
124}
@ RESET
Definition: fw_types.h:84
@ SET
Definition: fw_types.h:85
#define ST7567_BL
Definition: st7567.h:35

◆ ST7567_SetContrast()

void ST7567_SetContrast ( uint8_t  val)

Turn ST7567 LCD backlight off.

Parameters
valvalue between 0x00 ~ 0x3F
Return values
None

Definition at line 126 of file st7567.c.

127{
130}
uint8_t val[MAX7219_BLOCKS]

◆ ST7567_SetPowerSaveMode()

void ST7567_SetPowerSaveMode ( HAL_State_t  state)

Powersave mode control.

Parameters
stateHAL_State_ON:powersave mode, HAL_State_OFF:work mode
Return values
None

Definition at line 100 of file st7567.c.

101{
102#if (ST7567_MODEL == ST7567_MODEL_ST7565)
103 if (state == HAL_State_ON)
104 ST7567_WriteCommand(ST7567_MODE_SLEEP);
105 else
106 ST7567_WriteCommand(ST7567_MODE_NORMAL);
107#else
108 if (state == HAL_State_ON)
109 {
112 }
113 else
114 {
117 }
118#endif
119}
#define ST7567_DISPLAY_OFF
Definition: st7567.h:54
#define ST7567_ALL_PIXEL_ON
Definition: st7567.h:78

◆ ST7567_ToggleInvert()

void ST7567_ToggleInvert ( void  )

Toggles pixels invertion inside internal RAM.

Note
ST7567_UpdateScreen() must be called after that in order to see updated LCD screen
Parameters
None
Return values
None

Definition at line 144 of file st7567.c.

145{
146 /* Toggle invert */
149 {
151 }
152 else
153 {
155 }
156}
__BIT ST7567_colorInverted
Definition: st7567.c:22
#define ST7567_INVERSE_DISPLAY_ON
Definition: st7567.h:76

◆ ST7567_UpdateScreen()

void ST7567_UpdateScreen ( void  )

Update LCD display with buffer changes.

Note
Call this function each time when display is changed
Parameters
None
Return values
None

Definition at line 132 of file st7567.c.

133{
134 uint8_t i = 0, *pt = ST7567_Buffer_all;
135 for (i = 0; i < ST7567_PAGES; i++)
136 {
141 }
142}
static void ST7567_Transmit(const uint8_t *pDat, uint32_t size)
Definition: st7567.c:51
#define ST7567_PAGES
Definition: st7567.h:44

◆ ST7567_WriteCommand()

void ST7567_WriteCommand ( uint8_t  command)

Write a single byte command to ST7567.

Parameters
commandcommand
Return values
None

Definition at line 44 of file st7567.c.

45{
46 ST7567_DC = 0;
47 ST7567_WriteData(command);
48 ST7567_DC = 1;
49}
void ST7567_WriteData(uint8_t dat)
Write a single byte data to ST7567.
Definition: st7567.c:27
#define ST7567_DC
Definition: st7567.h:34

◆ ST7567_WriteData()

void ST7567_WriteData ( uint8_t  dat)

Write a single byte data to ST7567.

Parameters
datdata
Return values
None

Definition at line 27 of file st7567.c.

28{
29 ST7567_CS = 0;
31 ST7567_CS = 1;
32}
__CODE int8_t dat[20]
uint8_t SPI_TxRx(uint8_t dat)
Definition: fw_spi.c:20
#define ST7567_CS
Definition: st7567.h:30

◆ ST7567_WriteSameData()

void ST7567_WriteSameData ( uint8_t  dat,
uint32_t  size 
)

Definition at line 34 of file st7567.c.

35{
36 ST7567_CS = 0;
37 do
38 {
40 } while (--size);
41 ST7567_CS = 1;
42}

Variable Documentation

◆ Font_3x5

__CODE FontDef_t Font_3x5
extern

Definition at line 547 of file pcd8544.c.

◆ Font_5x7

__CODE FontDef_t Font_5x7
extern

Definition at line 548 of file pcd8544.c.