diff --git a/src/HT_E0213A367.h b/src/HT_E0213A367.h index f72de67..3d110a6 100644 --- a/src/HT_E0213A367.h +++ b/src/HT_E0213A367.h @@ -89,14 +89,52 @@ class HT_E0213A367 : public ScreenDisplay setPartialRamArea(0,0,128, 250); sendCommand(0x24); - for(int x=0; x<250; x++) + + if (rotate_angle == ANGLE_0_DEGREE) + { + for(int x=0; x<250; x++) + { + for (int y = 15; y >= 0; y--) + { + if (y == 0) + sendData(~(buffer[x + y * 256] << 6)); + else + sendData(~((buffer[x + y * 256] << 6) | (buffer[x + (y - 1) * 256] >> 2))); + } + } + } + else if (rotate_angle == ANGLE_180_DEGREE) + { + for(int x = 249; x >= 0; x--) + { + for (int y = 0; y < 16; y++) + { + uint8_t byte_data; + if (y == 15) + byte_data = buffer[x + y * 256] >> 2; + else + byte_data = (buffer[x + y * 256] >> 2) | (buffer[x + (y + 1) * 256] << 6); + + uint8_t reversed = 0; + for (int bit = 0; bit < 8; bit++) { + reversed |= ((byte_data >> bit) & 1) << (7 - bit); + } + + sendData(~reversed); + } + } + } + else { - for (int y = 15; y >= 0; y--) + for(int x=0; x<250; x++) { - if (y == 0) - sendData(~(buffer[x + y * 256] << 6)); - else - sendData(~((buffer[x + y * 256] << 6) | (buffer[x + (y - 1) * 256] >> 2))); + for (int y = 15; y >= 0; y--) + { + if (y == 0) + sendData(~(buffer[x + y * 256] << 6)); + else + sendData(~((buffer[x + y * 256] << 6) | (buffer[x + (y - 1) * 256] >> 2))); + } } } } diff --git a/src/HT_lCMEN2R13EFC1.h b/src/HT_lCMEN2R13EFC1.h index 65e00e5..2246e41 100644 --- a/src/HT_lCMEN2R13EFC1.h +++ b/src/HT_lCMEN2R13EFC1.h @@ -118,27 +118,22 @@ class HT_ICMEN2R13EFC1 : public ScreenDisplay } else { - fSPI.beginTransaction(SPISettings(6000000, MSBFIRST, SPI_MODE0)); + fSPI.beginTransaction(SPISettings(6000000, LSBFIRST, SPI_MODE0)); for (int x = 250 - 1; x >= 0; x--) { for (int y = (ymax - 1); y >= 0; y--) { // if(addr==0x24) - if (addr == 0x13) - - { - if (y == 0) - fSPI.transfer(~(buffer[x + y * xmax] << 6)); - else - fSPI.transfer(~((buffer[x + y * xmax] << 6) | (buffer[x + (y - 1) * xmax] >> 2))); + uint8_t byte_data = buffer[x + y * xmax]; + uint8_t reversed_byte = 0; + for (int bit = 0; bit < 8; bit++) { + reversed_byte |= ((byte_data >> bit) & 1) << (7 - bit); } + + if (addr == 0x13) + fSPI.transfer(~reversed_byte); else - { - if (y == 0) - fSPI.transfer(buffer[x + y * xmax] << 6); - else - fSPI.transfer((buffer[x + y * xmax] << 6) | (buffer[x + (y - 1) * xmax] >> 2)); - } + fSPI.transfer(reversed_byte); } } }