Commit 6c080c9d authored by Vowstar's avatar Vowstar
Browse files

Merge pull request #383 from devsaurus/dev

Doc update for u8g
parents 6eb5b9c8 897c8cd1
...@@ -410,7 +410,8 @@ u8glib comes with a wide range of fonts for small displays. Since they need to b ...@@ -410,7 +410,8 @@ u8glib comes with a wide range of fonts for small displays. Since they need to b
They'll be available as `u8g.<font_name>` in Lua. They'll be available as `u8g.<font_name>` in Lua.
#####Bitmaps #####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`. Binary files can be uploaded with [nodemcu-uploader.py](https://github.com/kmpm/nodemcu-uploader). 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`.
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 #####Unimplemented functions
- [ ] Cursor handling - [ ] Cursor handling
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
-- setup I2c and connect display -- setup I2c and connect display
function init_i2c_display() function init_i2c_display()
-- SDA and SCL can be assigned freely to available GPIOs -- SDA and SCL can be assigned freely to available GPIOs
sda = 5 -- GPIO14 local sda = 5 -- GPIO14
scl = 6 -- GPIO12 local scl = 6 -- GPIO12
sla = 0x3c local sla = 0x3c
i2c.setup(0, sda, scl, i2c.SLOW) i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.ssd1306_128x64_i2c(sla) disp = u8g.ssd1306_128x64_i2c(sla)
end end
...@@ -15,9 +15,9 @@ function init_spi_display() ...@@ -15,9 +15,9 @@ function init_spi_display()
-- Hardware SPI MOSI = GPIO13 -- Hardware SPI MOSI = GPIO13
-- Hardware SPI MISO = GPIO12 (not used) -- Hardware SPI MISO = GPIO12 (not used)
-- CS, D/C, and RES can be assigned freely to available GPIOs -- CS, D/C, and RES can be assigned freely to available GPIOs
cs = 8 -- GPIO15, pull-down 10k to GND local cs = 8 -- GPIO15, pull-down 10k to GND
dc = 4 -- GPIO2 local dc = 4 -- GPIO2
res = 0 -- GPIO16 local res = 0 -- GPIO16
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0) spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
disp = u8g.ssd1306_128x64_spi(cs, dc, res) disp = u8g.ssd1306_128x64_spi(cs, dc, res)
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
-- setup I2c and connect display -- setup I2c and connect display
function init_i2c_display() function init_i2c_display()
-- SDA and SCL can be assigned freely to available GPIOs -- SDA and SCL can be assigned freely to available GPIOs
sda = 5 -- GPIO14 local sda = 5 -- GPIO14
scl = 6 -- GPIO12 local scl = 6 -- GPIO12
sla = 0x3c local sla = 0x3c
i2c.setup(0, sda, scl, i2c.SLOW) i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.ssd1306_128x64_i2c(sla) disp = u8g.ssd1306_128x64_i2c(sla)
end end
...@@ -15,9 +15,9 @@ function init_spi_display() ...@@ -15,9 +15,9 @@ function init_spi_display()
-- Hardware SPI MOSI = GPIO13 -- Hardware SPI MOSI = GPIO13
-- Hardware SPI MISO = GPIO12 (not used) -- Hardware SPI MISO = GPIO12 (not used)
-- CS, D/C, and RES can be assigned freely to available GPIOs -- CS, D/C, and RES can be assigned freely to available GPIOs
cs = 8 -- GPIO15, pull-down 10k to GND local cs = 8 -- GPIO15, pull-down 10k to GND
dc = 4 -- GPIO2 local dc = 4 -- GPIO2
res = 0 -- GPIO16 local res = 0 -- GPIO16
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0) spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
disp = u8g.ssd1306_128x64_spi(cs, dc, res) disp = u8g.ssd1306_128x64_spi(cs, dc, res)
...@@ -91,17 +91,6 @@ function ascii_1() ...@@ -91,17 +91,6 @@ function ascii_1()
end end
end end
function ascii_2()
local x, y, s
disp:drawStr(0, 0, "ASCII page 2")
for y = 0, 5, 1 do
for x = 0, 15, 1 do
s = y*16 + x + 160
disp:drawStr(x*7, y*10+10, string.char(s))
end
end
end
function extra_page(a) function extra_page(a)
disp:drawStr(0, 12, "setScale2x2") disp:drawStr(0, 12, "setScale2x2")
disp:setScale2x2() disp:setScale2x2()
...@@ -131,8 +120,6 @@ function draw(draw_state) ...@@ -131,8 +120,6 @@ function draw(draw_state)
elseif (component == 6) then elseif (component == 6) then
ascii_1() ascii_1()
elseif (component == 7) then elseif (component == 7) then
ascii_2()
elseif (component == 8) then
extra_page(bit.band(draw_state, 7)) extra_page(bit.band(draw_state, 7))
end end
end end
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
-- setup I2c and connect display -- setup I2c and connect display
function init_i2c_display() function init_i2c_display()
-- SDA and SCL can be assigned freely to available GPIOs -- SDA and SCL can be assigned freely to available GPIOs
sda = 5 -- GPIO14 local sda = 5 -- GPIO14
scl = 6 -- GPIO12 local scl = 6 -- GPIO12
sla = 0x3c local sla = 0x3c
i2c.setup(0, sda, scl, i2c.SLOW) i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.ssd1306_128x64_i2c(sla) disp = u8g.ssd1306_128x64_i2c(sla)
end end
...@@ -15,9 +15,9 @@ function init_spi_display() ...@@ -15,9 +15,9 @@ function init_spi_display()
-- Hardware SPI MOSI = GPIO13 -- Hardware SPI MOSI = GPIO13
-- Hardware SPI MISO = GPIO12 (not used) -- Hardware SPI MISO = GPIO12 (not used)
-- CS, D/C, and RES can be assigned freely to available GPIOs -- CS, D/C, and RES can be assigned freely to available GPIOs
cs = 8 -- GPIO15, pull-down 10k to GND local cs = 8 -- GPIO15, pull-down 10k to GND
dc = 4 -- GPIO2 local dc = 4 -- GPIO2
res = 0 -- GPIO16 local res = 0 -- GPIO16
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0) spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
disp = u8g.ssd1306_128x64_spi(cs, dc, res) disp = u8g.ssd1306_128x64_spi(cs, dc, res)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment