Go Down

Topic: U8glib: Graphics Lib for LCDs and OLEDs (Read 224961 times) previous topic - next topic

olikraus

You should break down your task into three independent steps:

Code: [Select]
loop() {
  do measure and derive other values (FFT)
  display data
  calculate which page should be visible
}


"display data" will look like this:
Code: [Select]
if ( page_to_display == 1 )
  display_page_1();
else if ( page_to_display == 2 )
  display_page_2();


The "calculate which page should be visible" steps solves the task to calculate a suitable value for  "page_to_display". This calculation will be done based on the current system time, which is returned by millis(). So every 5 seconds you could switch the value for "page_to_display" from 1 to 2 and 2 to 1.

Oliver

oscar0226

#196
Feb 13, 2014, 03:55 pm Last Edit: Feb 13, 2014, 04:42 pm by oscar0226 Reason: 1

You should break down your task into three independent steps:

Code: [Select]
loop() {
 do measure and derive other values (FFT)
 display data
 calculate which page should be visible
}


"display data" will look like this:
Code: [Select]
if ( page_to_display == 1 )
 display_page_1();
else if ( page_to_display == 2 )
 display_page_2();


The "calculate which page should be visible" steps solves the task to calculate a suitable value for  "page_to_display". This calculation will be done based on the current system time, which is returned by millis(). So every 5 seconds you could switch the value for "page_to_display" from 1 to 2 and 2 to 1.

Oliver


Thanks for the reply!

I just wonder if I should do the "display data" inside the draw function picture loop or..? as if I do it in the main loop I would need delay(5000) after obtaining the millis() value so as to switch between the display page for every 5 seconds.

could you please explain a bit more detail about how to perform the function as I am confused?

The below is the program structure I am trying to perform and it needs to be finished in one cycle since the system picks new measurement during every cycle.

Code: [Select]

loop(){
     do measure and derive FFT value
    picture loop {
       draw();
    }
}

draw(){
   for (i=0; i<3; i++){
       display value
       wait 5s
       display FFT result
   }
}


olikraus

You should not do the delay inside the picture loop.

You could do it like this:
Code: [Select]
loop(){
     do measure and derive FFT value
     picture loop {
        display value
     }
     wait 5s
     picture loop {
        display FFT result
     }
     wait 5s
}


Oliver

DukeR

Hi Oliver.
I've been trying the new 4X 8 bit parallel mode for ST7920 and it's an obvious improvement. Thanks.
Since (for what I've seen) the ST7920 has become more "popular", I was wondering if you would reconsider writing the driver for the READ/WRITE/SHIFT low level capabilities of the parallel connection to it.
Keep up the good work!

olikraus


Hi Oliver.
I've been trying the new 4X 8 bit parallel mode for ST7920 and it's an obvious improvement. Thanks.
Since (for what I've seen) the ST7920 has become more "popular", I was wondering if you would reconsider writing the driver for the READ/WRITE/SHIFT low level capabilities of the parallel connection to it.
Keep up the good work!


Thanks, but your request is not so clear to me It is not so clear me. The parallel connection is there:
Code: [Select]
    U8GLIB_ST7920_128X64_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
        uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)

But i do not know what you mean by READ/WRITE/SHIFT.

Oliver

heathzap

#200
May 04, 2014, 01:43 pm Last Edit: May 04, 2014, 01:45 pm by heathzap Reason: 1
Hi

Two questions:

1.Trying to get the Adafruit 0.96" 128x64 OLED to work with U8glib. Seen other posts on 12C (TWI) not working and mine doesn't either. I have 4k7 pullups on D2 & D3. This running on Leonardo. Cant see anything to change other than selecting this line in code:

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);   // I2C / TWI

2.I intend getting the 128x128 color OLED from adafruit and running it on SPI. Not certain how to specify this in U8glib since SPI not linked to pins as on other arduinos?

Look forward to getting your excellent lib working.
Best regards

olikraus

1) Is it working with the Adafruit Libs?

2) I stopped supporting color oleds in U8glib. Better use Ucglib, which has better support for color OLEDs: https://code.google.com/p/ucglib/


heathzap

Hi Oliver

Works fine with the adafruit libs. I'm using D2,3 & 4 (Rst)

Tx for the link

olikraus

Unfortunately i do not have the Adafruit displays for testing.
Some people reported that u8glib will work with a different setup sequence (line 178 of u8g_dev_ssd1306_128x64.c)
You could modify the code to check if (for example) sequence 2 works better.

Oliver

heathzap

Tx Oliver. I'll try that and revert

JLLL

May I know how to draw text only on a small region of the LCD without the previously drawn text being wiped out?

I try to put one draw in setup() and another draw in loop(), however what was drawn during setup was all wiped out during loop().

olikraus

Yes, whenever you use the "picture loop", any previous picture is overwritten. U8glib behaves somehow different to other librieres, but it does only require a small amount of memory.
To solve this problem, add your graphics primitives from the setup procedure to your draw procedure in loop().

For more information on this, please see here: https://code.google.com/p/u8glib/wiki/tpictureloop

Oliver

JLLL

Thanks Oliver. I see. It is indeed different with other display libraries where you need to purposely clear the screen.

olikraus

Hi

Today, I have released v1.16 of U8glib (https://code.google.com/p/u8glib/). Changes include:
  * Added support for LD7032 60x32 OLED
  * Added support for SSD1306 OLED, which does not send I2C ACK (issue 239)
  * Added support for SH1106 128x64 OLED
  * Added support for T6963 128x128 displays
  * Added U8GLIB_SSD1306_ADAFRUIT_128X64 constructor

The picture below shows a 0.5" OLED module based on the LD7032 controller (from
here):



Oliver

ElmoC

How do you use the P version of functions like getStrWidthP?  The normal way used with things like strncpy_P(dest, PSTR("SOURCE"), size) doesn't seem to work.  I get an error when I try it...

invalid conversion from 'const char*' to 'u8g_pgm_uint8_t* {aka unsigned char*}' [-fpermissive]

Code: [Select]
const char szLabel[] PROGMEM = "Max:";  // defined in global space

u8g.getStrWidthP(szLabel); // Inside a function

Go Up