Pages: 1 ... 10 11 [12] 13 14 15   Go Down
Author Topic: U8glib: Graphics Lib for LCDs and OLEDs  (Read 43515 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@MAS3
We discussed this some months back here http://forum.arduino.cc/index.php?topic=159851.0? But i can not remember that anyone has confirmed that this OLED works with u8glib. Thanks for the information.

@Dj_Garfield
The dimensions of the display are provided by the driver (hardcoded into the driver c code).

Oliver
« Last Edit: December 18, 2013, 12:43:25 am by olikraus » Logged

The Netherlands
Offline Offline
Edison Member
*
Karma: 47
Posts: 1533
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The brightness of the CO-16 display can be set, i do not know (yet) if the brightness can be set per pixel, or for the entire display.
But this line:
Code:
    u8g.setColorIndex(1);
Just will work with a zero or a one.
Anything larger than one is a one, meaning i can only enable or disable the pixel.
I can't set the brightness this way.
Is there any other way to control the brightness ?
In the other sketch this sets the brightness (here described as contrast), maybe this can offer some help:
Code:
  i2c_OLED_send_cmd(0x81); // Setup CONTRAST CONTROL, following byte is the contrast Value
  i2c_OLED_send_cmd(0xaf); // contrast value between 1 ( == dull) to 256 ( == bright)

I'll try if i can set different contrast levels in one sketch, and if that will be of any influence on the entire display, or on the next drawn items.
Logged

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

The Netherlands
Offline Offline
Edison Member
*
Karma: 47
Posts: 1533
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, tried already.
This contrast setting sets the entire display.
I can make the display fade out this way.
Logged

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The SSD1306 controller is a pure monochrome controller. There are no gray levels. Pixel is either on or off, but the "brightness" of all "on" pixel can be controllt by the u8glib contrast setting.

Oliver
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there any plan to start supporting these interesting tft

 http://www.buydisplay.com/default/lcd-5-ssd1963-tft-module-touch-screen-display-800x480-mcu-arduino.html

thanks
Logged

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Indeed a nice display for a good price. U8glib supports some true color displays, but mainly the reason for this support had been that other people started to create such devices. However, U8glib has been optimized for monochrom displays with SPI interface. TFT LCDs could be supported, but speed (especially for such a large 800x480 display) will be very poor. Maybe UTFT has support for it.

Merry Christmas to everybody,

Oliver
Logged

France GARD
Offline Offline
Newbie
*
Karma: 1
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Merry Christmas to you Oliver smiley ( and for all )

I have some question about using fonts with u8g Lib .

Is it possible to truncate the font list to reduce it at the very strict necessary ? I explain , I'm Working on a DashBoard Atmega based , and I would like to know if it is possible to delete all characters I don't need in the way to have just numbers in the ASCII table ? because speed ( in km/h ) is displayed with numbers and no letters , so if I delete all the references to a letter in the ASCII table for any font , should this works ?

Is It Easy to create personal fonts like the font I use for the speed indicator on the following picture ?
( in the picture the oil indicator is an 10x19px icon , the battery a 7x10 icon , time is displayed wit u8g_font_helvB08 ( I would like to reduce this font to keep numbers only if it is possible , the same for the ODOmeter ), that I would like to do is build font for Speedometer .


* dash-test.jpg (992.32 KB, 2048x1536 - viewed 65 times.)
« Last Edit: December 26, 2013, 07:46:07 pm by Dj_Garfield » Logged

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

All fonts in u8glib are derived from the ".bdf" file format. It is a standard format to store bitmap fonts. Details are here: http://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format. It is a plain text format, so you could also use a simple text editor to modify the bitmaps. There are also several font editors which allow export to bdf. Just to name two of them:
Fony: http://hukka.ncn.fi/?fony
Fontforge: http://fontforge.org/

I have not used Fony for a while, but if i understand the latest ChangeLog corretly, it should be easy to copy and past your existing icons into a new font. Once this is done, export the font as bdf and convert it into a U8glib font with "bdf2u8g" (available for Windows on the U8glib download page on google code).

Have a look here on details how to use bdf2u8g: http://code.google.com/p/u8glib/wiki/bdf2u8g.

As an example, here is how to extract the numbers only from helvB08:
1. Download http://u8glib.googlecode.com/hg/tools/font/bdf/helvB08.bdf
2. Use
Code:
bdf2u8g  -b 48 -e 57  ../bdf/helvB08.bdf u8g_font_helvB08n u8g_font_helvb08n.c
to extract the font with the bitmaps for chars "0"..."9". The result will look like this:
Code:
const u8g_fntpgm_uint8_t u8g_font_helvB08n[157] U8G_FONT_SECTION("u8g_font_helvB08n") = {
  0,12,19,255,251,8,0,0,0,0,48,57,0,8,0,8,
  0,5,8,8,6,0,0,112,216,216,216,216,216,216,112,3,
  8,8,6,1,0,96,224,96,96,96,96,96,96,5,8,8,
  6,0,0,112,216,24,24,48,96,192,248,5,8,8,6,0,
  0,112,216,24,48,24,24,216,112,6,8,8,6,0,0,8,
  24,56,88,152,252,24,24,5,8,8,6,0,0,248,192,192,
  240,24,152,216,112,5,8,8,6,0,0,112,216,192,240,216,
  216,216,112,5,8,8,6,0,0,248,24,24,48,48,96,96,
  96,5,8,8,6,0,0,112,216,216,112,216,216,216,112,5,
  8,8,6,0,0,112,216,216,216,120,24,216,112};
3. Copy this code into your .ino file and use "u8g_font_helvB08n" as argument for the "setFont" command.

Oliver



Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all!

I use Arduino Mega 2560 with two displays ST7920.
Since most of the ports used for sensors, ports remain free 8,9,10,11,12,13
So I connected displays to these ports with software SPI
U8GLIB_ST7920_128X64_4X    u8g(10, 9, 8 );
U8GLIB_ST7920_128X64_4X   u8g2(13, 12, 11 );

In the  function "loop" I do rendering these displays alternating with intervals of 1 second.

Code:
if ((displayNo == 0) && (currentDisplayMillis - lastDisplayUpdate) > 1000)
 {
  u8g.firstPage();
  do {
 ....
       }
  while( u8g.nextPage());
  displayNo = 1;
  lastDisplayUpdate = currentDisplayMillis;
 }
else if ((displayNo == 1) && (currentDisplayMillis - lastDisplayUpdate) >1000)
 {
  u8g2.firstPage();
  do {
 ....
       }
  while( u8g2.nextPage());
  displayNo = 0;
  lastDisplayUpdate = currentDisplayMillis;
 }

The problem is that the first display only drawn for the first time and then is no longer updated. And the second is updated at the desired interval.
If I disable update of second display, the first starts normally updated.
Prompt where to find the error?
thanks
« Last Edit: December 27, 2013, 05:08:33 pm by boomych » Logged

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What i can say, is that two displays at the same time is not testes very well.
Can you replace one of the constructors with the 1x variant. For example
U8GLIB_ST7920_128X64_4X    u8g(10, 9, 8 );
U8GLIB_ST7920_128X64_1X   u8g2(13, 12, 11 );
Will this work?

Oliver
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have tried almost all combinations, behavior does not change - the second monitor is updated, not the first.
Only one combination was different: updated first display and the second would not be updated:
U8GLIB_ST7920_128X64_4X    u8g(10, 9, smiley-cool;
U8GLIB_ST7920_128X64           u8g2(13, 12, 11);

Logged

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To be honest, i do not have an idea why this does not work. From U8glib perspective it should work. The only issue could be, that the same buffer is used if the same constructure is called. However, it seems, that this does not make a difference.
Can you ensure that youre code works correctly?
Maybe you should do a simple test script first. Pseudo code:

int cnt = 0;
void loop(void)  {
  print "cnt" on first display
  cnt++;
  delay(1000)
  print "cnt" on second display
  cnt++;
  delay(1000)
}

Now, even numbers (0, 2, 4, 6, ...) should be printed on the first display and odd numbers (1, 3, 5, ...) are printed on the second display. Will this work?

Oliver
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It`s new code for test
Code:
#include "U8glib.h"
U8GLIB_ST7920_128X64_1X     u8g(10, 9, 8);
U8GLIB_ST7920_128X64_4X     u8g2(13, 12, 11);

int cnt = 0;

void setup(void) {
 if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
 if ( u8g2.getMode() == U8G_MODE_R3G3B2 ) {
    u8g2.setColorIndex(255);     // white
  }
  else if ( u8g2.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g2.setColorIndex(3);         // max intensity
  }
  else if ( u8g2.getMode() == U8G_MODE_BW ) {
    u8g2.setColorIndex(1);         // pixel on
  }
  else if ( u8g2.getMode() == U8G_MODE_HICOLOR ) {
    u8g2.setHiColorByRGB(255,255,255);
  }
}

void loop(void)
{
  u8g.firstPage(); 
  do {
         u8g.setFont(u8g_font_unifont);
         u8g.setColorIndex(1);
         u8g.setPrintPos( 0, 30);
         u8g.print(cnt);
  } while( u8g.nextPage() );

  delay(1000);
  cnt++;
 
  u8g2.firstPage(); 
  do {
         u8g2.setFont(u8g_font_unifont);
         u8g2.setColorIndex(1);
         u8g2.setPrintPos( 0, 30);
         u8g2.print(cnt);
  } while( u8g2.nextPage() );

 cnt++;
 delay(1000);
}

First display all time shows 0, second display shows 1, 3, 5, 7 ... etc


So, third display is TFT with UTFT library,  makes no difference whether it is on or not, I tried to disable it physically, it has no effect
Logged

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It took some time to reproduce the problem,  but indeed, this is a bug: Attaching two ST7920 displays with SW SPI does not work correctly. I have fixed this in v1.15pre3 of U8glib (attached...).

@boomych: Thank you very much for the bug report (karma+). I hope that this is now fixed.

Oliver

* u8glib_arduino_v1.15pre3.zip (1056.99 KB - downloaded 18 times.)
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oliver, Happy New Year!
I tried your new version of the library. Huge thanks! Everything works just fine!
Logged

Pages: 1 ... 10 11 [12] 13 14 15   Go Up
Jump to: