Giter Club home page Giter Club logo

u8g2's Introduction

Gitpod Ready-to-Code

https://raw.githubusercontent.com/wiki/olikraus/u8g2/ref/u8g2_logo_transparent_orange.png

U8g2: Library for monochrome displays, version 2

U8g2 is a monochrome graphics library for embedded devices. U8g2 supports monochrome OLEDs and LCDs, which include the following controllers: SSD1305, SSD1306, SSD1309, SSD1312, SSD1316, SSD1318, SSD1320, SSD1322, SSD1325, SSD1327, SSD1329, SSD1606, SSD1607, SH1106, SH1107, SH1108, SH1122, T6963, RA8835, LC7981, PCD8544, PCF8812, HX1230, UC1601, UC1604, UC1608, UC1610, UC1611, UC1617, UC1638, UC1701, ST7511, ST7528, ST7565, ST7567, ST7571, ST7586, ST7588, ST75160, ST75256, ST75320, NT7534, ST7920, IST3020, IST3088, IST7920, LD7032, KS0108, KS0713, HD44102, T7932, SED1520, SBN1661, IL3820, MAX7219, GP1287, GP1247, GU800 (see here for a full list).

The Arduino library U8g2 can be installed from the library manager of the Arduino IDE. U8g2 also includes U8x8 library:

  • U8g2
    • Includes all graphics procedures (line/box/circle draw).
    • Supports many fonts. (Almost) no restriction on the font height.
    • Requires some memory in the microcontroller to render the display.
  • U8x8
    • Text output only (character) device.
    • Only fonts allowed with fit into a 8x8 pixel grid.
    • Writes directly to the display. No buffer in the microcontroller required.

Setup Guide and Reference Manual

u8g2's People

Contributors

anthonydigirolamo avatar basilfx avatar bradjc avatar consuelita avatar dilucide avatar en4rab avatar fornellas avatar hendrykaak avatar huming2207 avatar izilzty avatar j0057 avatar jogi-k avatar liux-pro avatar madhurpv avatar maopiccoto avatar matteoscordino avatar matthijskooijman avatar mauabata avatar micooke avatar mnutsch avatar motla avatar mysterywolf avatar neilpanchal avatar olikraus avatar pdenes avatar qb4-dev avatar rivimey avatar sgjava avatar shlyakpavel avatar wuhanstudio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

u8g2's Issues

Support for SSD1322 NHD under Teensy 3.x

Hello Olivier,

If you can implement this display SSD1322 from New Heaven Display I can perform tests and try to debug the issues for this display with this new library.

Thanks

kerning table (follow up #39)

This is a followup of the discussions happened in #39

Sofar the idea is to introduce a kerning table with an additional command:
u8g2.setKerningTable

Existing kerning information can be found in .afm files.
AFM file format spec is here:
https://partners.adobe.com/public/developer/en/font/5004.AFM_Spec.pdf
The kerning table could be derived from the atm files:
http://www.nsl.com/k/pdf/afm/

Another option is to calculate the kerning tables in bdfconv itself under certain conditions:

  • not monospaced, not 8x8 font
  • transparent font

Algorithm:
Combine each glyph with each other.
i = 0
Start Loop
Start with default distance
Draw glyphs into the same Bitmap
Check for overlapping pixel
While pixel do not overlap, i++, decrease distance, continue with loop
if i <= user-def'ed-threshold
continue with next glyph
kerning delta = i - user-def'ed-threshold
store pair in kerning table

Implement line draw procedure

takeover from u8g:
void drawLine(u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2) { u8g_DrawLine(&u8g, x1, y1, x2, y2); }

U8x8: text scaling

I could probably miss something in the documentation, but I don't see a text scaling method for U8x8.
I think this feature should be available for text-only functionality (it is available in Adafruit SSD1306 libary and in SSD1306Ascii).
At least twofold scaling should be supported (the default system font is too small in most cases on 128x64 OLED displays).
And threefold scaling would be a great addition also.

setHardwareBackup

not implemented in u8g2 at the moment.
Not sure whether this should be implemented

ESP8266 compatibility most wanted :)

