Just to get a better handle on the I2C thing, I put together a little digital clock using this display...
https://www.adafruit.com/products/1268
I am using a ESP-01 so this project can be very small.
My I2C struggle is documented here...
viewtopic.php?f=45&t=7115
and I learned that a logic analyzer is invaluable when playing with this stuff.
I am sure this code could be better, but it works for now. I will update it as I progress, like getting the colon to flash and am/pm indicator, etc. As you can see, the time is checked every 5 seconds and the display is updated. More to come...
memclear
cls
'initialize display
address = 112
i2c.begin(address)
i2c.write(33)
i2c.end()
i2c.begin(address)
i2c.write(129)
i2c.end()
i2c.begin(address)
i2c.write(239)
i2c.end()
delay 10
timesetup(-5,0)
delay 750
timer 5000 [refresh]
wait
[refresh]
cls
button "Exit " [Exit]
print time()
disp = time()
z = mid(disp,13,1) 'hour ones
gosub [conv]
b = x
z = mid(disp,12,1) 'hour tens
gosub [conv]
a = x
z = mid(disp,16,1) 'minutes ones
gosub [conv]
d = x
z = mid(disp,15,1) 'minutes tens
gosub [conv]
c = x
gosub [wdisp]
wait
[wdisp]
i2c.begin(address)
i2c.write(0)
i2c.write(a)
i2c.end()
delay 10
i2c.begin(address)
i2c.write(2)
i2c.write(b)
i2c.end()
delay 10
i2c.begin(address)
i2c.write(6)
i2c.write(c)
i2c.end()
delay 10
i2c.begin(address)
i2c.write(8)
i2c.write(d)
i2c.end()
return
[Exit]
timer 0
wprint "<a href='/'>Menu</a>"
end
[conv]
if z = 0 then x = 63
if z = 1 then x = 6
if z = 2 then x = 91
if z = 3 then x = 79
if z = 4 then x = 102
if z = 5 then x = 109
if z = 6 then x = 125
if z = 7 then x = 7
if z = 8 then x = 127
if z = 9 then x = 111
return