From 311283124d209cf222344fde85ec088ac81bb90d Mon Sep 17 00:00:00 2001 From: devsaurus Date: Tue, 21 Jul 2015 21:32:42 +0200 Subject: [PATCH] u8g doc update --- README.md | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index df4cd504..ad3105cc 100644 --- a/README.md +++ b/README.md @@ -359,14 +359,14 @@ cu:send("hello") package.loaded["ds18b20"]=nil ``` -####Operate a display via I2c with u8glib +####Operate a display with u8glib u8glib is a graphics library with support for many different displays. The integration in nodemcu is developed for SSD1306 based display attached via the I2C port. Further display types and SPI connectivity will be added in the future. U8glib v1.18.1 #####I2C connection -Hook up SDA and SCL to any free GPIOs. Eg. `lua_examples/u8glib/graphics_test.lua` expects SDA=5 (GPIO14) and SCL=6 (GPIO12). They are used to set up nodemcu's I2C driver before accessing the display: +Hook up SDA and SCL to any free GPIOs. Eg. [u8g_graphics_test.lua](lua_examples/u8glib/u8g_graphics_test.lua) expects SDA=5 (GPIO14) and SCL=6 (GPIO12). They are used to set up nodemcu's I2C driver before accessing the display: ```lua sda = 5 scl = 6 @@ -384,7 +384,7 @@ All other pins can be assigned to any available GPIO: * D/C * RES (optional for some displays) -Also refer to the initialization sequence eg in `lua_examples/u8glib/graphics_test.lua`: +Also refer to the initialization sequence eg in [u8g_graphics_test.lua](lua_examples/u8glib/u8g_graphics_test.lua): ```lua spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0) ``` @@ -407,10 +407,24 @@ disp = u8g.ssd1306_128x64_hw_spi(cs, dc, res) ``` This object provides all of u8glib's methods to control the display. -Again, refer to `lua_examples/u8glib/graphics_test.lua` to get an impression how this is achieved with Lua code. Visit the [u8glib homepage](https://github.com/olikraus/u8glib) for technical details. +Again, refer to [u8g_graphics_test.lua](lua_examples/u8glib/u8g_graphics_test.lua) to get an impression how this is achieved with Lua code. Visit the [u8glib homepage](https://github.com/olikraus/u8glib) for technical details. + +#####Displays +I2C and HW SPI based displays with support in u8glib can be enabled. To get access to the respective constructors, add the desired entries to the I2C or SPI display tables in [app/include/u8g_config.h](app/include/u8g_config.h): +```c +#define U8G_DISPLAY_TABLE_I2C \ + U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c) \ + +#define U8G_DISPLAY_TABLE_SPI \ + U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi) \ + U8G_DISPLAY_TABLE_ENTRY(pcd8544_84x48_hw_spi) \ + U8G_DISPLAY_TABLE_ENTRY(pcf8812_96x65_hw_spi) \ +``` +An exhaustive list of available displays can be found in the [u8g module wiki entry](https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#u8g-module). + #####Fonts -u8glib comes with a wide range of fonts for small displays. Since they need to be compiled into the firmware image, you'd need to include them in `app/include/u8g_config.h` and recompile. Simply add the desired fonts to the font table: +u8glib comes with a wide range of fonts for small displays. Since they need to be compiled into the firmware image, you'd need to include them in [app/include/u8g_config.h](app/include/u8g_config.h) and recompile. Simply add the desired fonts to the font table: ```c #define U8G_FONT_TABLE \ U8G_FONT_TABLE_ENTRY(font_6x10) \ @@ -419,7 +433,7 @@ u8glib comes with a wide range of fonts for small displays. Since they need to b They'll be available as `u8g.` in Lua. #####Bitmaps -Bitmaps and XBMs are supplied as strings to `drawBitmap()` and `drawXBM()`. This off-loads all data handling from the u8g module to generic methods for binary files. See `lua_examples/u8glib/u8g_bitmaps.lua`. +Bitmaps and XBMs are supplied as strings to `drawBitmap()` and `drawXBM()`. This off-loads all data handling from the u8g module to generic methods for binary files. See [u8g_bitmaps.lua](lua_examples/u8glib/u8g_bitmaps.lua). In contrast to the source code based inclusion of XBMs into u8glib, it's required to provide precompiled binary files. This can be performed online with [Online-Utility's Image Converter](http://www.online-utility.org/image_converter.jsp): Convert from XBM to MONO format and upload the binary result with [nodemcu-uploader.py](https://github.com/kmpm/nodemcu-uploader). #####Unimplemented functions