lovyan03 / LovyanGFX

SPI LCD graphics library for ESP32 (ESP-IDF/ArduinoESP32) / ESP8266 (ArduinoESP8266) / SAMD51(Seeed ArduinoSAMD51)
Other
1.03k stars 189 forks source link

setSwapBytes issue. cut top row pixels? #485

Closed lefty01 closed 5 months ago

lefty01 commented 5 months ago

not sure if this is a bug or some usage/config error but I really do not currently understand this ...

Environment

platform = espressif32 board = esp32dev framework = arduino

Problem Description ( 問題の内容 )

using Sprites and pushImage to sprite (see example code below) to get the color right need to use swapBytes. the two images are 50x50 pixle rectangle with solid colors (blue-ish and purple-ish color created in gimp and converted online to c-array) with setSwapBytes(false) colors are not correctly displayed but the position / dimension is ok. when setSwapBytes(true) (I toggle via button to show the effect) then the top pixel row or rows (not sure how many pixel) gets "cleared" out. You can see in the images that with swap=false the color is like red/orange and the vert red lines go to top. when swap=true color is blue/purple and you see lines and top-left blue rectangle are reduced.

Expected Behavior ( 期待される動作 )

toggle swapBytes shall change color only not remove pixels from top of tft screen.

Actual Behavior ( 実際の動作 )

row of pixels not show on top of screen

Steps to reproduce ( 再現のための前提条件 )

load code below, I

// If possible, attach a picture of your setup/wiring here. 20231206_205159 20231206_205201

Code to reproduce this issue ( 再現させるためのコード )

Please submit complete source code that can reproduce your problem. あなたの問題を再現できる完全なソースコードを提示してください。

https://gist.github.com/lefty01/9ff3d09073d182cd136f68f9564fdced

lovyan03 commented 5 months ago

あなたのデータは4ピクセル足りないように見える。

あなたが想定しているデータサイズは 50×50 = 2500 pixel 実際に配列に入っているデータサイズは 16 × 156 = 2496 pixel

4ピクセル足りないのはあなたのデータが足りないからだと思います。

lefty01 commented 5 months ago

thanks for your fast response and the hint to the number of pixels. now when experimenting further I noticed that without changing (or fixing) the actual image data array, when I add tft.setRotation(1); also to the loop() then this again behaves as expected. that means I do need setRotation in setup (if createSprite is done in setup()) and loop()

I need to learn how does tft.setRotation effect the sprite(s)

lovyan03 commented 5 months ago

問題の再現に必要のないコードを削除し、最小限のコードを提示してください。 Tickerとは何ですか。Buttonの実装はどこにありますか。 余計なことに時間を使わせないでください。

lovyan03 commented 5 months ago

tft.startWrite(); の記述を削除して試してください。意味がわからないならstartWriteを使わないでください。

lefty01 commented 5 months ago

それを削除しましたが、機能します。

はい、確かに、疑問符を付けたので、事前に確認する必要がありました

I removed it, and it works. Yes indeed I should have checked that before since I even marked with questionmark. Sorry.

lovyan03 commented 5 months ago

As an additional note, when startWrite is used, LovyanGFX occupies the SPI bus and operates.

If startWrite is not used, each function will not proceed until SPI communication is complete.

When startWrite is used, each function does not wait for SPI communication to complete before proceeding. In other words, the DMA transfer communication is executed in the background.

For this reason, fillSprite(TFT_WHITE); rewrites the data being transferred.

The sample code should have displayed the image well by using two sprites alternately, but your code uses only one sprite, which rewrites the data being transferred, resulting in an incomplete image.

lefty01 commented 5 months ago

now the MovingCircles example makes more sense (flipping beween those two sprites)