tbnobody / OpenDTU

Software for ESP32 to talk to Hoymiles/TSUN/Solenso Inverters
GNU General Public License v2.0
1.83k stars 511 forks source link

PCD8544 display not working and wrong implementation of display contrast #674

Open nobodyman1 opened 1 year ago

nobodyman1 commented 1 year ago

What happened?

I tried to use a PCD8544 display but it remains blank. After testing https://github.com/tbnobody/OpenDTU/pull/650 and a lot of investigation the display shows some data. But I had to modify the code: Display.contrast = 255

To Reproduce Bug

Connections:

ESP32 PCD8544
IO13 DN (MOSI)
IO14 CLK
IO15 CS
IO22 DC
IO25 RESET

Expected Behavior

The range of display contrast in the webinterface is 0 ... 100%. This value is used without any modification to set display contrast in the u8g2 library. But I found in the u8g2 specification: value : Contrast or brightness from 0 to 255

Install Method

Self-Compiled

What git-hash/version of OpenDTU?

055eb3a

Relevant log/trace output

No response

Anything else?

No response

tbnobody commented 1 year ago

Display should be fixed in 2e33f5cd51ca201abea1753d7aa1322371186fdd

dAjaY85 commented 1 year ago

Nokia don't support contrast change, if contrast is setted, display stays off. In this case, I implemented in my fork, if contrast is 255, the contrast will not setted.

tbnobody commented 1 year ago

According to the data sheet it does support setting the contrast. Even the library supports it: https://github.com/olikraus/u8g2/blob/4d9f63394f070a9f6e079ae8bccb97bad5967481/csrc/u8x8_d_pcd8544_84x48.c#L124

With my patch above the contrast value from 0...100 is spread from 0...255... But if it's still not working there is maybe a mistake in the display library. will doublecheck this later.

dAjaY85 commented 1 year ago

I have testet it, without backlights, maybe with contrast you can adjust the blacklights?

ms-doneck commented 1 year ago

Could someone please be so kind and describe the connection of this display, including pin mapping, under doc2/Display.md and docs/DeviceProfiles?

nobodyman1 commented 1 year ago

I tried firmware version d508b41.

build_flags = ${env.build_flags}
    -DHOYMILES_PIN_MISO=19
    -DHOYMILES_PIN_MOSI=23
    -DHOYMILES_PIN_SCLK=18
    -DHOYMILES_PIN_IRQ=26
    -DHOYMILES_PIN_CE=21
    -DHOYMILES_PIN_CS=5
    -DDISPLAY_TYPE=1
    -DDISPLAY_DATA=22 ; D/C
    -DDISPLAY_CS=15
    -DDISPLAY_RESET=25
Display connections ESP32 PCD8544
IO23 DN (MOSI)
IO18 CLK
IO15 CS
IO22 DC
IO25 RESET

The display shows some text (OpenDTU!) but the contrast setting is very bad. If I try to change the default contrast (which is 60%) to another value and press the save button an error message is shown: Profil muss zwischen 1 und 63 Zeichen lang sein!

After uploading pin_configuration.json with exact same settings as configured with build_flags it was possible to change the display contrast. If I set the value to 50% the display contrast is ok!

ms-doneck commented 1 year ago

Today I'm back home and checked your settings - yes it's working, but I only see "OpenDTU!" msg with good contrast at 50%. But how to see the live data? On the web interface I can see that my HM600 is producing fine.

nobodyman1 commented 1 year ago

Today I'm back home and checked your settings - yes it's working, but I only see "OpenDTU!" msg with good contrast at 50%. But how to see the live data? On the web interface I can see that my HM600 is producing fine.

I´m sorry, I only prepared my OpenDTU but I don´t have a Hoymiles device to test.

ms-doneck commented 1 year ago

You don't need an Hoymiles. The display must change to "offline" inside the loop, but it stays "frozen" with the "OpenDTU!" text from setStartupDisplay().

The loop is running fine and an I2C display works. But the PCD8544 in dead inside the loop.

I wrote some text to all lines inside setStartupDisplay() > works! I did the same inside the loop, > doesn't work > still "OpenDTU!" :-(

When I change the displays constructor to use software SPI: U8G2_PCD8544_84X48_F_4W_SW_SPI(U8G2_R0, 14, 12, cs, data, reset); It's working fine - but I'd need an option for the two addional pins and the font isn't a beauty...

2023-03-28 17_01_35-Window

nobodyman1 commented 1 year ago

v24.4.6 seems to work without any modification. Thanks a lot!!

The date output in the last line doesn´t look very nice. It would be better to have hours and minutes instead of the day (%a).

dAjaY85 commented 1 year ago

Please look at the implementation of the displays at the ahoy Projekt. This steps are already done there.

Would be nice, if OpenDTU will get the same state with the displays like Ahoy. Code is there, need smaller adjustments.

If the implementation is needed, I can send a new PR.

ms-doneck commented 1 year ago

Here it's already running fine. I'm not very familar using GIT, so I add the files here. Use it as you like. I did some renaming in the displays constructor to clearfy the pin names and I also did a pin-mapping file and some sketches. I changed the date time format to "%d.%m.%y %T" if its not a "large" display.

The reset pin is not needed - so I used ths for the DC pin.

platformio_override.ini:

[env:esp32_pcd8455]
board = esp32dev
build_flags = ${env.build_flags}
    -DHOYMILES_PIN_MISO=19
    -DHOYMILES_PIN_MOSI=23
    -DHOYMILES_PIN_SCLK=18
    -DHOYMILES_PIN_IRQ=16
    -DHOYMILES_PIN_CE=4
    -DHOYMILES_PIN_CS=5
    -DDISPLAY_TYPE=1
    -DDISPLAY_DATA=12  ; DIN 
    -DDISPLAY_CLK=14   ; CLK
    -DDISPLAY_CS=26    ; CE
    -DDISPLAY_RESET=13 ; DC

changes.zip

dAjaY85 commented 1 year ago

look here: https://github.com/dAjaY85/OpenDTU