Left for archival purposes.

User avatar
By Mikejstb
#12284 Got a little mqtt message displayer working today.
Shows the topic, the date/time (sent once per minute from node-red) and the last two messages received.
it scrolls the messages up as they arrive.
I think it just squeeks by the memory limitations of nodemcu.

So far it's running on one of those 201-proto boards, my plan is to make a little board with an ESP to go behind the oled, plus a little lipo battery, to make a little portable message viewer so I don't have to keep using other clumsier methods to watch my ESP/node-red home monitors.

Thanks for the library!
Attachments
mqttMessageCenter.jpg
User avatar
By alon24
#12285 Can you share code?
I a trying to make the same thing.
I am currently trying to make a module for writing to the oled, because I think it should be one file that handles logic, and another (module?) that does the writing.

It would be helpfull to see what u have.

Thanks
User avatar
By alon24
#12286 also with ug8 how do I clear screen?
clear 1 line?
write a line instead of a line?

I am doing the module using flashmod, currently not going well.....
(this is a work in progress)

Code: Select alllocal ug8_utils = {MOD_NAME = "ug8_utils"}
function ug8_utils:initI2C(sda_n, scl_n, addr_n)
   self.id = 0
   self.addr = addr_n
   self.sda = sda_n
   self.scl = scl_n
     -- SDA and SCL can be assigned freely to available GPIOs
   i2c.setup(self.id, self.sda, self.scl, i2c.SLOW)   
     self.disp = u8g.ssd1306_128x64_i2c(sla)
end

print('ug8_utils.lua - print msg')
function ug8_utils:prepare()
     self.disp.setFont(u8g.font_6x10)
     self.disp.setFontRefHeightExtendedText()
     self.disp.setDefaultForegroundColor()
     self.disp.setFontPosTop()
end

function ug8_utils:write(x,y,txt)
     print("--- Starting Ug8Lib draw ---")
     -- cycle through all components
     self.disp.firstPage()
     repeat
         self.prepare()
         self.disp.drawStr(x,y,txt)
      until self.disp.nextPage() == false
    tmr.wdclr()
    print("end write func")
end

flashMod(ug8_utils)
return ug8_utils