-
Notifications
You must be signed in to change notification settings - Fork 0
/
LCDWIKI_SPI.h
99 lines (90 loc) · 3.09 KB
/
LCDWIKI_SPI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Lcdwiki GUI library with init code from Rossum
// MIT license
#ifndef _LCDWIKI_SPI_H_
#define _LCDWIKI_SPI_H_
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#ifdef __AVR__
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#else
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#endif
#include "LCDWIKI_GUI.h"
// LCD controller chip identifiers
#define ID_932X 0
#define ID_7575 1
#define ID_9341 2
#define ID_HX8357D 3
#define ID_4535 4
#define ID_9486 5
#define ID_7735 6
#define ID_1283A 7
#define ID_UNKNOWN 0xFF
//LCD controller chip mode identifiers
#define ILI9325 0
#define ILI9328 1
#define ILI9341 2
#define HX8357D 3
#define HX8347G 4
#define HX8347I 5
#define ILI9486 6
#define ST7735S 7
#define SSD1283A 8
typedef struct _lcd_info
{
uint16_t lcd_id;
int16_t lcd_wid;
int16_t lcd_heg;
}lcd_info;
class LCDWIKI_SPI:public LCDWIKI_GUI
{
public:
LCDWIKI_SPI(uint16_t model,int8_t cs, int8_t cd, int8_t miso, int8_t mosi, int8_t reset, int8_t clk, int8_t led);
LCDWIKI_SPI(uint16_t model,int8_t cs, int8_t cd, int8_t reset,int8_t led);
LCDWIKI_SPI(int16_t wid,int16_t heg,int8_t cs, int8_t cd, int8_t miso, int8_t mosi, int8_t reset, int8_t clk,int8_t led);
LCDWIKI_SPI(int16_t wid,int16_t heg,int8_t cs, int8_t cd, int8_t reset,int8_t led);
void Init_LCD(void);
void reset(void);
void start(uint16_t ID);
void Draw_Pixe(int16_t x, int16_t y, uint16_t color);
void Spi_Write(uint8_t data);
uint8_t Spi_Read(void);
void Write_Cmd(uint16_t cmd);
void Write_Data(uint16_t data);
void Write_Cmd_Data(uint16_t cmd, uint16_t data);
void init_table8(const void *table, int16_t size);
void init_table16(const void *table, int16_t size);
void Push_Command(uint8_t cmd, uint8_t *block, int8_t N);
uint16_t Color_To_565(uint8_t r, uint8_t g, uint8_t b);
uint16_t Read_ID(void);
void Fill_Rect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void Set_Rotation(uint8_t r);
uint8_t Get_Rotation(void) const;
void Invert_Display(boolean i);
uint16_t Read_Reg(uint16_t reg, int8_t index);
int16_t Read_GRAM(int16_t x, int16_t y, uint16_t *block, int16_t w, int16_t h);
void Set_Addr_Window(int16_t x1, int16_t y1, int16_t x2, int16_t y2);
void Push_Any_Color(uint16_t * block, int16_t n, bool first, uint8_t flags);
void Push_Any_Color(uint8_t * block, int16_t n, bool first, uint8_t flags);
void Vert_Scroll(int16_t top, int16_t scrollines, int16_t offset);
int16_t Get_Height(void) const;
int16_t Get_Width(void) const;
void Set_LR(void);
void Led_control(boolean i);
protected:
uint16_t WIDTH,HEIGHT,width, height, rotation,lcd_driver,lcd_model;
boolean hw_spi;
private:
uint16_t XC,YC,CC,RC,SC1,SC2,MD,VL,R24BIT;
volatile uint8_t *spicsPort, *spicdPort, *spimisoPort , *spimosiPort, *spiclkPort;
uint8_t spicsPinSet, spicdPinSet ,spimisoPinSet , spimosiPinSet , spiclkPinSet,
spicsPinUnset, spicdPinUnset, spimisoPinUnset, spimosiPinUnset,spiclkPinUnset;
int8_t _cs,_cd,_miso,_mosi,_clk,_reset,_led;
};
#endif