I remember there were problems with the non existing garbage collection with u8g. Not sure if this new version still has those requirements, in any case, an ESP port would be great!

Add page buffer offsets (Add support for LS013B7DH03)

For the Sharp LS013B7DH03 128x128 display you write individual lines of 128x1 pixels at minimum. The format is 1 address byte (Y coordinate), 16 bytes of pixel data, and a trailing byte (don't care). It's also possible to send multiple lines at once (e.g. one full page).

It looks something like this:

00 | 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 | 17
=========================================================
YY | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | TR
..
..
..
YY | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | TR

I was looking for a way to add these extra two bytes to the page buffer, so I can use DMA to transfer more data without CPU intervention. This will increase memory consumption because the extra bytes are just dead space, but lower energy consumption.

In U8glib I tried something like this:

  • Catch U8G_DEV_MSG_SET_PIXEL, increase the X coordinate by 8 (so it moves to next byte)
  • In U8G_DEV_MSG_PAGE_NEXT, set the 1st byte of each line in the page buffer to the correct address, and the 18th byte to the trailing byte (clearPage clears it all). Then use DMA to transfer full page buffer to the LCD.

Unfortunately, this doesn't work, because increasing the X coordinate will result in problems at the borders (drawPixel checks bounds).

So I was looking for a way to do this with U8g2, but as far as I can tell, it's not possible. Therefore, would it be possible to add an option to add offsets when writing to the page buffer?

Documentation for printUTF8()

Idea: UTF8 Support for normal print() function

  • testing required
  • documentation required
  • F() macro not yet supported. Implementation?
    u8g_uint_t drawStr(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStrP(&u8g, x, y, (u8g_pgm_uint8_t *)s); }

This is all obsolete, now print will support UTF8 with
enablePrintUTF8()

  • testing
  • documentation

Rising edge of clock

The LS013B7DH03 requires SPI clock mode 'second rising', whereas other displays use 'first falling'.

I presume the field sck_takeover_edge in u8x8_display_info_t can be used for this, but is there a standardized mapping of values to clock modes?

I can create a PR to fix this, e.g. taking the modes as defined by https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Mode_numbers?

(Yes, the LS013B7DH03 driver has the wrong clock mode in the display info structure, but I did not notice this until I refactored my platform driver, because I hard coded the mode.)

ST7920 problems

  • Test HW SPI
  • Fix documentation, see below

Arduino Forum:

It's also quite confusing what "RS" actually really is.
On this site it tells me that CS is RS :
[url=https://github.com/olikraus/u8g2/wiki/setup_tutorial#select-a-physical-bus]https://github.com/olikraus/u8g2/wiki/setup_tutorial#select-a-physical-bus[/url]
On this site it tells me that RS is dc :
[url=https://github.com/olikraus/u8g2/wiki/u8g2setupcpp#st7920-128x64]https://github.com/olikraus/u8g2/wiki/u8g2setupcpp#st7920-128x64[/url]
So how do I have to wire the display correct and build the constructor for my display.
As I said, with the older U8Glib everything works fine.

Document RefHeight

void u8g2_SetFontRefHeightText(u8g2_t *u8g2);
void u8g2_SetFontRefHeightExtendedText(u8g2_t *u8g2);
void u8g2_SetFontRefHeightAll(u8g2_t *u8g2);

Incorrect pixel placement - esp8266

I'm using an esp8266 (esp-01) with a 128x64 oled display SSD1306 with i2c interface.

I'm using u8g2 version 2.1.5 (downloaded yesterday) with Arduino 1.6.6 and the Generic ESP8266 v2 board library.

Running your example page_buffer/HelloWorld for example shows the text "HelloWorld!" followed by half of the letter "H" from the beginning. What I've noticed is that the first few pixel columns, 8 I think, of text placed at the start of a line is duplicated at the end of the line. This happens irrespective of the length of the text or size of the font.

img_20160811_151456

I've tried various variations including frame buffer, which makes no difference, and different drivers which changes the symptoms but is still wrong.

I use this constructor in your example program:

define gpio_SDA 0

define gpio_SCL 2

U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=/ gpio_SCL, / data=/ gpio_SDA, / reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display

Is there anything I can do to cure this problem?

Thanks

u8g2::clear()

should be changed. Currently only the buffer is cleared. However a compleate clean should happen (first/next loop)

SPI.h, cpp

Use SPISettings to set the parameters for the Transfer.
SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0))

(Requested by Michael via e-mail)

I'm not sure whether I found a BUG of u8g library.

When I use u8g lib on 256x128 LCD(driver chip is ST75256), After create the ST65256 special initial code, it works. But it could not work at WIDTH=256, So I check source codes under folder clib. Then I find uncomment "#define U8G_16BIT 1" to use larger piexls. But, it still not work!

So I changed all "uint8_t cnt" to "u8g_uint_t cnt" under clib folder. For example, "u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq)" change to
"u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t cnt, uint8_t *seq)"
And changed all "uint8_t arg_val" to "u8g_uint_t arg_val". There are many file changed.

After change of above, the u8g lib could work at 256x128 LCD.

I'm not sure this is a bug or I'm not use it correctly, email me [email protected] if need any detail.

drawBitmap not work (properly)? --> add drawBitmapP

I'm using the rook_bitmap example from U8G in combination with drawBitmap but aren't getting the expected output to my SSD1306 OLED screen (full page mode).

This is the specific command I'm using:
u8g2.drawBitmap( 0, 0, 1, 8, rook_bitmap);

I'm getting a single white pixel at the x7 y6 position and every couple of seconds a few other pixels will flicker. I have tried upping the cnt as well as the height vars to a few different variables but so far nothing has worked. I've tried running page buffer mode as well, but got the same results.

getStrWidth sometimes wrong

I'm trying right justify some text by subtracting the string width from right-hand column location. There's a few odd things going on.

Using u8g2_font_6x10_tr the wrong length is returned for strings containing "|" or ">". The function returns length = 1 and length = 4 respectively whereas it should perhaps be 2 for "|" and definitely 5 for ">".

Using u8g2_font_helvB08_tf there is no problem with ">" - it returns length = 4 which in this case is correct but it gets "|" wrong. So strings "-|" and "lazydog|" for example are given the wrong length.

There's endless possibilities to test and I've only tried one or two. Here's snippet that can be used to test.

char *list[] = {"|", ">", "-|", "lazydog|", "lazydog!", "lazy|dog"};
u8g2_uint_t fh, w;
u8g2.drawLine(120, 0, 120, 63);

u8g2.setFont(u8g2_font_6x10_tr);
//u8g2.setFont(u8g2_font_helvB08_tf);
u8g2.setFontPosTop();
fh = u8g2.getFontAscent() - u8g2.getFontDescent();

int i;
for (i = 0; i < sizeof(list)/sizeof(char*); i++) {
w = u8g2.getStrWidth(list[i]);
u8g2.drawStr(120 - w, fh * i, list[i]);
u8g2.setCursor(0,fh * i);
u8g2.print(w);
}

N.B this is not a big deal for me - it's just something I noticed in passing.

None display when init another IIC device

#include <U8g2lib.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>

U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, SCL, SDA, U8X8_PIN_NONE);
Adafruit_BMP085 bmp;

