Closed barabanus closed 4 years ago
Lcd not support pixel read because spi bus read pixel is very troublesome try apply a buffer to flash all the screen,like Sprite https://github.com/m5stack/M5Stack/blob/master/examples/Advanced/Display/Sprite/Sprite_scroll_16bit/Sprite_scroll_16bit.ino TFT_eSprite also effective on StickC lib, but sorry, there are currently no examples
@EeeeBin Thank you, I did exactly like you said and it worked!
I replaced all my calls to M5.Lcd
to LCD::canvas
which has the same interface. Obviously, it takes a lot of memory for double buffer and 8 ms to copy buffer onto LCD.
namespace LCD {
TFT_eSprite canvas = TFT_eSprite(&M5.Lcd);
constexpr uint8_t RIGHT_TO_LEFT = 1;
constexpr uint8_t LEFT_TO_RIGHT = 3;
uint8_t orientation = LEFT_TO_RIGHT;
void setup()
{
// set landscape orientation
canvas.createSprite(TFT_HEIGHT, TFT_WIDTH);
canvas.setRotation(3);
M5.Lcd.setRotation(3);
}
template <typename T>
void update(T accel_x)
{
uint8_t target = (accel_x > 0) ? RIGHT_TO_LEFT : LEFT_TO_RIGHT;
if (accel_x != 0 && target != orientation) {
canvas.setRotation(target);
M5.Lcd.setRotation(target);
orientation = target;
}
canvas.pushSprite(0, 0);
}
}
ReadPixel(), readRect() and readRectRGB() doesn't return real pixel values from LCD.
For example (for black and white pixels on the screen):
This routine prints blank output though in reality display has a lot of white pixels printed on black background.
I would like to implement auto LCD orientation update so I need to get full dump of display pixels. BTW I suggest you to consider this functionality within
M5.update()
routine.