Go Down

Topic: 192X64 SLG19264B LCD display (Read 435 times) previous topic - next topic

jxid

Constructor:
Code: [Select]
U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 5, 6, 7, 8, 9, 10, 11, 12, 4, 2, 13, A1, A2, A0);

Example:
u8g2 library
HelloWorld

Code: [Select]
/*

HelloWorld.ino

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 5, 6, 7, 8, 9, 10, 11, 12, 4, 2, 13, A1, A2, A0);


void setup(void) {
  u8g2.begin();
   pinMode(3, OUTPUT);
   digitalWrite(3, LOW); 
}

void loop(void) {
  u8g2.clearBuffer(); // clear the internal memory
  u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
  u8g2.drawStr(0,10,"Hello World!"); // write something to the internal memory
  u8g2.sendBuffer(); // transfer internal memory to the display
  delay(1000); 
}

david_prentice

This is from the Paged Buffer HelloWorld.ino example
Code: [Select]

void loop(void) {
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB10_tr);
    u8g2.drawStr(0,24,"Hello World!");
  } while ( u8g2.nextPage() );
  //delay(1000);
}


Your code will only work with a Full Buffer constructor.  e.g.
Code: [Select]

U8G2_KS0108_ERM19264_F u8g2(U8G2_R0, 5, 6, 7, 8, 9, 10, 11, 12, 4, 2, 13, A1, A2, A0);


Your Uno has only got 2048 bytes of SRAM
A 192x64 display needs 1536 bytes for "Full Buffer"
HelloWorld will probably be ok.   But any real life programs will run out of SRAM unless you are very careful.

David.

jxid

I tried your constructor but it doesn't work.
I have nothing on the screen.
And you are right,It consumes much SRAM.

Is there any posibility to run with ESP8266?

david_prentice

I have wasted lots of time.

Why don't you just try the Paged Buffer examples with the constructor that I suggested.  e.g.
Code: [Select]

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif


/*
  U8g2lib Example Overview:
    Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
    Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
    U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.
    
  This is a page buffer example.    
*/

U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 5, 6, 7, 8, 9, 10, 11, 12, 4, 2, 13, A1, A2, A0);

void setup(void) {
  pinMode(3, OUTPUT);
  digitalWrite(3, 0);
  u8g2.begin();  
}

void loop(void) {
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB10_tr);
    u8g2.drawStr(0,24,"Hello World!");
  } while ( u8g2.nextPage() );
  //delay(1000);
}

jxid

OK David. I will try more.
Thanks for your help.

david_prentice

#20
Nov 15, 2019, 09:27 am Last Edit: Nov 15, 2019, 09:33 am by david_prentice
I do not have your display.
I built the paged example from #18 for a Uno with _1 constructor:
Code: [Select]

Using library U8g2 at version 2.26.14 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\U8g2
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.9\hardware\arduino\avr\libraries\SPI
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.9\hardware\arduino\avr\libraries\Wire
"C:\\Program Files (x86)\\Arduino-1.8.9\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_680476/jxid_ks0108.ino.elf"
Sketch uses 9510 bytes (29%) of program storage space. Maximum is 32256 bytes.
Global variables use 588 bytes (28%) of dynamic memory, leaving 1460 bytes for local variables. Maximum is 2048 bytes.

Paged example with _F constructor:
Code: [Select]

U8G2_KS0108_ERM19264_F u8g2(U8G2_R0, 5, 6, 7, 8, 9, 10, 11, 12, 4, 2, 13, A1, A2, A0);

Code: [Select]

Sketch uses 9514 bytes (29%) of program storage space. Maximum is 32256 bytes.
Global variables use 1932 bytes (94%) of dynamic memory, leaving 116 bytes for local variables. Maximum is 2048 bytes.

Your full buffer example from #15 with _1
Code: [Select]

Sketch uses 9078 bytes (28%) of program storage space. Maximum is 32256 bytes.
Global variables use 588 bytes (28%) of dynamic memory, leaving 1460 bytes for local variables. Maximum is 2048 bytes.

Or your code with _2
Code: [Select]

Sketch uses 9082 bytes (28%) of program storage space. Maximum is 32256 bytes.
Global variables use 780 bytes (38%) of dynamic memory, leaving 1268 bytes for local variables. Maximum is 2048 bytes.

Or your code with _F
Code: [Select]

Sketch uses 9082 bytes (28%) of program storage space. Maximum is 32256 bytes.
Global variables use 1932 bytes (94%) of dynamic memory, leaving 116 bytes for local variables. Maximum is 2048 bytes.


You can see that the Full Buffer only leaves 116 bytes of SRAM.   The program will probably crash.

