天天看點

nodemcu(esp8266)u8g2 oled顯示漢字擷取網絡時間

我的OLED是1.3寸128×64點陣,驅動是SH1106 I2C接口,我用的U8G2的子產品,u8G2有16×16的漢字,Chinese1,chinese2,chinese3,三個漢字字型,是unicode編碼,不過我發現漢字不全,隻有很少一部分,用DrewGlyph顯示。有知道的歡迎讨論。本來分兩個檔案,發現問題比較多,現在用一個init.lua檔案,發現是可以的,連接配接熱點後,可以同步時間,并且在OLED上顯示出來,顯示正常,程式如下:I2C用的1,2為資料端。時間重新整理10S,也可設短,但是改程式,不好傳進去。

function init_OLED(sda,scl)

     sla = 0x3c

     i2c.setup(0, sda, scl, i2c.SLOW)

     disp=u8g2.sh1106_i2c_128x64_noname(0,sla)

     disp:setFontPosTop()

end

function print_OLED()

 disp:clearBuffer()

  disp:setFont(u8g2.font_unifont_t_chinese1)

   disp:drawGlyph(45, 3, 24180)

   disp:drawStr(1, 3, tostring(time["year"]))

    disp:drawStr(64, 3, tostring(time["mon"]))

     disp:drawStr(97, 3, tostring(time["day"]))

    disp:setFont(u8g2.font_unifont_t_chinese2)

   disp:drawGlyph(80, 3,26376)

 disp:setFont(u8g2.font_unifont_t_chinese2)

   disp:drawGlyph(115, 3,26085)

disp:drawLine(10,25,120,25)

   disp:setFont(u8g2.font_unifont_t_chinese2)

   disp:drawGlyph(44, 30,26102)

    disp:drawStr(28, 30, tostring(time["hour"]+8))

     disp:drawStr(60, 30, tostring(time["min"]))

      disp:drawStr(97, 30, tostring(time["sec"]))

  disp:setFont(u8g2.font_unifont_t_chinese1)

   disp:drawGlyph(80, 30, 20998)

   以上部分代嗎,三天的時間,主要是做個總結,需要全部代碼的。聯系我,[email protected]

nodemcu(esp8266)u8g2 oled顯示漢字擷取網絡時間

繼續閱讀