Xinyuan-LilyGO / LilyGo-EPD47

GNU General Public License v3.0
402 stars 120 forks source link

rotate screen #9

Open kd8bxp opened 3 years ago

kd8bxp commented 3 years ago

is it possible to rotate the screen, from landscape to portrait? Thanks

kd8bxp commented 3 years ago

@martinberlin @Rainerlan Perhaps the kernel panic is happening when drawing images, or fonts - I believe the sketch that I also got the kernel panic/reboots was one of my "The Orville Font" tests. I will try just a simple draw sketch and see if I get a reboot/panic state from it.

kd8bxp commented 3 years ago

This is the sketch I used to test (Using both Platform IO and Arduino, I get kernel panics/reboots) The Arduino Exception Decoder says:

Guru Meditation Error: Core  1 panic'ed (LoadStoreError). Exception was unhandled.
Core 1 register dump:
PC      : 0x400d14c1  PS      : 0x00060330  A0      : 0x800d14e2  A1      : 0x3ffb1f40  
A2      : 0x00000014  A3      : 0x000000ff  A4      : 0x00000000  A5      : 0x3f7ffe4e  
A6      : 0x00000001  A7      : 0x00000000  A8      : 0x000000f0  A9      : 0x0000000a  
A10     : 0x00000003  A11     : 0x00000000  A12     : 0x000003c0  A13     : 0x0000021c  
A14     : 0x00000004  A15     : 0x00000032  SAR     : 0x00000006  EXCCAUSE: 0x00000003  
EXCVADDR: 0x3f7ffe4e  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000  

Backtrace: 0x400d14c1:0x3ffb1f40 0x400d14df:0x3ffb1f60 0x400d0f5a:0x3ffb1f80 0x400d331d:0x3ffb1fb0 0x4008b02d:0x3ffb1fd0

which translates to:

PC: 0x400d14c1: epd_draw_hline at /tmp/arduino_build_548139/sketch/src/epd_driver.c line 330
EXCVADDR: 0x3f7ffe4e

Decoding stack results
0x400d14c1: epd_draw_hline at /tmp/arduino_build_548139/sketch/src/epd_driver.c line 330
0x400d14df: epd_draw_vline at /tmp/arduino_build_548139/sketch/src/epd_driver.c line 337
0x400d0f5a: loop() at /tmp/arduino_modified_sketch_501826/shapes.ino line 139
0x400d331d: uartWrite at /home/lfmiller/.arduino15/packages/esp32/hardware/esp32/1.0.4/cores/esp32/esp32-hal-uart.c line 312
0x4008b02d: xQueueReceiveFromISR at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c line 1616

So, test to I commented out the epd_draw_hline and the epd_draw_vline statements, and still get the reboot/kernel panic, but this time the error is different.

Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC      : 0x4000c271  PS      : 0x00060034  A0      : 0x8008baff  A1      : 0x3ffb1e20  
A2      : 0x3ffb0058  A3      : 0x3f40a6a8  A4      : 0x00000014  A5      : 0x3ffbe790  
A6      : 0x3ffbe7d8  A7      : 0x00000001  A8      : 0x00000001  A9      : 0x3f40a6a9  
A10     : 0x000000a5  A11     : 0xaaaaaaaa  A12     : 0x8008c6e7  A13     : 0x3ffbe760  
A14     : 0x00000008  A15     : 0x00000001  SAR     : 0x0000001b  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000  

Backtrace: 0x4000c271:0x3ffb1e20 0x4008bafc:0x3ffb1e40 0x4008d604:0x3ffb1e60 0x4008d5ba:0xaaaaaaaa

Core 0 register dump:
PC      : 0x400edfd2  PS      : 0x00060134  A0      : 0x800d565e  A1      : 0x3ffbbff0  
A2      : 0x00000000  A3      : 0x00000001  A4      : 0x00000000  A5      : 0x00000001  
A6      : 0x00060120  A7      : 0x00000000  A8      : 0x800d5226  A9      : 0x3ffbbfc0  
A10     : 0x00000000  A11     : 0x40087fd8  A12     : 0x00060120  A13     : 0x3ffbb970  
A14     : 0x00000000  A15     : 0x3ffbbce0  SAR     : 0x00000000  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  

