-
Notifications
You must be signed in to change notification settings - Fork 4
/
ST7735_REV.cpp
73 lines (65 loc) · 1.92 KB
/
ST7735_REV.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
#include "ST7735_REV.h"
void ST7735_REV::initR(uint8_t options) {
Adafruit_ST7735::initR(options);
//tabcolor is private in parent class
tabcolor = options;
//Serial.print("SAT7735_REV.initR(): Options: ");
//Serial.println(options);
if (options == INITR_YELLOWTAB) {
//Serial.println("ST7735_REV.initR(): YELLOWTAB on");
startWrite();
writeCommand(ST77XX_MADCTL);
spiWrite(0xC0);
endWrite();
}
}
void ST7735_REV::setRotation(uint8_t m) {
Adafruit_ST7735::setRotation(m);
//Serial.print("ST7735_REV.setRotation(): ");
//Serial.println(m);
//Serial.print("ST7735_REV.setRotation() - tab Color: ");
//Serial.println(tabcolor);
uint8_t madctl = 0;
if (tabcolor == INITR_YELLOWTAB) {
//Serial.println("ST7735_REV.setRotation(): YELLOWTAB on");
switch (rotation) {
case 0:
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_RGB;
break;
case 1:
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB;
break;
case 2:
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB;
break;
case 3:
madctl = ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB;
break;
}
startWrite();
writeCommand(ST77XX_MADCTL);
spiWrite(madctl);
endWrite();
}
else if (tabcolor == INITR_YELLOWTAB_NON_REVERSED) {
Serial.println("ST7735_REV.setRotation(): YELLOWTAB_NON_REVERSED on");
switch (rotation) {
case 0:
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_RGB;
break;
case 1:
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB;
break;
case 2:
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB;
break;
case 3:
madctl = ST77XX_MADCTL_MV | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB;
break;
}
startWrite();
writeCommand(ST77XX_MADCTL);
spiWrite(madctl);
endWrite();
}
}