olikraus / u8g2

U8glib library for monochrome displays, version 2
Other
5.04k stars 1.04k forks source link

I have a 144 x 32 LCD driven by a ST7920 chip #2091

Open olikraus opened 1 year ago

olikraus commented 1 year ago
    I have a 144 x 32 LCD driven by a ST7920 chip. (Tight physical-height requirement, displays is 36mm tall, all the room I have). I've used u8g before, but never had this particular problem: how to specify/set display size in pixels.

There's getDisplayHeight() and getDisplayWidth() methods; are there corresponding set methods?

Or should I just choose a constructor for a differently geometry, eg. 160 x 32, and restrict my horizontal addresses to 144? Eg. U8G2_ST7920_160X32_F_6800(rotation, d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) [full framebuffer, size = 640 bytes]?

SORRY newbie error: somehow clicked POST with incomplete subject line. No way to edit subject nor delete post.

Originally posted by @tomjennings in https://github.com/olikraus/u8g2/discussions/2084

craigmoates commented 1 year ago

We also have this 144 x 32 on ST7920 via SW SPI. I've tried to patch in values but have not succeeded yet. I'm looking now on how to rebuild via codebuild, and saw that others also have a need for this new constructor. Thank you!

olikraus commented 1 year ago

Is this topic still open? Can you do the testing, if I would do the code build changes?

craigmoates commented 1 year ago

Yes, we should be able to test for this as needed, thank you!

tomjennings commented 1 year ago

Unfortunately I managed to use a more conventional LCD module and I don't have a good system to check this with. Sorry.

olikraus commented 1 year ago

I have created beta 2.34.20 which includes the constructor U8G2_ST7920_144X32...

It would be great if someone could test this.

You can download the latest U8g2 beta release from here: https://github.com/olikraus/U8g2_Arduino/archive/master.zip Arduino IDE:

  1. Remove the existing U8g2_Arduino library (https://stackoverflow.com/questions/16752806/how-do-i-remove-a-library-from-the-arduino-environment)
  2. Install the U8g2_Arduino Zip file via Arduino IDE, add zip library menu (https://www.arduino.cc/en/Guide/Libraries).

PlatformIO: platformio.ini (https://docs.platformio.org/en/latest/projectconf/section_env_library.html#lib-deps) should include

lib_deps =
  u8g2=https://github.com/olikraus/U8g2_Arduino/archive/master.zip
craigmoates commented 1 year ago

Tested with several examples but still not working correctly. Let me know what feedback may be helpful. Compiled OK but has same behavior as 160x32 construct it seems. The 144x32 has 18 instead of 20 columns, but other than that they should respond similarly. Here is a code example (tested good): http://baxsie.com/images/forum/Arduino_ST7920_LCD/CFAG14432_SPI_Arduino.zip

olikraus commented 1 year ago

Which u8g2 code did you use for testing? How will it look on the display? Any picture of the current u8g2 output?

craigmoates commented 1 year ago

Arduino IDE 2.1.0 Mega2560 U8g2_2.34.20 using U8G2_ST7920_144X32_F_SW_SPI, results shown for logo, spacetrash, helloworld, and graphicstest. Ready for other testing as needed.

u8g2_logo_test u8g2_spacetrash_test u8g2_helloworld_test

https://github.com/olikraus/u8g2/assets/18092204/a431ea54-f548-469e-a168-2bc811fb2694

olikraus commented 1 year ago

Thanks for the pics and video. To me it looks like that there is some noise on the signal lines or some other wiring issue.

craigmoates commented 1 year ago

The other example which I linked above for your reference works fine, also SW SPI. Here is a video, same setup, just uploaded.

https://github.com/olikraus/u8g2/assets/18092204/8917af37-a31d-483c-8206-1f1dfabab5d6

olikraus commented 1 year ago

So HW SPI works, but SW SPI doesn't ?

craigmoates commented 1 year ago

These examples shown, including the working Crystalfontz one above, are SW SPI. No HW SPI here. Here is a section of their code, including bus timing comments:

define FAST_SPI 1

//FAST_SPI = 0: The SS pin is high for ~429uS (24-bits) // The clock frequency is ~57KHz // Full graphic update takes ~285mS //FAST_SPI = 1: With no delays, the SS pin is high for ~12uS (24-bits) // The clock frequency is ~2MHz // But that is too fast for the ST7920, so slow it down // with the additional _delay_us(1) calls, which makes: // The SS pin is high for ~39uS (24-bits) // The clock frequency is ~615KHz // Full graphic update takes ~22.5mS

//Software SPI (10-bit transfers, difficult to do using the hardware SPI)

define SPIPORT (PORTB)

define SPITOGGLE (PINB)

olikraus commented 4 weeks ago

looks very complicated...