1. 最后点击生成固件:
1. 最终固件会发到你的邮箱,需要24小时内下载(会生成两个固件,一个是整型数的固件,以integer结尾;另一个是浮点型的固件,以float结尾),两个固件都下载,实际上只要用到整型的固件就行了
连接成功大概如下图,会有部分乱码,不要在意
代码还算比较浅显,应该容易看懂的,均为lua代码
NodeMCU板子上,D5接12864的sda口
NodeMCU板子上,D6接12864的scl口
NodeMCU板子上,G(低电平的意思)接12864的GND
NodeMCU板子上,3V接12864的VCC口
function init_i2c_display()
-- SDA and SCL can be assigned freely to available GPIOs
local sda = 5 -- GPIO14
local scl = 6 -- GPIO12
local sla = 0x3c
i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g2.ssd1306_i2c_128x64_noname(0, sla)
end
function u8g2_prepare()
disp:setFont(u8g2.font_6x10_tf)
disp:setFontRefHeightExtendedText()
disp:setDrawColor(1)
disp:setFontPosTop()
disp:setFontDirection(0)
end
function u8g2_ascii_1()
head="Honey Z"
content=" I will go away."
content1=' The farther I go,'
content2=' the more I miss you.'
tail="CQ "
headlen=string.len(head)
contentlen=string.len(content)
contentlen1=string.len(content1)
contentlen2=string.len(content2)
taillen=string.len(tail)
if(a <= headlen)then
disp:drawStr( 0, 2, string.sub(head,1,a)..'_')
else
disp:drawStr( 0, 2, string.sub(head,1,a))
end
if(a > headlen and a <= headlen+contentlen) then
disp:drawStr( 9, 16, string.sub(content,1,a-headlen)..'_')
elseif(a > headlen) then
disp:drawStr( 9, 16, string.sub(content,1,a-headlen))
end
if(a > headlen+contentlen and a <= headlen+contentlen+contentlen1) then
disp:drawStr( 9, 28, string.sub(content1,1,a-headlen-contentlen)..'_')
elseif(a > headlen+contentlen) then
disp:drawStr( 9, 28, string.sub(content1,1,a-headlen-contentlen))
end
if(a > headlen+contentlen+contentlen1 and a <= headlen+contentlen+contentlen1+contentlen2) then
disp:drawStr( 9, 40, string.sub(content2,1,a-headlen-contentlen-contentlen1)..'_')
elseif(a > headlen+contentlen+contentlen1) then
disp:drawStr( 9, 40, string.sub(content2,1,a-headlen-contentlen-contentlen1))
end
if(a > headlen+contentlen+contentlen1+contentlen2 ) then
disp:drawStr( 112, 54, string.sub(tail,1,a- headlen-contentlen-contentlen1-contentlen2)..'_')
end
end
function loop()
disp:clearBuffer()
u8g2_prepare()
u8g2_ascii_1()
disp:sendBuffer()
end
b=1
a=0
init_i2c_display()
tmr.alarm(4, 300, tmr.ALARM_AUTO, function()
b=b+1
if(b > 7) then
a=a+1
end
loop()
end
)
手机扫一扫
移动阅读更方便
你可能感兴趣的文章