first server files
This commit is contained in:
parent
6afab56c43
commit
56da8aea6c
3 changed files with 84 additions and 0 deletions
1
server/autorun.lua
Normal file
1
server/autorun.lua
Normal file
|
@ -0,0 +1 @@
|
||||||
|
dofile("main.lua")
|
10
server/main.lua
Normal file
10
server/main.lua
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
dofile("screen.lua")
|
||||||
|
|
||||||
|
-- connecte l'écran sur les pins 18 et 19
|
||||||
|
attachscreen(18, 19, 0x3C)
|
||||||
|
|
||||||
|
-- connecte la bande de led sur le pin 21
|
||||||
|
neo = neopixel.attach(neopixel.WS2812B, pio.GPIO21, 8)
|
||||||
|
|
||||||
|
cls()
|
||||||
|
console("test")
|
73
server/screen.lua
Normal file
73
server/screen.lua
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
function attachscreen(sda, scl, i2cadd)
|
||||||
|
try (
|
||||||
|
function ()
|
||||||
|
i2c.setpins(0,sda,scl)
|
||||||
|
gdisplay.attach(gdisplay.SSD1306_128_64, gdisplay.LANDSCAPE, false, i2cadd)
|
||||||
|
gdisplay.clear()
|
||||||
|
gdisplay.setfont(gdisplay.FONT_LCD)
|
||||||
|
gdisplay.setwrap(false)
|
||||||
|
end,
|
||||||
|
|
||||||
|
function (where, line, error, message)
|
||||||
|
print("Couldn't attach the screen.\nError in "..where.." at "..line.." "..error..": "..message)
|
||||||
|
end,
|
||||||
|
|
||||||
|
function () end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
local consolepos = 0
|
||||||
|
local consoletab = {}
|
||||||
|
local consolemax = 6
|
||||||
|
local oledflip = 1
|
||||||
|
|
||||||
|
function flip()
|
||||||
|
oledflip = oledflip+1; if oledflip > 3 then oledflip = 0 end
|
||||||
|
if oledflip==0 then
|
||||||
|
consolemax = 6
|
||||||
|
gdisplay.attach(gdisplay.SSD1306_128_64, gdisplay.LANDSCAPE_FLIP, false, i2cadd)
|
||||||
|
elseif oledflip==1 then
|
||||||
|
consolemax = 6
|
||||||
|
gdisplay.attach(gdisplay.SSD1306_128_64, gdisplay.LANDSCAPE, false, i2cadd)
|
||||||
|
elseif oledflip==2 then
|
||||||
|
consolemax = 13
|
||||||
|
gdisplay.attach(gdisplay.SSD1306_128_64, gdisplay.PORTRAIT, false, i2cadd)
|
||||||
|
else
|
||||||
|
consolemax = 13
|
||||||
|
gdisplay.attach(gdisplay.SSD1306_128_64, gdisplay.PORTRAIT_FLIP, false, i2cadd)
|
||||||
|
end
|
||||||
|
cls()
|
||||||
|
end
|
||||||
|
|
||||||
|
function cls()
|
||||||
|
if (consolemax==6) then gdisplay.clear()
|
||||||
|
else
|
||||||
|
gdisplay.rect( {0,0}, 128, 9*consolemax, {0,0,0}, {0,0,0} )
|
||||||
|
end
|
||||||
|
if oledflip ~= 1 then gdisplay.clear() end
|
||||||
|
consolepos = 0
|
||||||
|
consoletab={}
|
||||||
|
for i=0, consolemax do
|
||||||
|
consoletab[i] = ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function console(msg)
|
||||||
|
if (consolepos <= consolemax) then
|
||||||
|
consoletab[consolepos] = msg
|
||||||
|
gdisplay.write({0, consolepos*9},msg)
|
||||||
|
consolepos = consolepos+1
|
||||||
|
else
|
||||||
|
for i = 1, consolemax do
|
||||||
|
consoletab[i-1] = consoletab[i]
|
||||||
|
end
|
||||||
|
consoletab[consolemax] = msg
|
||||||
|
if (consolemax==6) then gdisplay.clear()
|
||||||
|
else
|
||||||
|
gdisplay.rect( {0,0}, 128, 9*consolemax+9, {0,0,0}, {0,0,0} )
|
||||||
|
end
|
||||||
|
for i=0, consolemax do
|
||||||
|
gdisplay.write({0, i*9},consoletab[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue