You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.4 KiB
81 lines
2.4 KiB
Id = 0 |
|
Sda = 5 -- GPIO14 |
|
Scl = 6 -- GPIO12 |
|
Sla = 0x3c |
|
i2c.setup(Id, Sda, Scl, i2c.SLOW) |
|
Disp = u8g2.ssd1306_i2c_128x64_noname(Id, Sla) |
|
print("Oled Init Success!"); |
|
|
|
Screen_WIFINAME = ""; |
|
Screen_IPADDRESS = ""; |
|
Screen_VERSION = ""; |
|
--tips to user link-AP |
|
function PageAPNet() |
|
Disp:clearBuffer() |
|
--Disp:setFont(u8g2.font_unifont_t_symbols); |
|
Disp:setFont(u8g2.font_unifont_t_symbols); |
|
Disp:drawStr(0,10,"AP-LinkMode"); |
|
Disp:setFont(u8g2.font_6x10_tf); |
|
Disp:drawStr(0,26,"Please use your"); |
|
Disp:drawStr(0,36,"mobile phone search"); |
|
Disp:drawStr(0,46,"and link ap-point"); |
|
Disp:drawStr(0,56,"DY-Light-Controller"); |
|
Disp:updateDisplay(); |
|
end |
|
|
|
--progress:1-100,tips loading and update from server |
|
function PageLoading(progress) |
|
Disp:clearBuffer(); |
|
--Disp:setFont(u8g2.font_unifont_t_symbols); |
|
Disp:setFont(u8g2.font_unifont_t_symbols); |
|
Disp:drawStr(40,10,"DYTech"); |
|
Disp:setFont(u8g2.font_6x10_tf); |
|
Disp:drawStr(16,32,"Check for update"); |
|
Disp:drawFrame(12,42,104,10); |
|
Disp:drawBox(14,44,progress,6); |
|
Disp:updateDisplay(); |
|
end |
|
|
|
-- |
|
function PageMainScene(wifiName,ipAddress,version) |
|
Disp:clearBuffer(); |
|
DrawMainScene(wifiName,ipAddress,version) |
|
Disp:updateDisplay(); |
|
Screen_WIFINAME = wifiName; |
|
Screen_IPADDRESS = ipAddress; |
|
Screen_VERSION = version; |
|
--Disp:sendBuffer(); |
|
end |
|
|
|
function DrawMainScene(wifiName,ipAddress,version) |
|
--Disp:setFont(u8g2.font_unifont_t_symbols); |
|
Disp:setFont(u8g2.font_unifont_t_symbols); |
|
Disp:drawStr(40,10,"DYTech"); |
|
Disp:setFont(u8g2.font_6x10_tf); |
|
Disp:drawStr(0,26,"Wifi:"..wifiName); |
|
Disp:drawStr(0,36,"Light Ctrl-UDP"..version); |
|
Disp:drawStr(0,46,"S:"..ipAddress..":5000"); |
|
end |
|
|
|
function PageLight(lightArr) |
|
Disp:clearBuffer(); |
|
DrawMainScene(Screen_WIFINAME,Screen_IPADDRESS,Screen_VERSION); |
|
Disp:drawCircle(16,56,4,u8g2.U8G2_DRAW_ALL); |
|
Disp:drawCircle(32,56,4,u8g2.U8G2_DRAW_ALL); |
|
Disp:drawCircle(48,56,4,u8g2.U8G2_DRAW_ALL); |
|
Disp:drawCircle(64,56,4,u8g2.U8G2_DRAW_ALL); |
|
for index, value in ipairs(lightArr) do |
|
if value then |
|
Disp:drawDisc(16*index,56,4,u8g2.U8G2_DRAW_ALL); |
|
end |
|
end |
|
Disp:sendBuffer(); |
|
--Disp:updateDisplayArea(0,0,64,64); |
|
end |
|
|
|
--PageMainScene("DF2","192.168.1.111","V1.0") |
|
--LightArr = {[1]=true,[2]=false,[3]=true,[4]=true} |
|
--PageLight(LightArr) |
|
--LightArr[1] = false; |
|
--PageLight(LightArr) |
|
PageAPNet()
|
|
|