Backtrace: 0x400edfd2:0x3ffbbff0 0x400d565b:0x3ffbc010 0x4008c6d6:0x3ffbc030 0x4008b195:0x3ffbc050

which translates too:

PC: 0x4000c271
EXCVADDR: 0x00000000

Decoding stack results
0x4008bafc: vTaskSwitchContext at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 2770

Using I believe the latest platform io, and Arduino 1.8.13 with esp32 1.0.4 core installed (ESP32 Dev module with PSRAM enabled)

This is the same sketch I used to try the various draw features, and rotation set at 1 which worked without issues shapes.zip

martinberlin commented 3 years ago

Thanks for the update will try to reproduce it. Now we need to be aware also that EPDiy has a new version and many methods got updated. That’s one of the disadvantages of copying the files like this. But anyways will try to make it. NEW fonts drawing function looks a better candidate for rotation.

Update: I'm a bit blocked with this at the moment since I have another client works to finish. The thing is that previous to add this, the best would be to actually rethink how this is implemented.

For me the best way to add this EPDiy library as a controller for this epaper would be to add it as a library itself (libdeps in platformio.ini) And then leave just the Lilygo examples ready. That way at least we can benefit from updates in the library itself instead of having an static copy. That if the right settings can be added directly as build_flags or similar to instance EPDiy with the right board and display configuration (They are only 2 constants) Let me know what you think please @lewisxhe @LilyGO

martinberlin commented 3 years ago

I’m updating this in my fork of the base component EPDiy https://github.com/vroland/epdiy/issues/71

I don’t think it makes sense to add it here since it uses an old version of EPDiy and it will be much harder and double work to add it on the fonts rendering. Related #33 I suggest to close this one and once my pull request is approved we can use EPDiy and ASAP Lilygo examples but using the component as a library dependency and not copying it like it is now.

Pull request made to add software rotation to EPDiy. I really don't think that updating it here makes any sense since you are using an old static version of the mother library that is EPDiy. I would suggest to use: https://github.com/martinberlin/epdiy-rotation/tree/develop (Branch: develop)

to try it out. Also if you want to use it as an arduino library, you need to add:

https://github.com/martinberlin/epdiy-rotation.git#develop

to your platformio.ini lib_deps @kd8bxp

martinberlin commented 3 years ago

My fork of EPDiy is ready to be tested: https://github.com/martinberlin/epdiy-rotation/tree/develop

branch develop

just use EPDiy in libdeps as a dependency and try one of the demo examples https://github.com/martinberlin/epdiy-rotation.git#develop

rotation is covered in:

could use some help if someone wants to give it a try.

DavidM42 commented 3 years ago

@martinberlin I tested your fork and it works great for me. Thanks for the great work :tada: Took me a bit of finding code snippets and figuring out, but I now successfully show text in portrait mode with the great new high-level api. No more random crashes and many improvements compared to this library too because of the new epdiy features

martinberlin commented 3 years ago

My fork is merged on EPDiy Master branch. So you can use it directly!

martinberlin commented 3 years ago

Closing here since I don't want this to get stale. Please just as @DavidM42 commented, use directly: https://github.com/vroland/epdiy

Remember to make an: idf.py menuconfig Go to Component config -> E-Paper driver (At the very end)

And there set both options Display type and board to use LILYGO. Do not forget that SPRAM should be active!

Go to Component config -> ESP32-Specific and check Support for external SPI-connected RAM

DavidM42 commented 3 years ago

I think an example for this device here with platformIO config and the new high level api would be a nice addition to the epdiy repo. Wanted to do it but didn't find the time yet

martinberlin commented 3 years ago

Ah yes sure. A part of that I cannot close it since this is not my repository ;) I hope that Lilygo developers can just take the new EPDiy where I added rotation and was tested by V. Roland. That will be a much better move than refactoring an old version. If you have time just do it, will be a great addition for any other person using this epaper display.

zenith85 commented 2 years ago

i tried, and spent 3 days working on trying to make the code work. but i face many errors. most of the errors are just unknown variables, unions and constructs. i tried to digest the code and understand it... but no hope, it is too distant like it is a different project than the original lilygo codes. May be i am just new to this .... Anyway i was looking for simple tweak to make the screen rotate, but couldn't find any working way to do it.