-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathliquidcrystal.cpp
More file actions
70 lines (56 loc) · 1.62 KB
/
liquidcrystal.cpp
File metadata and controls
70 lines (56 loc) · 1.62 KB
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
#include <stdint.h>
#include <util/delay.h>
#include "liquidcrystal.hpp"
#include "IO.hpp"
namespace liquidcrystal{
Liquidcrystal& Liquidcrystal::init(uint8_t cols, uint8_t line){
this->lcd_type->set_pins();
this->_line = line;
this->_cols = cols;
//inicia o modo de 4bits
this->config(0X3);
_delay_ms(5);
this->config(0X3);
_delay_us(160);
this->config(0X3);//ESTADO DA COMUNICAÇÃO É 8BITS
_delay_us(160);
this->config(0x2);
_delay_ms(10);
//confg do display
config(0x28);
config(0x0C);
config(0x01);
_delay_us(15);
return *this;
}
Liquidcrystal& Liquidcrystal::write(char value){
this->lcd_type->send(value, true);
_delay_us(80);
return *this;
}
Liquidcrystal& Liquidcrystal::write(int value){
unsigned long int i = 10000;
while(i>0){
this->write((char)((value/i) % 10 + 48));
i /= 10;
}
return *this;
}
Liquidcrystal& Liquidcrystal::write(String value){
for(uint16_t i = 0; value[i] != '\0'; i++){
this->write(value[i]);
}
return *this;
}
Liquidcrystal& Liquidcrystal::config(uint8_t flag){
this->lcd_type->send(flag, false);
_delay_ms(2);
return *this;
}
Liquidcrystal& Liquidcrystal::set_cursor(uint8_t line, uint8_t cols){
if(this->_line > line || this->_cols >= cols){
this->lcd_type->set_cursor(line, cols);
}
return *this;
}
}