You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
4.5 KiB

9 months ago
  1. // This is the command sequence that rotates the ST7735 driver coordinate frame
  2. rotation = m % 4; // Limit the range of values to 0-3
  3. writecommand(TFT_MADCTL);
  4. switch (rotation) {
  5. case 0:
  6. if (tabcolor == INITR_BLACKTAB) {
  7. writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
  8. } else if(tabcolor == INITR_GREENTAB2) {
  9. writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
  10. colstart = 2;
  11. rowstart = 1;
  12. } else if(tabcolor == INITR_GREENTAB3) {
  13. writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
  14. colstart = 2;
  15. rowstart = 3;
  16. } else if(tabcolor == INITR_GREENTAB128) {
  17. writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_COLOR_ORDER);
  18. colstart = 0;
  19. rowstart = 32;
  20. } else if(tabcolor == INITR_GREENTAB160x80) {
  21. writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_COLOR_ORDER);
  22. colstart = 26;
  23. rowstart = 1;
  24. } else if(tabcolor == INITR_REDTAB160x80) {
  25. writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_COLOR_ORDER);
  26. colstart = 24;
  27. rowstart = 0;
  28. } else if(tabcolor == INITB) {
  29. writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
  30. } else {
  31. writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
  32. }
  33. _width = _init_width;
  34. _height = _init_height;
  35. break;
  36. case 1:
  37. if (tabcolor == INITR_BLACKTAB) {
  38. writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  39. } else if(tabcolor == INITR_GREENTAB2) {
  40. writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  41. colstart = 1;
  42. rowstart = 2;
  43. } else if(tabcolor == INITR_GREENTAB3) {
  44. writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  45. colstart = 3;
  46. rowstart = 2;
  47. } else if(tabcolor == INITR_GREENTAB128) {
  48. writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
  49. colstart = 32;
  50. rowstart = 0;
  51. } else if(tabcolor == INITR_GREENTAB160x80) {
  52. writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
  53. colstart = 1;
  54. rowstart = 26;
  55. } else if(tabcolor == INITR_REDTAB160x80) {
  56. writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
  57. colstart = 0;
  58. rowstart = 24;
  59. } else if(tabcolor == INITB) {
  60. writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
  61. } else {
  62. writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  63. }
  64. _width = _init_height;
  65. _height = _init_width;
  66. break;
  67. case 2:
  68. if (tabcolor == INITR_BLACKTAB) {
  69. writedata(TFT_MAD_COLOR_ORDER);
  70. } else if(tabcolor == INITR_GREENTAB2) {
  71. writedata(TFT_MAD_COLOR_ORDER);
  72. colstart = 2;
  73. rowstart = 1;
  74. } else if(tabcolor == INITR_GREENTAB3) {
  75. writedata(TFT_MAD_COLOR_ORDER);
  76. colstart = 2;
  77. rowstart = 1;
  78. } else if(tabcolor == INITR_GREENTAB128) {
  79. writedata(TFT_MAD_COLOR_ORDER);
  80. colstart = 0;
  81. rowstart = 0;
  82. } else if(tabcolor == INITR_GREENTAB160x80) {
  83. writedata(TFT_MAD_COLOR_ORDER);
  84. colstart = 26;
  85. rowstart = 1;
  86. } else if(tabcolor == INITR_REDTAB160x80) {
  87. writedata(TFT_MAD_COLOR_ORDER);
  88. colstart = 24;
  89. rowstart = 0;
  90. } else if(tabcolor == INITB) {
  91. writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
  92. } else {
  93. writedata(TFT_MAD_COLOR_ORDER);
  94. }
  95. _width = _init_width;
  96. _height = _init_height;
  97. break;
  98. case 3:
  99. if (tabcolor == INITR_BLACKTAB) {
  100. writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  101. } else if(tabcolor == INITR_GREENTAB2) {
  102. writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  103. colstart = 1;
  104. rowstart = 2;
  105. } else if(tabcolor == INITR_GREENTAB3) {
  106. writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  107. colstart = 1;
  108. rowstart = 2;
  109. } else if(tabcolor == INITR_GREENTAB128) {
  110. writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  111. colstart = 0;
  112. rowstart = 0;
  113. } else if(tabcolor == INITR_GREENTAB160x80) {
  114. writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  115. colstart = 1;
  116. rowstart = 26;
  117. } else if(tabcolor == INITR_REDTAB160x80) {
  118. writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  119. colstart = 0;
  120. rowstart = 24;
  121. } else if(tabcolor == INITB) {
  122. writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  123. } else {
  124. writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
  125. }
  126. _width = _init_height;
  127. _height = _init_width;
  128. break;
  129. }