olikraus / u8g2

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

Refresh/scan rate is very slow. #1085

Closed AdinAck closed 4 years ago

AdinAck commented 4 years ago

I'm not sure if I'm doing this completely wrong or something but I cannot figure out how to make this screen draw more than ~5 frames per second. Just drawing one pixel takes about .75 seconds.

I'm using an Adafruit Grand Central (SAMD51). The display is an SSD1322 256x64. The communication protocol is 4 wire SPI.

Here is a video: link and here is my code:

include

include

include

U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI u8g2(U8G2_R0, / clock=/ SCL, / data=/ SDA, / cs=/ 6, / dc=/ 9, / reset=/ 5); // Enable U8G2_16BIT in u8g2.h

int a = 0;

void setup() { u8g2.begin(); u8g2.clearBuffer(); u8g2.setCursor(0,0); u8g2.setFont(u8g2_font_helvB18_tr); }

void loop() { u8g2.clearBuffer(); u8g2.drawBox(128-25,32-25,50,50); u8g2.sendBuffer(); u8g2.clearBuffer(); u8g2.sendBuffer(); }

Thank you for any help!

AdinAck commented 4 years ago

update: tried 8080 to see if that would work better, however, 8080 constructor does not exist for SSD1322 ;(

olikraus commented 4 years ago

You should try HW_SPI. SW SPI will always be very slow.

AdinAck commented 4 years ago

Oh hey man, thanks for helping out! So I did try that, it doesn't make any sense to me because the constructor for that has no clock or data pins.

U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI(rotation, cs, dc [, reset]) [full framebuffer, size = 2048 bytes]

Is that a typo?

Thanks!

AdinAck commented 4 years ago

Update, just tried this:

U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI u8g2(U8G2_R0, / clock=/ 52, / data=/ 51, / cs=/ 2, / dc=/ 3, / reset=/ 4);

When verifying it says "no matching function or call"

olikraus commented 4 years ago

Clock and data pins are fixed by your hardware, so there's no need to specify them in the ino script. See the description of your board for the location of the SPI pins.

AdinAck commented 4 years ago

Ah! Let me guess, SW stands for software and HW stands for hardware. Awesome, I'll try it as soon as I can!

Thanks!

olikraus commented 4 years ago

yes, MOSI (SPI data) pin seems to be # 50 and SCK (SPI clock) pin is # 52 on the Adafruit Grand Central board.

AdinAck commented 4 years ago

Works SUPER well! However... it appears that u8g2 is cutting off the right of the screen for some reason? That part of the screen functions when the board is programmed in circuitpython. This problem still happens on an ESP8266.

Here is a video: link

And here is the code:

include

include

include

U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI u8g2(U8G2_R0, / cs=/ 2, / dc=/ 4, / reset=/ 3); // Enable U8G2_16BIT in u8g2.h

int a = 128; int b = 1;

void setup() { u8g2.begin(); u8g2.clearBuffer(); u8g2.setCursor(0,0); u8g2.setFont(u8g2_font_helvB18_tr); }

void loop() { u8g2.clearBuffer(); u8g2.drawBox(a,32-25,50,50); u8g2.sendBuffer(); a = a + b; if (a >= 256-26 or a <= 26){ if (b == 1){ b = -1; }else{ b = 1; } } }

Just a square going back and forth. (not all the way to the left btw)

Thank you so much!

olikraus commented 4 years ago

Did you enable 16 bit mode in u8g2.h as mentioned in the constructor comment? See also the u8g2 FAQ.

olikraus commented 4 years ago

no further feedback, closing...

AdinAck commented 4 years ago

Sorry, was busy. That did the trick! Thank you so much!

olikraus commented 4 years ago

:-)