Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By vcch
#45161 Hi !

I ordered the wemos oled shield (64x48) but can't make it work

I soldered the shield on the Wemos D1, soldering each pin

I'm using the original firmware (contains u8g library & supports ssd1306 i2c)

I'm using the following script

sda = 2
scl = 1
sla = 0x3c
txt="XXX"
i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.ssd1306_64x48_i2c(sla)
disp:setFont(u8g.font_6x10)
disp:setFontRefHeightExtendedText()
disp:setDefaultForegroundColor()
disp:setFontPosTop()

disp:drawStr(0, 0, "drawBox")
disp:drawBox(5, 10, 20, 10)
disp:drawBox(10, 15, 30, 7)
disp:drawStr(0, 30, "drawFrame")
disp:drawFrame(5, 10+30, 20, 10)
disp:drawFrame(10, 15+30, 30, 7)

3)All i get is a screen with random dots. Unable to draw, clear or anything. Help !
User avatar
By hkubota
#52824 Hi,

Probably (by now) a solved problem, but since I could not find easily a good example, here is what works (adopted from the u8g library, specifically https://github.com/nodemcu/nodemcu-firm ... s_test.lua):

Code: Select all-- ***************************************************************************
-- Rotation Test
--
-- This script executes the rotation features of u8glib to test their Lua
-- integration.
--
-- Note: It is prepared for SSD1306-based displays. Select your connectivity
--       type by calling either init_i2c_display() or init_spi_display() at
--       the bottom of this file.
--
-- ***************************************************************************

-- setup I2c and connect display
function init_i2c_display()
     -- SDA and SCL can be assigned freely to available GPIOs
     local sda = 2 -- 5 -- GPIO14
     local scl = 1 -- 6  -- GPIO12
     local sla = 0x3c
     i2c.setup(0, sda, scl, i2c.SLOW)
     disp = u8g.ssd1306_64x48_i2c(sla)
end


-- the draw() routine
function draw()
     disp:setFont(u8g.font_6x10)
     --disp:drawCircle(64,40,20)
     disp:drawCircle(32,24,10)
     
     disp:drawStr( 0+0, 20+0, "Hello!")
     disp:drawStr( 0+2, 20+16, "Hello!")

     disp:drawBox(0, 0, 3, 3)
     disp:drawBox(disp:getWidth()-6, 0, 6, 6)
     disp:drawBox(disp:getWidth()-9, disp:getHeight()-9, 9, 9)
     disp:drawBox(0, disp:getHeight()-12, 12, 12)
end


function rotate()
     if (next_rotation < tmr.now() / 1000) then
          if (dir == 0) then
               disp:undoRotation()
          elseif (dir == 1) then
               disp:setRot90()
          elseif (dir == 2) then
               disp:setRot180()
          elseif (dir == 3) then
               disp:setRot270()
          end

          dir = dir + 1
          dir = bit.band(dir, 3)
          -- schedule next rotation step in 1000ms
          next_rotation = tmr.now() / 1000 + 1000
     end
end

function rotation_test()
     print("--- Starting Rotation Test ---")
     dir = 0
     next_rotation = 0
    print("size:", disp:getWidth(), disp:getHeight())
     local loopcnt
     for loopcnt = 1, 100, 1 do
          rotate()

          disp:firstPage()
          repeat
               draw(draw_state)
          until disp:nextPage() == false

          tmr.delay(100000)
          tmr.wdclr()
     end

     print("--- Rotation Test done ---")
end

init_i2c_display()
rotation_test()


Harald