char tmp_buf[] = "123456";
char pre_buf[] = "abcdef";

void initBmp(void) {
  if (!bmp.begin()) {
    Serial.println("Could not find a valid BMP085 sensor, check wiring!");
    while (1) {}
  }
}

void setup(void) {
  Serial.begin(9600);
  initBmp();                //when add this line,  oled has no display, but comment this line oled display normal.
  u8g2.begin();
}

void loop(void) {

  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_profont12_mr);
  u8g2.drawStr(0, 20, tmp_buf);
  Serial.println(tmp_buf);
  u8g2.drawStr(0, 30, pre_buf);
  Serial.println(pre_buf);
  u8g2.sendBuffer();

  delay(1000);
}

when I call initBmp in setup function, and oled has no display

documentation for setFontDirection

void setFontDirection(uint8_t dir) {u8g2_SetFontDirection(&u8g2, dir); }
void u8g2_SetFontDirection(u8g2_t *u8g2, uint8_t dir);

create picture?

create user interface examples for u8g2

  • reuse examples from u8x8
  • create value change procedure
  • remove \t (center) feature, all text is centered automatically
  • add userInterface function to the cpp u8g2 header
  • documentation of the user interface examples

uint8_t u8g2_UserInterfaceSelectionList(u8g2_t *u8g2, const char *title, uint8_t start_pos, const char *sl);
uint8_t u8g2_UserInterfaceMessage(u8g2_t *u8g2, const char *title1, const char *title2, const char *title3, const char *buttons);
uint8_t u8g2_UserInterfaceInputValue(u8g2_t *u8g2, const char *title, const char *pre, uint8_t *value, uint8_t lo, uint8_t hi, uint8_t digits, const char *post);

