stm32-camera  1.0
Data Structures | Macros | Typedefs | Functions | Variables
st7735r.h File Reference

Main header file for the ST7735R LCD chip. More...

#include "main.h"

Go to the source code of this file.

Data Structures

struct  ST7735R
 

Macros

#define ST7735R_RET_OK   0
 
#define ST7735R_RET_FAIL   0
 
#define ST7735R_SPI_TIMEOUT   100
 

Typedefs

typedef int ST7735R_Return
 

Functions

void ST7735R_CS_High (void)
 Set SPI1 CS pin. More...
 
void ST7735R_CS_Low (void)
 Bring low SPI1 CS pin. More...
 
ST7735R_Return ST7735R_Write_Command (struct ST7735R *self, uint8_t cmd)
 Write command on device. More...
 
ST7735R_Return ST7735R_Write_Data (struct ST7735R *self, uint8_t *data, uint8_t size)
 Write data to RAM on device. More...
 
ST7735R_Return ST7735R_Backlight_Off (struct ST7735R *self)
 Turn backlight off. More...
 

Variables

static uint8_t ST7735R_NOP_CMD = 0x00
 NOP command. More...
 
static uint8_t ST7735R_SWRESET_CMD = 0x01
 SWRESET command. More...
 
static uint8_t ST7735R_RDDID_CMD = 0x04
 RDDID command. More...
 
static uint8_t ST7735R_RDDST_CMD = 0x09
 RDDST command. More...
 
static uint8_t ST7735R_RDDPM_CMD = 0xA0
 RDDPM command. More...
 
static uint8_t ST7735R_RDDMADCTL_CMD = 0xB0
 RDDMADCTL command. More...
 
static uint8_t ST7735R_RDDCOLMOD_CMD = 0xC0
 RDDCOLMOD command. More...
 
static uint8_t ST7735R_RDDIM_CMD = 0xD0
 RDDIM command. More...
 
static uint8_t ST7735R_RDDSM_CMD = 0xE0
 RDDSM command. More...
 
static uint8_t ST7735R_SLPIN_CMD = 0x10
 SLPIN command. More...
 
static uint8_t ST7735R_SLPOUT_CMD = 0x11
 SLPOUT command. More...
 
static uint8_t ST7735R_PTLON_CMD = 0x12
 PTLON command. More...
 
static uint8_t ST7735R_NORON_CMD = 0x13
 NORON command. More...
 
static uint8_t ST7735R_INVOFF_CMD = 0x20
 INVOFF command. More...
 
static uint8_t ST7735R_INVON_CMD = 0x21
 INVON command. More...
 
static uint8_t ST7735R_GAMSET_CMD = 0x26
 GAMSET command. More...
 
static uint8_t ST7735R_DISPOFF_CMD = 0x28
 DISPOFF command. More...
 
static uint8_t ST7735R_DISPON_CMD = 0x29
 DISPON command. More...
 
static uint8_t ST7735R_CASET_CMD = 0x2A
 CASET command. More...
 
static uint8_t ST7735R_RASET_CMD = 0x2B
 RASET command. More...
 
static uint8_t ST7735R_RAMWR_CMD = 0x2C
 RAMWR command. More...
 
static uint8_t ST7735R_RGBSET_CMD = 0x2D
 RGBSET command. More...
 
static uint8_t ST7735R_RAMRD_CMD = 0x2E
 RAMRD command. More...
 
static uint8_t ST7735R_PTLAR_CMD = 0x30
 PTLAR command. More...
 
static uint8_t ST7735R_TEOFF_CMD = 0x34
 TEOFF command. More...
 
static uint8_t ST7735R_TEON_CMD = 0x35
 TEON command. More...
 
static uint8_t ST7735R_MADCTL_CMD = 0x36
 MADCTL command. More...
 
static uint8_t ST7735R_IDMOFF_CMD = 0x38
 IDMOFF command. More...
 
static uint8_t ST7735R_IDMON_CMD = 0x39
 IDMON command. More...
 
static uint8_t ST7735R_COLMOD_CMD = 0x3A
 COLMOD command. More...
 
static uint8_t ST7735R_RDID1_CMD = 0xDA
 RDID1 command. More...
 
static uint8_t ST7735R_RDID2_CMD = 0xDB
 RDID2 command. More...
 