Yes,  life is easier with a Full buffer.  Fine for a 128x64 on a Uno.  Your 192x64 needs too much SRAM on a Uno.
With a Paged constructor means you have to use the firstPage() .. nextPage() construction.
But at least it will run on a Uno.

David.

jxid

#21
Nov 15, 2019, 09:13 pm Last Edit: Nov 16, 2019, 09:16 pm by jxid
I have wasted lots of time.

Why don't you just try the Paged Buffer examples with the constructor that I suggested.  e.g.
Code: [Select]

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif


/*
  U8g2lib Example Overview:
    Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
    Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
    U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.
    
  This is a page buffer example.    
*/

U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 5, 6, 7, 8, 9, 10, 11, 12, 4, 2, 13, A1, A2, A0);

void setup(void) {
  pinMode(3, OUTPUT);
  digitalWrite(3, 0);
  u8g2.begin();  
}

void loop(void) {
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB10_tr);
    u8g2.drawStr(0,24,"Hello World!");
  } while ( u8g2.nextPage() );
  //delay(1000);
}


Well David thank you very much for your time.
You helped me a lot.
The above example it uses less SRAM in my UNO R3.

Code: [Select]
Sketch uses 9430 bytes (29%) of program storage space. Maximum is 32256 bytes.
Global variables use 558 bytes (27%) of dynamic memory, leaving 1490 bytes for local variables. Maximum is 2048 bytes.

jxid

Here is a demo project that i made with the help of David.
It prints greek words in the display.

Code: [Select]

#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <Wire.h>
#define U8X8_HAVE_HW_SPI

U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 5, 6, 7, 8, 9, 10, 11, 12, 4, 2, 13, A1, A2, A0);

void setup(void) {
  pinMode(3, OUTPUT);
  digitalWrite(3, 0);
  u8g2.begin(); 
}

void loop(void) {
  u8g2.firstPage();
  do
    {
    u8g2.setFont(u8g2_font_cu12_t_greek);
    u8g2.drawUTF8(0,12,"Καλησπέρα - ΚΑΛΗΣΠΕΡΑ");
    u8g2.setFont(u8g2_font_unifont_t_greek);
    u8g2.drawUTF8(0,30,"Καλησπέρα - ΚΑΛΗΣΠΕΡΑ");
    u8g2.setFont(u8g2_font_10x20_t_greek);
    u8g2.drawUTF8(0,50,"Καλησπέρα-ΚΑΛΗΣΠΕΡΑ");           
    }
  while ( u8g2.nextPage() );
}



Code: [Select]
Sketch uses 19252 bytes (59%) of program storage space. Maximum is 32256 bytes.
Global variables use 624 bytes (30%) of dynamic memory, leaving 1424 bytes for local variables. Maximum is 2048 bytes.


Thaks for the help.

jxid

#23
Nov 16, 2019, 09:15 pm Last Edit: Nov 16, 2019, 09:16 pm by jxid
And here is a demo with bitmaps print.

Code: [Select]
#include <Arduino.h>
#include <U8g2lib.h>
#define U8X8_HAVE_HW_SPI
#include <SPI.h>

#include <Wire.h>

U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 5, 6, 7, 8, 9, 10, 11, 12, 4, 2, 13, A1, A2, A0);

