-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholeddisplay.cpp
102 lines (85 loc) · 1.92 KB
/
oleddisplay.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
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
#pragma once
#include "oleddisplay.h"
#ifdef LCD_SSD1306
OledDisplay::OledDisplay()
{
}
void OledDisplay::update() {
}
void OledDisplay::lcd_data( unsigned char Data) {
oled.write(Data);
}
void OledDisplay::lcd_clear( void ) {
oled.clear();
}
unsigned char OledDisplay::translateLine(unsigned char Line)
{
return Line * oled.fontRows();
}
unsigned char OledDisplay::translateCol(unsigned char Col)
{
return Col * oled.fontWidth();
}
void OledDisplay::lcd_line(unsigned char Line) {
oled.setRow(translateLine(Line));
oled.setCol(0);
}
//Clear single line of display
void OledDisplay::lcd_clear_line(unsigned char Line)
{
lcd_line(Line);
oled.clearToEOL();
}
//Write probe pin number to the LCD
void OledDisplay::lcd_testpin(unsigned char Probe)
{
//Since TP1 is 0 we simply add the value to '1'
lcd_data('1' + Probe); //Send data
}
//Display a space
void OledDisplay::lcd_space(void)
{
oled.print(' ');
}
//Display a string
void OledDisplay::lcd_string(char *Str)
{
oled.print(Str);
}
//Display a fixed string stored in PROGMEM
void OledDisplay::lcd_fixed_string(const unsigned char *Str)
{
while (pgm_read_byte(Str) != 0x00)
write(pgm_read_byte(Str++));
}
void OledDisplay::print(const unsigned char *Str) {
oled.print((const String&)Str);
}
void OledDisplay::print(const char *Str) {
oled.print(Str);
}
void OledDisplay::setCursor(uint8_t col, uint8_t row)
{
oled.setCursor(translateCol(col), translateLine(row));
}
void OledDisplay::begin(uint8_t cols, uint8_t rows)
{
oled.begin(&Adafruit128x64, LCD_SSD1306_I2C_ADDRESS);
oled.clear();
setCursor(0, 0);
oled.setFont(Adafruit5x7);
}
void OledDisplay::backlight(void) {}
void OledDisplay::createChar(uint8_t location, uint8_t charmap[]) {}
size_t OledDisplay::write(uint8_t value)
{
oled.write(value);
}
void OledDisplay::home()
{
setCursor(0, 0);
}
void OledDisplay::component(uint8_t c) {
_comp = c;
}
#endif // LCD_SSD1306