Graphic Display v1.0.0
Control any mochrome display, with any microcontroller, in any amount.
Loading...
Searching...
No Matches
st7920.h
Go to the documentation of this file.
1
14#ifndef DRIVERS_ST7920_ST7920_H_
15#define DRIVERS_ST7920_ST7920_H_
16
17#include <assert.h>
18#include <malloc.h>
19#include <stdint.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <stddef.h>
23#include <stdbool.h>
24#include <string.h>
25
26#include "st7920_defs.h"
27
28/*
29 * Macros
30 */
31
32#define ST7920_OK 0
33#define ST7920_FAIL 1
34
35#define ST7920_COLOR_BLACK 0
36#define ST7920_COLOR_WHITE 1
37
38/*
39 * Enumerates
40 */
41
51
52/*
53 * Structs
54 */
55
61typedef void (*fxnDelay_ms)(uint32_t ms);
62
69typedef void (*fxn7920_mtxLock)(void);
70
77typedef void (*fxn7920_mtxunlock)(void);
78
85typedef void (*fxn1306spi_cs)(uint8_t Signal);
86
91typedef void (*fxn1306spi_reset)(uint8_t Signal);
92
98typedef uint8_t (*fxn1306spi_write)(uint8_t *buff, uint32_t len);
99
155
232
233/*
234 * Publics
235 */
236
244uint8_t ST7920_Init(st7920_t *st7920, st7920_params_t *params);
245
253uint8_t ST7920_SetFrameBuffer(st7920_t *st7920, uint8_t *pu8FrameBuffer);
254
261uint8_t ST7920_Refresh(st7920_t *st7920);
262
272uint8_t ST7920_Write(st7920_t *st7920, uint32_t x, uint32_t y, bool color);
273
281uint8_t ST7920_Fill(st7920_t *st7920, uint8_t color);
282
283#endif /* DRIVERS_ST7920_ST7920_H_ */
uint8_t ST7920_Refresh(st7920_t *st7920)
Definition st7920.c:207
uint8_t ST7920_SetFrameBuffer(st7920_t *st7920, uint8_t *pu8FrameBuffer)
Definition st7920.c:195
uint8_t ST7920_Fill(st7920_t *st7920, uint8_t color)
Definition st7920.c:275
uint8_t(* fxn1306spi_write)(uint8_t *buff, uint32_t len)
Function pointer to routine to transmit packets to ST7920 over SPI.
Definition st7920.h:98
void(* fxn1306spi_reset)(uint8_t Signal)
Function pointer to routine to control the Reset pin signal.
Definition st7920.h:91
void(* fxnDelay_ms)(uint32_t ms)
Function pointer definition for milliseconds delay.
Definition st7920.h:61
uint8_t ST7920_Init(st7920_t *st7920, st7920_params_t *params)
Definition st7920.c:125
void(* fxn7920_mtxLock)(void)
Function pointer to routine that waits for the mutex and lock it. It's useful on RTOS environments.
Definition st7920.h:69
st7920_mode_e
Set the Mode of ST7920 display. This device can work on 8bits, 4bits and spi mode,...
Definition st7920.h:48
@ ST7920_MODE_SPI
Definition st7920.h:49
void(* fxn7920_mtxunlock)(void)
Function pointer to routine that unlocks the mutex. It's useful on RTOS environments.
Definition st7920.h:77
uint8_t ST7920_Write(st7920_t *st7920, uint32_t x, uint32_t y, bool color)
Definition st7920.c:247
void(* fxn1306spi_cs)(uint8_t Signal)
Function pointer to routine to control the Chip Select signal. On ST7920, Chip Select is enabled on H...
Definition st7920.h:85
Struct to initialize and configure the driver to control the ST7920 peripheral.
Definition st7920.h:161
fxnDelay_ms delayMs
Pointer to delay milliseconds routine.
Definition st7920.h:194
fxn7920_mtxunlock mtxUnlock
Pointer to mutex unlock. If not used, sets to NULL.
Definition st7920.h:207
fxn1306spi_cs spiCs
Pointer to Chip Select controller routine.
Definition st7920.h:215
st7920_mode_e Mode
Configures the Mode of the ST7920. This driver can work on 4bit, 8bit or SPI mode.
Definition st7920.h:167
fxn1306spi_reset spiReset
Pointer to Reset controller routine.
Definition st7920.h:222
uint32_t u32Width
Configure the Width of the display.
Definition st7920.h:173
fxn7920_mtxLock mtxLock
Pointer to mutex lock. If not used, sets to NULL.
Definition st7920.h:201
uint32_t u32Heigth
Configure the Height of the display.
Definition st7920.h:179
bool bUseExternalFrameBuffer
Sets to true to provide a external FrameBuffer array. The size of array must be calculated with the f...
Definition st7920.h:187
fxn1306spi_write spiWrite
Pointer to spi controller routine.
Definition st7920.h:230
Handler of ST7920. Each display must need your own handler. Yes, this library supports multiples disp...
Definition st7920.h:107
fxn1306spi_write spiWrite
Pointer to function that write data over SPI.
Definition st7920.h:145
fxn1306spi_cs spiCs
Pointer to function that controls the Chip Select pin of ST7920.
Definition st7920.h:131
bool bInitialized
Definition st7920.h:148
fxn7920_mtxLock mtxLock
Pointer to function that waits and lock the mutex.
Definition st7920.h:118
fxn7920_mtxunlock mtxUnlock
Pointer to function that will unlock the mutex.
Definition st7920.h:124
st7920_mode_e Mode
Definition st7920.h:108
uint32_t u32Heigth
Definition st7920.h:152
uint8_t * pu8FrameBuffer
Definition st7920.h:150
uint32_t u32Width
Definition st7920.h:151
uint32_t u32FrameSize
Definition st7920.h:149
fxnDelay_ms delayMs
Pointer to function to execute a milliseconds delay.
Definition st7920.h:113
fxn1306spi_reset spiReset
Pointer to function that controls the Reset pin of ST7920.
Definition st7920.h:138