MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / rotateBuffer

Function rotateBuffer

ESP32_AP-Flasher/src/contentmanager.cpp:2851–2879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2849}
2850
2851void rotateBuffer(uint8_t rotation, uint8_t &currentOrientation, TFT_eSprite &spr, imgParam &imageParams) {
2852 rotation = rotation % 4; // First of all, let's be sure that the rotation have a valid value (0, 1, 2 or 3)
2853 if (rotation != currentOrientation) { // If we have a rotation to do, let's do it
2854 int stepToDo = (currentOrientation - rotation + 4) % 4;
2855 // 2: upside down
2856 // 3: 270° rotation
2857 // 1: 90° rotation
2858
2859 if (abs(stepToDo) == 2) { // If we have to do a 180° rotation:
2860 TFT_eSprite sprCpy = TFT_eSprite(&tft); // We create a new sprite that will act as a buffer
2861 initSprite(sprCpy, spr.width(), spr.height(), imageParams); // initialisation of the new sprite
2862 spr.pushRotated(&sprCpy, 180, TFT_WHITE); // We fill the new sprite with the old one rotated by 180°
2863 spr.fillSprite(TFT_WHITE); // We fill the old one in white as anything that's white will be ignored by the pushRotated function
2864 sprCpy.pushRotated(&spr, 0, TFT_WHITE); // We copy the buffer sprite to the main one
2865 sprCpy.deleteSprite(); // We delete the buffer sprite to avoid memory leak
2866 } else {
2867 int angle = (stepToDo == 3) ? 270 : 90;
2868 TFT_eSprite sprCpy = TFT_eSprite(&tft);
2869 initSprite(sprCpy, spr.height(), spr.width(), imageParams);
2870 spr.pushRotated(&sprCpy, angle, TFT_WHITE);
2871 spr.deleteSprite();
2872 initSprite(spr, sprCpy.width(), sprCpy.height(), imageParams);
2873 sprCpy.pushToSprite(&spr, 0, 0);
2874 sprCpy.deleteSprite();
2875 imageParams.rotatebuffer = 1 - (imageParams.rotatebuffer % 2);
2876 }
2877 currentOrientation = rotation;
2878 }
2879}
2880
2881TFT_eSprite sprDraw = TFT_eSprite(&tft);
2882bool spr_draw(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap) {

Callers 1

drawElementFunction · 0.85

Calls 3

initSpriteFunction · 0.85
widthMethod · 0.80
heightMethod · 0.80

Tested by

no test coverage detected