static uint8_t ST7735R_RDID3_CMD = 0xDC
 RDID3 command. More...
 

Detailed Description

Main header file for the ST7735R LCD chip.

pinkeee @ j.t0d.nosp@m.d@pr.nosp@m.otonm.nosp@m.ail..nosp@m.com

Note
See README for contributing guides and info.

Definition in file st7735r.h.

Macro Definition Documentation

◆ ST7735R_RET_FAIL

#define ST7735R_RET_FAIL   0

Definition at line 16 of file st7735r.h.

◆ ST7735R_RET_OK

#define ST7735R_RET_OK   0

Definition at line 15 of file st7735r.h.

◆ ST7735R_SPI_TIMEOUT

#define ST7735R_SPI_TIMEOUT   100

Definition at line 18 of file st7735r.h.

Typedef Documentation

◆ ST7735R_Return

typedef int ST7735R_Return

Definition at line 269 of file st7735r.h.

Function Documentation

◆ ST7735R_Backlight_Off()

ST7735R_Return ST7735R_Backlight_Off ( struct ST7735R self)

Turn backlight off.

Returns
either ST7735R_RET_OK or ST7735R_RET_FAIL

Definition at line 74 of file st7735r.c.

75 {
76  uint8_t tx[2] = {0};
77  uint8_t rx[10] = {0};
78 
79  tx[0] = ST7735R_DISPOFF_CMD;
80 
82  HAL_GPIO_WritePin(A0_GPIO_Port, A0_Pin, GPIO_PIN_RESET);
83 
84  HAL_SPI_Transmit(self->SPI_Handler, tx, sizeof(tx), 100);
85  //HAL_SPI_Receive(self->SPI_Handler, rx, 4, 100);
87 
88  return ST7735R_RET_OK;
89 }
static uint8_t ST7735R_DISPOFF_CMD
DISPOFF command.
Definition: st7735r.h:139
void ST7735R_CS_Low(void)
Bring low SPI1 CS pin.
Definition: st7735r.c:26
#define ST7735R_RET_OK
Definition: st7735r.h:15
void ST7735R_CS_High(void)
Set SPI1 CS pin.
Definition: st7735r.c:16
SPI_HandleTypeDef * SPI_Handler
Definition: st7735r.h:266

◆ ST7735R_CS_High()

void ST7735R_CS_High ( void  )

Set SPI1 CS pin.

Parameters
Void
Returns
Void N/A

Definition at line 16 of file st7735r.c.

17 {
18  HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_SET);
19 }

◆ ST7735R_CS_Low()

void ST7735R_CS_Low ( void  )

Bring low SPI1 CS pin.

Parameters
Void
Returns
Void N/A

Definition at line 26 of file st7735r.c.

27 {
28  HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET);
29 }

◆ ST7735R_Write_Command()

ST7735R_Return ST7735R_Write_Command ( struct ST7735R self,
uint8_t  cmd 
)

Write command on device.

Parameters
cmdwhat command to write to
Returns
either ST7735R_RET_OK or ST7735R_RET_FAIL

Definition at line 36 of file st7735r.c.

37 {
38  HAL_GPIO_WritePin(A0_GPIO_Port, A0_Pin, GPIO_PIN_RESET);
39 
41  if (HAL_SPI_Transmit(self->SPI_Handler, &cmd, sizeof(cmd), ST7735R_SPI_TIMEOUT) != HAL_OK)
42  {
44  return ST7735R_RET_FAIL;
45  }
47  return ST7735R_RET_OK;
48 }
void ST7735R_CS_Low(void)
Bring low SPI1 CS pin.
Definition: st7735r.c:26
#define ST7735R_RET_OK
Definition: st7735r.h:15
#define ST7735R_RET_FAIL
Definition: st7735r.h:16
#define ST7735R_SPI_TIMEOUT
Definition: st7735r.h:18
void ST7735R_CS_High(void)
Set SPI1 CS pin.
Definition: st7735r.c:16
SPI_HandleTypeDef * SPI_Handler
Definition: st7735r.h:266

◆ ST7735R_Write_Data()

ST7735R_Return ST7735R_Write_Data ( struct ST7735R self,
uint8_t *  data,
uint8_t  size 
)