#define gps2_width 50
#define gps2_height 64
static const unsigned char gps2_bits[] PROGMEM = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00,
   0x00, 0x30, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0x01, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x03, 0x00, 0x00, 0x00,
   0xc0, 0xa2, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x0c, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
   0x10, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x60, 0x30, 0x00, 0x00, 0x00, 0x80,
   0xf7, 0xc0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0x83, 0x61, 0x00, 0x08,
   0x00, 0x00, 0x00, 0x06, 0x41, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0xc3,
   0x00, 0x78, 0x00, 0x00, 0x00, 0x08, 0x42, 0x00, 0xf8, 0x01, 0x00, 0x00,
   0x18, 0x02, 0x00, 0xd8, 0x07, 0x00, 0x00, 0x10, 0x02, 0x00, 0x98, 0x1f,
   0x00, 0x0c, 0x30, 0x00, 0x00, 0x18, 0x7e, 0x00, 0x1c, 0x00, 0x00, 0x00,
   0x18, 0xfe, 0x01, 0x1e, 0x00, 0x00, 0x00, 0x18, 0xfe, 0x07, 0x1e, 0x00,
   0x00, 0x00, 0x18, 0xfe, 0x0f, 0x0e, 0x00, 0x00, 0x00, 0x30, 0xfe, 0x3f,
   0x06, 0x00, 0x00, 0x00, 0x30, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x30,
   0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x60, 0xfc, 0xff, 0x0f, 0x00, 0x00,
   0x00, 0x60, 0xfc, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xe0, 0xf8, 0xff, 0xff,
   0x00, 0x00, 0x00, 0xc0, 0xf8, 0xff, 0xff, 0x03, 0x00, 0x00, 0x80, 0xf9,
   0xff, 0xff, 0x07, 0x00, 0x00, 0x80, 0xf3, 0xff, 0xff, 0x1f, 0x00, 0x00,
   0x00, 0xf3, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xee, 0xff, 0xff, 0xff,
   0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xf8, 0xff,
   0xff, 0xff, 0x1f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
   0xe0, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x1f,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xfe, 0xff,
   0xff, 0x01, 0x00, 0x00, 0x10, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x00, 0x38,
   0xc0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xe8, 0x00, 0x50, 0x00, 0x00, 0x00,
   0x00, 0xc8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x0f, 0x00, 0x00,
   0x00, 0x00, 0x00, 0xc4, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0xff,
   0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0xe2, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xf2, 0xff, 0x01, 0x00, 0x00,
   0x00, 0x00, 0xf3, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xff, 0x03,
   0x00, 0x00, 0x00, 0x00, 0xf9, 0xff, 0x03, 0x00, 0x00, 0x00, 0x80, 0xfd,
   0xff, 0x07, 0x00, 0x00, 0x00, 0x80, 0xfe, 0xff, 0x07, 0x00, 0x00, 0x00,
   0xc0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00 };


#define gps_width 32
#define gps_height 32
static const unsigned char gps_bits[] PROGMEM = {
   0x00, 0x00, 0x01, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x1c, 0x38, 0x00,
   0x00, 0x03, 0xe0, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x01,
   0xc0, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x06, 0x20, 0x8e, 0x73, 0x04,
   0x20, 0x11, 0x80, 0x04, 0x20, 0x81, 0x14, 0x04, 0x20, 0x98, 0xc3, 0x04,
   0x30, 0x01, 0x00, 0x0c, 0x20, 0x31, 0x90, 0x04, 0x20, 0x8c, 0x60, 0x04,
   0x20, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x03,
   0x80, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x03, 0xc0, 0x00,
   0x00, 0x0f, 0x78, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfc, 0x3f, 0x00,
   0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf0, 0x0f, 0x00,
   0x00, 0xe0, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00,
   0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

#define weather_width 32
#define weather_height 32
static const unsigned char weather_bits[] PROGMEM = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x20, 0x84, 0x00, 0x00,
   0x40, 0x84, 0x00, 0x00, 0x80, 0x44, 0x00, 0x00, 0x80, 0x3f, 0x08, 0x00,
   0x8c, 0x7f, 0x06, 0x00, 0xf0, 0xe1, 0x03, 0x00, 0xe0, 0x40, 0x00, 0x00,
   0x60, 0x00, 0xf8, 0x01, 0x76, 0x00, 0xfc, 0x07, 0x64, 0x00, 0x0e, 0x0e,
   0x60, 0xe0, 0x07, 0x0c, 0x60, 0xf0, 0x03, 0x0c, 0x18, 0x18, 0x00, 0x18,
   0x0c, 0x1c, 0x00, 0x38, 0x00, 0x0f, 0x00, 0x70, 0x80, 0x0f, 0x00, 0x60,
   0xc0, 0x01, 0x00, 0xc0, 0xc0, 0x00, 0x1c, 0xc0, 0xc0, 0x00, 0x1c, 0x60,
   0xc0, 0x01, 0x0c, 0x60, 0x80, 0x37, 0x0e, 0x7b, 0x00, 0x3f, 0x0e, 0x1f,
   0x00, 0x20, 0x1e, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x0c, 0x00,
   0x00, 0x00, 0x04, 0x0c, 0x00, 0x0c, 0x04, 0x0e, 0x00, 0x0e, 0x00, 0x0e,
   0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 };

  
void setup(void) {
  pinMode(3, OUTPUT);
  digitalWrite(3, 0);
  u8g2.begin();
}

void loop(void) {
  u8g2.firstPage();
  do {
  u8g2.clearBuffer();
  u8g2.drawXBMP( 2, 0, gps2_width, gps2_height, gps2_bits);
  u8g2.drawXBMP( 160, 0, gps_width, gps_height, gps_bits);
  u8g2.drawXBMP( 160, 32, weather_width, weather_height, weather_bits);          
  }
  while(u8g2.nextPage());
 // delay(1000);
}


Just for reference for anyone who may have the same questions as i did.
Yannis

Go Up