uint8_t userInterfaceSelectionList(const char *title, uint8_t start_pos, const char *sl) {
  return u8g2_UserInterfaceSelectionList(&u8g2, title, start_pos, sl); }
uint8_t userInterfaceMessage(const char *title1, const char *title2, const char *title3, const char *buttons) {
  return u8g2_UserInterfaceMessage(&u8g2, title1, title2, title3, buttons); }
uint8_t userInterfaceInputValue(const char *title, const char *pre, uint8_t *value, uint8_t lo, uint8_t hi, uint8_t digits, const char *post) {
  return u8g2_UserInterfaceInputValue(&u8g2, title, pre, value, lo, hi, digits, post); }

u8g2_string_width in u8g2_font.c

For
w = u8g2_GetUTF8Width(u8g2, " X ")
returned width is not correct, because for the first blank the algorithm will use deltax but for the last black the algorithm will use glyph_width
Idea:
in bg_ReduceGlyph(bg_t *bg) (bg_glyph.c) keep the original width (bbx->w) if the height and width becomes zero (bbx->h == 0 and bbx->w == 0).

  • check if bbx->w and bbx->h really will be zero for the blank char
  • check the other algorithms if something relays on bbx->w to be there in such a case

bbx.w and bbx.h will be zero, however, this will be fixed in u8g2 font procedures

HW SPI: SPI_MODEx

spi_mode in the info struct should correspond to the Arduino SPI modes SPI_MODE0, SPI_MODE1, etc.
However the numbers 0..3 do not correspond to SPI_MODE0..SPI_MODE3 because internally these macros do have several random values.
As a result, we can not simply pass 0..3 to SPISettings, instead a mapping has to happen first.

More tests are required. At least ST7920 must be tested.

Mode Clock Polarity (CPOL) Clock Phase (CPHA) Output Edge Data Takover
SPI_MODE0 0 0 Falling Rising
SPI_MODE1 0 1 Rising Falling
SPI_MODE2 1 0 Rising Falling
SPI_MODE3 1 1 Falling Rising

spi-bus-timing
Image Source: http://www.corelis.com/education/SPI_Tutorial.htm

  • Introduce SPI_MODEx mapping in the HW SPI procedures for Arduino
  • Check the table above (is this all correct? Does the HW respond correctly?)
  • Document the table in the code
  • Update the byte procedure (SW SPI)
  • Testing

Problems when compiling fonts

I noticed two problems when compiling U8g2 (x64, Clang, OS X, -Wall):

  • Font file lines too large (can be worked around by -Wno-overlength-strings). This is just an example (of many):
u8g2/csrc/u8g2_fonts.c:14647:3: error: string literal of length 12689 exceeds maximum length 4095 that ISO C99 compilers are required to support
      [-Werror,-Woverlength-strings]
  "Z\0\3\2\4\5\4\5\6\20\21\0\375\12\375\13\377\1\234\3I\4\330 \6\0\220\247\0!\10\261"
  • Binary file size increases because all fonts are compiled. I noticed the same problem with U8glib, which I worked around by pointing to the indiviual fonts. Would it be an option to split fonts into single files (again)?

Arabic font

Dear Oliver
Thanks for your rapid reply