Write data to RAM on device.

Parameters
datawhat command to write to
sizesize of data buffer
Returns
either ST7735R_RET_OK or ST7735R_RET_FAIL

Definition at line 56 of file st7735r.c.

57 {
58  HAL_GPIO_WritePin(A0_GPIO_Port, A0_Pin, GPIO_PIN_SET);
59 
61  if (HAL_SPI_Transmit(self->SPI_Handler, data, size, ST7735R_SPI_TIMEOUT) != HAL_OK)
62  {
64  return ST7735R_RET_FAIL;
65  }
67  return ST7735R_RET_OK;
68 }
void ST7735R_CS_Low(void)
Bring low SPI1 CS pin.
Definition: st7735r.c:26
#define ST7735R_RET_OK
Definition: st7735r.h:15
#define ST7735R_RET_FAIL
Definition: st7735r.h:16
#define ST7735R_SPI_TIMEOUT
Definition: st7735r.h:18
void ST7735R_CS_High(void)
Set SPI1 CS pin.
Definition: st7735r.c:16
SPI_HandleTypeDef * SPI_Handler
Definition: st7735r.h:266

Variable Documentation

◆ ST7735R_CASET_CMD

uint8_t ST7735R_CASET_CMD = 0x2A
static

CASET command.

Column address set

Returns
0x2A

Definition at line 153 of file st7735r.h.

◆ ST7735R_COLMOD_CMD

uint8_t ST7735R_COLMOD_CMD = 0x3A
static

COLMOD command.

Interface pixel format

Returns
0x3A

Definition at line 230 of file st7735r.h.

◆ ST7735R_DISPOFF_CMD

uint8_t ST7735R_DISPOFF_CMD = 0x28
static

DISPOFF command.

Display off

Returns
0x28

Definition at line 139 of file st7735r.h.

◆ ST7735R_DISPON_CMD

uint8_t ST7735R_DISPON_CMD = 0x29
static

DISPON command.

Display on

Returns
0x29

Definition at line 146 of file st7735r.h.

◆ ST7735R_GAMSET_CMD

uint8_t ST7735R_GAMSET_CMD = 0x26
static

GAMSET command.

Gamma curve select

Returns
0x26

Definition at line 132 of file st7735r.h.

◆ ST7735R_IDMOFF_CMD

uint8_t ST7735R_IDMOFF_CMD = 0x38
static

IDMOFF command.

Idle mode off

Returns
0x38

Definition at line 216 of file st7735r.h.

◆ ST7735R_IDMON_CMD

uint8_t ST7735R_IDMON_CMD = 0x39
static

IDMON command.

Idle mode on

Returns
0x39

Definition at line 223 of file st7735r.h.

◆ ST7735R_INVOFF_CMD

uint8_t ST7735R_INVOFF_CMD = 0x20
static

INVOFF command.

Display inversion off

Returns
0x20

Definition at line 118 of file st7735r.h.

◆ ST7735R_INVON_CMD

uint8_t ST7735R_INVON_CMD = 0x21
static

INVON command.

Display inversion on

Returns
0x21

Definition at line 125 of file st7735r.h.

◆ ST7735R_MADCTL_CMD

uint8_t ST7735R_MADCTL_CMD = 0x36
static

MADCTL command.

Memory data access control

Returns
0x36

Definition at line 209 of file st7735r.h.

◆ ST7735R_NOP_CMD

uint8_t ST7735R_NOP_CMD = 0x00
static

NOP command.

This command is empty command.

Returns
0x00

Definition at line 27 of file st7735r.h.

◆ ST7735R_NORON_CMD

uint8_t ST7735R_NORON_CMD = 0x13
static

NORON command.

Partial off (Normal)

Returns
0x13

Definition at line 111 of file st7735r.h.

◆ ST7735R_PTLAR_CMD

uint8_t ST7735R_PTLAR_CMD = 0x30
static

PTLAR command.

Partial start/end address set

Returns
0x30

Definition at line 188 of file st7735r.h.

◆ ST7735R_PTLON_CMD

uint8_t ST7735R_PTLON_CMD = 0x12
static

PTLON command.

Partial mode on

Returns
0x12

Definition at line 104 of file st7735r.h.

◆ ST7735R_RAMRD_CMD

