commit
This commit is contained in:
parent
e92123ab22
commit
9a82196fd1
3 changed files with 104 additions and 84 deletions
47
main.lua
47
main.lua
|
@ -19,6 +19,53 @@ function printTemp()
|
|||
print("Température du CPU :", cpu.temperature())
|
||||
end
|
||||
|
||||
-- fonction permettant de trouver l'addresse I2C d'un écran OLED
|
||||
function findaddr()
|
||||
i2c.setpins(1, 18, 19)
|
||||
ic = i2c.attach(i2c.I2C1, i2c.MASTER)
|
||||
|
||||
for i = 0, 127 do
|
||||
try(
|
||||
function ()
|
||||
ic:start()
|
||||
ic:address(i, false)
|
||||
ic:stop()
|
||||
print(string.format("found # %x", i))
|
||||
end,
|
||||
|
||||
function()
|
||||
print("failed")
|
||||
end,
|
||||
|
||||
function() end
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function min(tab)
|
||||
local min = tab[1]
|
||||
for i=1,#tab do
|
||||
if tab[i] < min then min = tab[i] end
|
||||
end
|
||||
return min
|
||||
end
|
||||
|
||||
function max(tab)
|
||||
local max = tab[1]
|
||||
for i=1,#tab do
|
||||
if tab[i] > max then max = tab[i] end
|
||||
end
|
||||
return max
|
||||
end
|
||||
|
||||
function avg(tab)
|
||||
local sum = 0
|
||||
for i=1,#tab do
|
||||
sum = sum + tab[i]
|
||||
end
|
||||
return sum / #tab
|
||||
end
|
||||
|
||||
-- charge tout nos fichiers lua
|
||||
dofile("leds.lua")
|
||||
dofile("buzz.lua")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue