Files
TFT_eSPI/TFT_Drivers/ILI9341_Rotation.h
T

82 lines
2.0 KiB
C
Raw Normal View History

2017-02-22 03:07:17 +00:00
// This is the command sequence that rotates the ILI9341 driver coordinate frame
rotation = m % 8; // Limit the range of values to 0-7
writecommand(TFT_MADCTL);
switch (rotation) {
case 0:
2018-02-08 00:45:18 +00:00
#ifdef M5STACK
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#else
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#endif
2018-02-24 19:02:20 +00:00
_width = _init_width;
_height = _init_height;
2017-02-22 03:07:17 +00:00
break;
case 1:
2018-02-08 00:45:18 +00:00
#ifdef M5STACK
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#else
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#endif
2018-02-24 19:02:20 +00:00
_width = _init_height;
_height = _init_width;
2017-02-22 03:07:17 +00:00
break;
case 2:
2018-02-08 00:45:18 +00:00
#ifdef M5STACK
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#else
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#endif
2018-02-24 19:02:20 +00:00
_width = _init_width;
_height = _init_height;
2017-02-22 03:07:17 +00:00
break;
case 3:
2018-02-08 00:45:18 +00:00
#ifdef M5STACK
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#else
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#endif
2018-02-24 19:02:20 +00:00
_width = _init_height;
_height = _init_width;
2017-02-22 03:07:17 +00:00
break;
2018-02-08 00:45:18 +00:00
// These next rotations are for bottom up BMP drawing
2017-02-22 03:07:17 +00:00
case 4:
2018-02-08 00:45:18 +00:00
#ifdef M5STACK
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#else
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#endif
2018-02-24 19:02:20 +00:00
_width = _init_width;
_height = _init_height;
2017-02-22 03:07:17 +00:00
break;
case 5:
2018-02-08 00:45:18 +00:00
#ifdef M5STACK
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#else
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#endif
2018-02-24 19:02:20 +00:00
_width = _init_height;
_height = _init_width;
2017-02-22 03:07:17 +00:00
break;
case 6:
2018-02-08 00:45:18 +00:00
#ifdef M5STACK
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#else
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#endif
2018-02-24 19:02:20 +00:00
_width = _init_width;
_height = _init_height;
2017-02-22 03:07:17 +00:00
break;
case 7:
2018-02-08 00:45:18 +00:00
#ifdef M5STACK
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#else
2019-10-21 22:56:35 +01:00
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
2018-02-08 00:45:18 +00:00
#endif
2018-02-24 19:02:20 +00:00
_width = _init_height;
_height = _init_width;
2017-02-22 03:07:17 +00:00
break;
}