uint8_t ST7735R_RAMRD_CMD = 0x2E
static

RAMRD command.

Memory read

Returns
0x2E

Definition at line 181 of file st7735r.h.

◆ ST7735R_RAMWR_CMD

uint8_t ST7735R_RAMWR_CMD = 0x2C
static

RAMWR command.

Memory write

Returns
0x2C

Definition at line 167 of file st7735r.h.

◆ ST7735R_RASET_CMD

uint8_t ST7735R_RASET_CMD = 0x2B
static

RASET command.

Row address set

Returns
0x2B

Definition at line 160 of file st7735r.h.

◆ ST7735R_RDDCOLMOD_CMD

uint8_t ST7735R_RDDCOLMOD_CMD = 0xC0
static

RDDCOLMOD command.

Read Display Pixel

Returns
0xC0

Definition at line 69 of file st7735r.h.

◆ ST7735R_RDDID_CMD

uint8_t ST7735R_RDDID_CMD = 0x04
static

RDDID command.

Read Display ID

Returns
0x04

Definition at line 41 of file st7735r.h.

◆ ST7735R_RDDIM_CMD

uint8_t ST7735R_RDDIM_CMD = 0xD0
static

RDDIM command.

Read Display Image

Returns
0xD0

Definition at line 76 of file st7735r.h.

◆ ST7735R_RDDMADCTL_CMD

uint8_t ST7735R_RDDMADCTL_CMD = 0xB0
static

RDDMADCTL command.

Read Display

Returns
0xB0

Definition at line 62 of file st7735r.h.

◆ ST7735R_RDDPM_CMD

uint8_t ST7735R_RDDPM_CMD = 0xA0
static

RDDPM command.

Read Display Power

Returns
0xA0

Definition at line 55 of file st7735r.h.

◆ ST7735R_RDDSM_CMD

uint8_t ST7735R_RDDSM_CMD = 0xE0
static

RDDSM command.

Read Display Signal

Returns
0xE0

Definition at line 83 of file st7735r.h.

◆ ST7735R_RDDST_CMD

uint8_t ST7735R_RDDST_CMD = 0x09
static

RDDST command.

Read Display Status

Returns
0x09

Definition at line 48 of file st7735r.h.

◆ ST7735R_RDID1_CMD

uint8_t ST7735R_RDID1_CMD = 0xDA
static

RDID1 command.

Read ID1

Returns
0xDA

Definition at line 237 of file st7735r.h.

◆ ST7735R_RDID2_CMD

uint8_t ST7735R_RDID2_CMD = 0xDB
static

RDID2 command.

Read ID2

Returns
0xDB

Definition at line 244 of file st7735r.h.

◆ ST7735R_RDID3_CMD

uint8_t ST7735R_RDID3_CMD = 0xDC
static

RDID3 command.

Read ID3

Returns
0xDC

Definition at line 251 of file st7735r.h.

◆ ST7735R_RGBSET_CMD

uint8_t ST7735R_RGBSET_CMD = 0x2D
static

RGBSET command.

LUT for 4k,65k,262k color

Returns
0x2D

Definition at line 174 of file st7735r.h.

◆ ST7735R_SLPIN_CMD

uint8_t ST7735R_SLPIN_CMD = 0x10
static

SLPIN command.

Sleep in & booster off

Returns
0x10

Definition at line 90 of file st7735r.h.

◆ ST7735R_SLPOUT_CMD

uint8_t ST7735R_SLPOUT_CMD = 0x11
static

SLPOUT command.

Sleep out & booster on

Returns
0x11

Definition at line 97 of file st7735r.h.

◆ ST7735R_SWRESET_CMD

uint8_t ST7735R_SWRESET_CMD = 0x01
static

SWRESET command.

Software reset

Returns
0x01

Definition at line 34 of file st7735r.h.

◆ ST7735R_TEOFF_CMD

uint8_t ST7735R_TEOFF_CMD = 0x34
static

TEOFF command.

Tearing effect line off

Returns
0x34

Definition at line 195 of file st7735r.h.

◆ ST7735R_TEON_CMD

uint8_t ST7735R_TEON_CMD = 0x35
static

TEON command.

Tearing effect mode set & on

Returns
0x35

Definition at line 202 of file st7735r.h.