StarGate01 / p8b-infinitime

Run InfiniTime & Bootloader on the P8 smartwatch
MIT License
20 stars 2 forks source link

P8B Display Flipped #3

Closed izzeho closed 2 years ago

izzeho commented 2 years ago

Have flashed your zip as I'm not sure the state of the PRs into the standard Infinitime release. I believe I have a p8b based on magnetic charger. Ordered recently from Aliexpress and the stock firmware worked okay.

Everything seems to be working except ... the display is flipped left-to-right. Same behaviour was seen in the bootloader.

20220622_204727

I don't see anything immediately obvious for build options or config. The touchscreen interactions aren't flipped. Before I start digging in driver code, do you have any suggestions?

StarGate01 commented 2 years ago

Oh wow, that is a new one :D Where did you buy that one? I am interested in collecting more variants.

What was your firmware identification string? E.g. something like MOY-TFK5-1.7.7 .

As for fixing this, I think the display controller itself has an option/register to flip the display. I am not sure weather the driver exposes this function. Maybe LVGL has a function to mirror everything in software as well.

Is your touch flipped as well? Does it align with the display content?

I'm not sure the state of the PRs into the standard Infinitime release

Upstreaming is still in progress and will take quite some time still.

izzeho commented 2 years ago

Touch is not flipped. I didn't take note of the firmware string before trying to flash wasp-os (also was flipped). I'll start having a dig through LVGL and the display driver.

This was the model purchased: https://www.aliexpress.com/item/4000557708951.html

StarGate01 commented 2 years ago

I see. So your touch inputs don't line up with the elements on the display you want to tap?

I guess the manufacturer decided to mount the LCD in reverse, or used a slightly different model.

izzeho commented 2 years ago

I couldn't find anything in LVGL to flip, only rotate. Setting MX bit in MADCTL register fixes the display

void St7789::MemoryDataAccessControl() { WriteCommand(static_cast<uint8_t>(Commands::MemoryDataAccessControl)); WriteData(0x40); // MY(0) MX(1) MV(0) ML(0) RGB(0) 0 0 0 }

in St7789 header. Uploading the firmware, it shows correct for about 10 seconds before reverting back to the bootloader. More digging for another day.

I'm at a loss how I have a flipped screen, seems like a very strange sku change. Unless they have a bad production run and worked around it?

StarGate01 commented 2 years ago

Good find! I ordered one of these watches. I will add support for the register config once I can reproduce and debug the issue.

The 10 second reboot is probably triggered by the watchdog, indicating a hard error lockup .

izzeho commented 2 years ago

Built from clean 1.9.0.2 source and it is now working and (seemingly) stable. I'm surprised how precise and responsive the touchscreen is. The stock firmware was nowhere near this reliable (for the 15 minutes I played with it).

Accelerometer works, heart rate works, time and gadgetbridge sync works. The step counter doesn't work.

I'm not really sure the best way to incorporate this. There's no real way to detect screen flip, so compile flag/yet-another-version or a setting in the watch are seemingly the options?

StarGate01 commented 2 years ago

Great to hear! If you want to create a PR, please make one to https://github.com/StarGate01/InfiniTime/tree/p8b-base , since that is the one that will get upstreamed via https://github.com/InfiniTimeOrg/InfiniTime/pull/1128 (see also: https://github.com/InfiniTimeOrg/InfiniTime/pull/1050). The p8b branch in my InfiniTime fork is a big merge of all these PRs for convenience.

I recommend adding an entry to https://github.com/StarGate01/InfiniTime/blob/p8b-base/src/CMakeLists.txt#L796= , e.g. P8B_FLIP. I will replace that name once I figured out its original MOY name.

Then, you can define a variable: add_definitions(-DDRIVER_DISPLAY_FLIP), and check for that one in your code.

For testing, you can just merge your PR fork back into p8b.

Once I verified your patch, I will make sure your version and also #2 are incorporated into https://github.com/InfiniTimeOrg/InfiniTime/pull/1128 .

StarGate01 commented 2 years ago

The step counter doesn't work.

Step counting in hardware is not supported by the SC7A20 accelerometer used in the P8b, and no software implementation exists yet.

StarGate01 commented 2 years ago

I have squashed, rebased and integrated the changes from your fork into the branch p8b-mirror (https://github.com/StarGate01/InfiniTime/tree/p8b-mirror), and created a PR at https://github.com/InfiniTimeOrg/InfiniTime/pull/1200 . It is also linked to https://github.com/InfiniTimeOrg/InfiniTime/pull/1050 .

If you want to make further changes, please rebase and PR to p8b-mirror.

StarGate01 commented 2 years ago

Please test the new 1.9.0.3 MOY-UNK release: https://github.com/StarGate01/p8b-infinitime/releases/tag/v1.9.0.3 .

izzeho commented 2 years ago

Have flashed 1.9.0.3 and confirm happily running.

StarGate01 commented 2 years ago

The model I received from your AliExpress link appears to be a atock MOY-TON5 P8b, colors are correct, however the SPI Flash might have changed. I will have to debug this in depth (already ripped it open). I suspect the manufacturer mixes and matches parts depending on availability.

In any case, your model will continue to be called MOY-UNK.