Describe the bug
If I want to use ILI9341 LCD (320x240), the value of img->pixLength() in updateScreen() in libs/st7735---screen/scree.cpp is 38400. But it should be 9600.
To Reproduce
Steps to reproduce the behavior:
Set LCD related parameters as follows in config.ts. (If I use parameters of ST7735, LCD works fine)
2. Add `"game": "file:../game"` to "dependencies" category of pxt.json.
3. Then from the makecode editor, I can use [Scene] category. If I use [Set background image to ()] block and download uf2 file to my board, my board blinks LED irregularly.
4. I found it entered `target_panic(PANIC_GC_TOO_BIG_ALLOCATION)`. It is because it satisfies `if (numbytes > GC_MAX_ALLOC_SIZE)` condition in `void *gcAllocate(int numbytes)` in libs/base/gc.cpp. The value of `GC_MAX_ALLOC_SIZE` is 16k while `numbytes` is 38416.
5. If I change `GC_MAX_ALLOC_SIZE` to larger value, like 64k, then this panic doesn't happen.
6. But `target_panic(PANIC_SCREEN_ERROR)` happens. Because `img->width() * mult != display->width` condition and `img->height() * mult != display->displayHeight` condition are satisfied in `updateScreen()` of libs/st7735---screen/scree.cpp.
7. Followings are related values:
_For the explanation why `img->pixLength()` should be 9600, please refer to https://github.com/lancaster-university/codal-core/pull/118. This PR is closed but I think the calculation result is correct._
display->doubleSize : 1
mult : 2
img->bpp : 4
img->width() : 320 ---> it should be 160, since actually use LCD as 160x120 resolutuion
img->height() : 240 ---> it should be 120, since actually use LCD as 160x120 resolutuion
display->width : 320
display->height : 240
img->pixLength() : 38400 ---> it should be 9600, since actually use LCD as 160x120 resolutuion
8. I think if the image buffer size is corrected, the `PANIC_GC_TOO_BIG_ALLOCATION `panic will not happen.
I think I found a way.
I can modify arguments of image.create() in pxt-common-packages\libs\screen---st7735\targetoverrides.ts to fix image size to 160x128 or 160x120.
I will close this issue.
Describe the bug If I want to use ILI9341 LCD (320x240), the value of
img->pixLength()
inupdateScreen()
in libs/st7735---screen/scree.cpp is 38400. But it should be 9600.To Reproduce Steps to reproduce the behavior:
export const DISPLAY_TYPE = 9341 export const DISPLAY_WIDTH = 320 export const DISPLAY_HEIGHT = 240 export const DISPLAY_CFG0 = 0x08 export const DISPLAY_CFG1 = 0x0010ff export const DISPLAY_CFG2 = 50
display->doubleSize : 1 mult : 2 img->bpp : 4 img->width() : 320 ---> it should be 160, since actually use LCD as 160x120 resolutuion img->height() : 240 ---> it should be 120, since actually use LCD as 160x120 resolutuion display->width : 320 display->height : 240 img->pixLength() : 38400 ---> it should be 9600, since actually use LCD as 160x120 resolutuion