Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 6:c964b41674fc, committed 2015-11-22
- Comitter:
- SomeRandomBloke
- Date:
- Sun Nov 22 15:59:30 2015 +0000
- Parent:
- 5:9c04464cd1b4
- Child:
- 7:856a3443f68d
- Commit message:
- Updated setRotation to correct colour problem when rotating display
Changed in this revision
| Adafruit_ST7735.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Adafruit_ST7735.cpp Sun Nov 22 13:15:07 2015 +0000
+++ b/Adafruit_ST7735.cpp Sun Nov 22 15:59:30 2015 +0000
@@ -414,36 +414,70 @@
#define MADCTL_MX 0x40
#define MADCTL_MV 0x20
#define MADCTL_ML 0x10
-#define MADCTL_RGB 0x08
+#define MADCTL_RGB 0x00
+#define MADCTL_BGR 0x08
#define MADCTL_MH 0x04
-void Adafruit_ST7735::setRotation(uint8_t m)
-{
+void Adafruit_ST7735::setRotation(uint8_t m) {
+
+ writecommand(ST7735_MADCTL);
+ rotation = m % 4; // can't be higher than 3
+ switch (rotation) {
+ case 0:
+ if (tabcolor == INITR_BLACKTAB) {
+ writedata(MADCTL_MX | MADCTL_MY | MADCTL_RGB);
+ } else {
+ writedata(MADCTL_MX | MADCTL_MY | MADCTL_BGR);
+ }
+ _width = ST7735_TFTWIDTH;
+
+ if (tabcolor == INITR_144GREENTAB)
+ _height = ST7735_TFTHEIGHT_144;
+ else
+ _height = ST7735_TFTHEIGHT_18;
+
+ break;
+ case 1:
+ if (tabcolor == INITR_BLACKTAB) {
+ writedata(MADCTL_MY | MADCTL_MV | MADCTL_RGB);
+ } else {
+ writedata(MADCTL_MY | MADCTL_MV | MADCTL_BGR);
+ }
- writecommand(ST7735_MADCTL);
- rotation = m % 4; // can't be higher than 3
- switch (rotation) {
- case 0:
- writedata(MADCTL_MX | MADCTL_MY | MADCTL_RGB);
- _width = ST7735_TFTWIDTH;
- _height = ST7735_TFTHEIGHT;
- break;
- case 1:
- writedata(MADCTL_MY | MADCTL_MV | MADCTL_RGB);
- _width = ST7735_TFTHEIGHT;
- _height = ST7735_TFTWIDTH;
- break;
- case 2:
- writedata(MADCTL_RGB);
- _width = ST7735_TFTWIDTH;
- _height = ST7735_TFTHEIGHT;
- break;
- case 3:
- writedata(MADCTL_MX | MADCTL_MV | MADCTL_RGB);
- _width = ST7735_TFTHEIGHT;
- _height = ST7735_TFTWIDTH;
- break;
- }
+ if (tabcolor == INITR_144GREENTAB)
+ _width = ST7735_TFTHEIGHT_144;
+ else
+ _width = ST7735_TFTHEIGHT_18;
+
+ _height = ST7735_TFTWIDTH;
+ break;
+ case 2:
+ if (tabcolor == INITR_BLACKTAB) {
+ writedata(MADCTL_RGB);
+ } else {
+ writedata(MADCTL_BGR);
+ }
+ _width = ST7735_TFTWIDTH;
+ if (tabcolor == INITR_144GREENTAB)
+ _height = ST7735_TFTHEIGHT_144;
+ else
+ _height = ST7735_TFTHEIGHT_18;
+
+ break;
+ case 3:
+ if (tabcolor == INITR_BLACKTAB) {
+ writedata(MADCTL_MX | MADCTL_MV | MADCTL_RGB);
+ } else {
+ writedata(MADCTL_MX | MADCTL_MV | MADCTL_BGR);
+ }
+ if (tabcolor == INITR_144GREENTAB)
+ _width = ST7735_TFTHEIGHT_144;
+ else
+ _width = ST7735_TFTHEIGHT_18;
+
+ _height = ST7735_TFTWIDTH;
+ break;
+ }
}