I think for Persian language I need these Unicode 9.0 Ranges of the Arabic Font :

  1. Arabic 0600-06FF
  2. Arabic Presentation Forms-A FB50-FBB1
  3. Arabic Presentation Forms-B FE70-FEFF

Greetings from Iran
Farzad

Event handling: begin() with button args

add comments in the examples for the various boards with buttons

  • DOGM128 shield
  • DOGS102 shield
  • Feather Wing OLED
  • Arduboy
  • Two more events (UP, DOWN) have been added, update the begin() procedure for this
  • Finish issue #10
  • Update begin() statement for UP/DOWN buttons (Documentation)
  • Create some interactive examples and add some comments for the begin()

button event support / getMenuEvent

void begin(uint8_t menu_select_pin, uint8_t menu_next_pin, uint8_t menu_prev_pin, uint8_t menu_home_pin)
/* return 0 for no event or U8X8_MSG_GPIO_MENU_SELECT, */
 /* U8X8_MSG_GPIO_MENU_NEXT, U8X8_MSG_GPIO_MENU_PREV, */
 /* U8X8_MSG_GPIO_MENU_HOME */
 uint8_t getMenuEvent(void)
  • documentation
  • add example

Port to ARM

create an example project, which demonstrates ARM usage

Link between u8x8 and u8g2 unclear

This night I tried to understand the relation between u8x8 and u8g2. It's not completely clear how both relate. I see that u8g2 setup code refers to u8x8 code (e.g. in u8g2_d_setup.c), so that makes me believe that u8x8 code is responsible for interfacing.

I also understand that u8x8 does not use page buffers and write directly to the display in tiles of 8x8 pixels. How does this work for displays that are line based? I want to add a driver for the Sharp LS013B7DH03, which requires you to write one line at a time (128x1 pixels). In other words, I cannot send a tile of 8x8 to the display without writing 128x8 pixels (thus use a buffer).

Maybe I'm missing a bit of information, can you help me out?

warning: pointer of type 'void *' used in arithmetic

When compiling version 2.0.7 with Arduino IDE 1.6.9:

...\U8g2\src\clib\u8x8_cad.c: In function 'u8x8_cad_ssd13xx_i2c':
...\U8g2\src\clib\u8x8_cad.c:348:9: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
  arg_ptr+=24;
...
...\U8g2\src\clib\u8x8_cad.c: In function 'u8x8_cad_ld7032_i2c':
...\U8g2\src\clib\u8x8_cad.c:397:9: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
  arg_ptr+=24;

I think, it would be better to convert the pointer into byte* or something like this.
Such warnings might mask other ones which could be crucial...

ST7920 Hardware SPI support?

Hey,
I've wondered whether if there is any plan to support HW SPI withe the ST9700 Controller (128x64)?
Would be great to have more than 1 FPS :)

Remove assert()

assert might cause issues on some embedded systems, so better remove assert completly.

Documentation drawBitmap

this is implemented, but documentation is required

    void drawBitmap(u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t cnt, u8g2_uint_t h, const uint8_t *bitmap)
      { u8g2_DrawBitmap(&u8g2, x, y, cnt, h, bitmap); }
    void drawXBM(u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
      { u8g2_DrawXBM(&u8g2, x, y, w, h, bitmap); }

bdf converersion, u8g2.

Hi Oliver,
I'm trying to use bdfconv.exe but I'm not getting success.
I do not really understand how to use it, I created my bdf file from
an existing source, and put in the bdf folder, hoping he would convert, and nothing happened.

ST7920 Hardware SPI not working correctly

Hi,
I've just tested the HW SPI with a ST7920 128X64 LCD.
At the start most of the picture is displayed partly correctly but then it starts the get messed up.
Tested own code and example-code
Examples: http://imgur.com/a/Jvxel
Tested on Arduino Uno
Pins:
RS -> 10
R/W -> 11
E -> 13
(RST -> 8)

Constructor: U8G2_ST7920_128X64_F_HW_SPI lcd(U8G2_R0, 10, U8X8_PIN_NONE);
and U8G2_ST7920_128X64_F_HW_SPI lcd(U8G2_R0, 10, 8);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.