-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodlcd.cpp
74 lines (66 loc) · 2.08 KB
/
modlcd.cpp
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
#include "modlcd.h"
Lcd::Lcd(byte rs,byte en,byte d4,byte d5,byte d6,byte d7) {
this->rs = rs;
this->en = en;
this->d4 = d4;
this->d5 = d5;
this->d6 = d6;
this->d7 = d7;
this->error_flag = false;
}
LiquidCrystal Lcd::init(int col, int row)
{
this->lcd_col = col;
this->lcd_row = row;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
lcd.begin(this->lcd_col,this->lcd_row);
return lcd;
}
void Lcd::writeRow(LiquidCrystal l, int col , int row, String data){
l.setCursor(0,row);
l<<" ";
l.setCursor(col,row);
l<<data;
this->debug_msg = __func__;
}
void Lcd::writeString(LiquidCrystal l, int col, int row, String cdata){
int data_length = cdata.length();
String space = " ";
String str;
for(int i = 0; i < data_length; i++){
str+= space;
}
l.setCursor(col,row);
l<<str;
l.setCursor(col,row);
l<<cdata;
this->debug_msg = __func__;
}
void Lcd::welcome(LiquidCrystal l)
{
l.clear();
this->writeRow(l,1,0,"LCD Library module");
this->writeRow(l,5,1,"OOP Design");
this->writeRow(l,8,2,"BY");
this->writeRow(l,3,3,"Bonolo K Nyoni");
this->debug_msg =__func__;
}
void Lcd::scrollText(LiquidCrystal l, int col , int row, String sdata){
int ldata = sdata.length();
l.setCursor(col,row);
while(true){
int screenText = col+ldata;
this->writeString(l,col,row,sdata);
delay(200);
l.clear();
col = col + 1;
if(screenText >= this->lcd_col){
row = row + 1;
col = 0;
}
if(row > ( this->lcd_row -1)){
col = 0;
row = 0;
}
}
}