-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwepdl.h
154 lines (122 loc) · 6.22 KB
/
wepdl.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// =====================================================================================================================
//
// File : wepdl.h
// Tested on : Arduino-IDE (1.8.2 & 1.9.0 Beta31), Arduino Uno/Nano; Lolin Nodemcu v3, Wemos d1 mini
// Version : 0.0.3
// Created by : Tadeusz Miszczyk (tadeusz.miszczyk[at]gmail.com)
// Library : https://github.com/8tm/wepdl
// Wiki : https://github.com/8tm/wepdl/wiki
// Last changes : 2019-11-06
//
// =====================================================================================================================
#ifndef WEPDL_H
#define WEPDL_H
#include <Arduino.h>
#include <SoftwareSerial.h>
// Memory
#define FLASH 0
#define MICROSD 1
// Screen rotation
#define HORIZONTAL 0
#define VERTICAL 1
// Languages
#define ENGLISH 0x1E
#define CHINESE 0x1F
// Font sizes
#define SIZE32 0x01
#define SIZE48 0x02
#define SIZE64 0x03
// Colors
#define BLACK 0x00
#define DARK 0x01
#define LIGHT 0x02
#define WHITE 0x03
//----------------------------------------------------------------------------------------------------------------------
class wepdl
{
private :
uint8_t _wake_up,
_reset;
unsigned char _global_color,
_global_background_color,
_cmd_buff[512];
const unsigned char _cmd_handshake[8] = { 0xA5, 0x00, 0x09, 0x00, 0xCC, 0x33, 0xC3, 0x3C },
_cmd_read_baud[8] = { 0xA5, 0x00, 0x09, 0x02, 0xCC, 0x33, 0xC3, 0x3C },
_cmd_stopmode[8] = { 0xA5, 0x00, 0x09, 0x08, 0xCC, 0x33, 0xC3, 0x3C },
_cmd_update[8] = { 0xA5, 0x00, 0x09, 0x0A, 0xCC, 0x33, 0xC3, 0x3C },
_cmd_load_font[8] = { 0xA5, 0x00, 0x09, 0x0E, 0xCC, 0x33, 0xC3, 0x3C },
_cmd_load_pic[8] = { 0xA5, 0x00, 0x09, 0x0F, 0xCC, 0x33, 0xC3, 0x3C };
void _putchars ( const unsigned char * ptr, int n);
unsigned char _verify( const void * ptr, int n);
public :
wepdl ( uint8_t rx,
uint8_t tx,
uint8_t wake_up,
uint8_t reset );
SoftwareSerial *SoftSerial;
// ------------- D E V I C E -------------------------------------------------------------------------------------------
void initialize ( void );
void goSleep ( void );
void handShake ( void );
void reset ( void );
void wakeUp ( void );
void readBaud ( void );
// ------------- S C R E E N -------------------------------------------------------------------------------------------
void clearScreen ( void );
void rotateScreen ( unsigned char mode );
void updateScreen ( void );
// ------------- S E T -------------------------------------------------------------------------------------------------
void setBaud ( long baud );
void setColor ( unsigned char color,
unsigned char background_color,
bool global_color = true );
void setFont ( unsigned char font,
unsigned char language = ENGLISH );
void setMemory ( unsigned char mode );
// ------------- D I S P L A Y -----------------------------------------------------------------------------------------
void displayBitmap ( int x,
int y,
const void * p );
void displayCharacter( int x,
int y,
unsigned char ch );
void displayText ( int x,
int y,
const void * p );
// ------------- I M A G E S -------------------------------------------------------------------------------------------
void Picture ( void );
// ------------- ? ? ? ? -----------------------------------------------------------------------------------------------
void FontLoad ( void );
// ------------- D R A W -----------------------------------------------------------------------------------------------
void drawPixel ( int x,
int y );
void drawLine ( int A_x,
int A_y,
int B_x,
int B_y,
int thickness = 1 );
void drawCircle ( int x,
int y,
int radius,
bool fill = false );
void drawRing ( int x,
int y,
int radius,
int border,
unsigned char color,
unsigned char background_color );
void drawTriangle ( int A_x,
int A_y,
int B_x,
int B_y,
int C_x,
int C_y,
bool fill = false );
void drawRectangle ( int A_x,
int A_y,
int C_x,
int C_y,
bool fill = false );
};
//----------------------------------------------------------------------------------------------------------------------
#endif