summaryrefslogtreecommitdiff
path: root/display_setup.lua
blob: 78dfb219d976807e75bf05eb0caa2eb50159bfab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- setup I2c and connect display
function init_i2c_display()
    -- Pinsa are hardwired on the oled display shield
    local sda = 2 -- GPIO14
    local scl = 1 -- GPIO12
    local sla = 0x3c -- 0x3c or 0x3d
    i2c.setup(0, sda, scl, i2c.SLOW)
    -- old 1.5.1 nodemcu firmware
    -- disp = u8g.ssd1306_64x48_i2c(sla)
    -- new 3.0.0 nodemcu firmware
    disp = u8g2.ssd1306_i2c_64x48_er(0, sla)
end

function prepare()
    -- old 1.5.1 nodemcu firmware
    --disp:setFont(u8g.font_6x10)
    --disp:setFontRefHeightExtendedText()
    --disp:setDefaultForegroundColor()
    --disp:setFontPosTop()
    -- old 3.0.0 nodemcu firmware
    disp:setFont(u8g2.font_6x10_tf)
    disp:setFontRefHeightExtendedText()
    disp:setDrawColor(1)
    disp:setFontPosTop()
end

init_i2c_display()
prepare()