-
Notifications
You must be signed in to change notification settings - Fork 0
/
nhdlcd.hpp
85 lines (80 loc) · 1.83 KB
/
nhdlcd.hpp
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
#pragma once
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
enum class Command : unsigned char {
DisplayOn,
DisplayOff,
SetCursor /* takes param */
,
CursorHome,
UnderlineCursorOn,
UnderlineCursorOff,
MoveCursorLeftOnePlace,
MoveCursorRightOnePlace,
BlinkingCursorOn,
BlinkingCursorOff,
Backspace,
ClearScreen,
SetContrast /* takes param */
,
SetBacklightBrightness /* takes param */
,
LoadCustomCharacter /* takes params */
,
MoveDisplayLeftOnePlace,
MoveDisplayRightOnePlace,
ChangeRS232BaudRate,
ChangeI2CAddress,
DisplayFirmwareVersionNumber,
DisplayRS232BaudRate,
DisplayI2CAddress
};
class nhdlcd {
typedef const unsigned char pin_t;
private:
pin_t data;
pin_t clock;
pin_t slaveSelect;
public:
/**
* Create a LCD serial communication object on specified pins.
* Automatically calls setup() for you.
* @param data pin
* @param clock pin
* @param slave select pin
*/
nhdlcd(pin_t, pin_t, pin_t);
/**
* Explicitly called this function to set the pin modes.
*/
void setup();
/**
* Write a character to the LCD, using the specified bit order.
* MSB first by default.
* @param character to write to LCD
* @param bit order to use when writing
*/
void write(unsigned char, int = MSBFIRST);
/**
* Write command to the LCD.
* It is the programmer's responsibility that the command works without an
* argument.
* @param command to send to LCD
*/
void write(Command);
/**
* Write command to the LCD.
* Command will always write at least one argument to the LCD.
* @param command to send to LCD
* @param arguments for the command
*/
void write(Command, int...);
/**
* Write string to the LCD.
* @param c-style string to write to LCD
*/
void write(const char *);
};