microsoft/pxt-arcade

Micro:bit V2 Arcade game device support config DISPLAY_CFG0?

Opened this issue · 4 comments

Hi Sirs,
Recently, I want to DIY an arcade game console, and the MCU uses microbit v2. The screen uses st7735. As a result of my experiment, I found that there will be an offset in the screen display. I looked at the instructions and it seems that DISPLAY_CFG0 can adjust this offset. I check the library screen.cpp. If one function can fine-tune Offx & Offy, I think this issue will be solved. Not sure if it's possible?
If possible, how to do it?

Attached file is the st7735 screen offset image.
7735_border

Hello @MasonChen1003,
i have a similar issue with a display. I think you might need to create a new hardware, or if pxt-arcade is only hosted locally, you can just adjust one of the existing micro:bit arcade shields, like N3. As far as I understood, the file that then needs adjustment is here: libs/hw---n3/config.ts, I assume the following line needs to be adjusted:
export const DISPLAY_CFG0 = 0x00000080

And these comments in docs/hardware/adding.md describe the different bytes:
For the ST7735 and ILI9341 screens:

  • the low byte of CFG0 is the MADCTL register
  • the next two bytes of CFG0 are offset X and Y (if the display doesn't start at 0, 0)
  • the lowest bit of high byte of CFG0 can be set to enabled XOR of palette
  • CFG1 is FRMCTR1
  • the low byte of CFG2 is the desired SPI frequency in MHz (ignored for ILI9341)

I was not yet able to change the correct bytes, i tried to change the 4 digits left from "08".
Let me know if you have success

Hi Sir, I remember trying it a long time ago. Changing CFG0 can indeed improve this problem, but the main problem is that this parameter is on the cloud platform and you cannot modify it arbitrarily. Unless you are running a makecode arcade server on the local side. So I would recommend adding an adjustable parameter to correspond to different screen results.

Hi, thanks for the message!
Thats correct, for now I only try for debugging purposes. But somehow changing line 34 in libs/hw---n3/config.ts from:
export const DISPLAY_CFG0 = 0x00000080
to e.g.
export const DISPLAY_CFG0 = 0x00FFFF80or export const DISPLAY_CFG0 = 0x00060680
nothing changes and the pixel noise bottom and right corners stay.
Image

I think I found the reason why I didn't see any effects when adjusting these 4 bytes: The display in libs/hw---n3/config.ts is set to be a smart display by line 32 export const DISPLAY_TYPE = 4242 // smart display, when I change the setting to export const DISPLAY_TYPE = 7735 it actually works. For me setting export const DISPLAY_CFG0 = 0x00020180 did the trick. It also seemed that the two digits (8bit) after '08' are the y-Dimension and the next two bytes change the x-Dimension. Might be due to the orientation, since the display is usually used vertically.
Not sure if changing the type from smart display to ST7735 has any other unwanted side effects though.
As far as I see, a solution for the Arcade platform would be to duplicate and adapt the hw---n3 folder, just creating a derivate based on N3 hardware as e.g. Meowbit does not allow for an offset setting.

PS: for me it was necessary to have the full development setup including pxt and pxt-common packages as described in the readme /setup.cmd file.