ca clignote :)
This commit is contained in:
parent
a2b0006d11
commit
61442993eb
1 changed files with 23 additions and 1 deletions
|
@ -13,7 +13,7 @@ console("Connecting...")
|
|||
client:connect("student", password)
|
||||
console("Connected !")
|
||||
|
||||
if neo ~= nil then
|
||||
if neo == nil then
|
||||
-- connecte la bande de led sur le pin 21
|
||||
neo = neopixel.attach(neopixel.WS2812B, pio.GPIO21, 8)
|
||||
end
|
||||
|
@ -37,6 +37,26 @@ function get_public_word()
|
|||
return r
|
||||
end
|
||||
|
||||
function set_color(r, g, b)
|
||||
for i=0, 7 do
|
||||
neo:setPixel(i, r, g, b)
|
||||
end
|
||||
end
|
||||
|
||||
function blink(positive)
|
||||
thread.start(function()
|
||||
if positive then
|
||||
set_color(0, 5, 0)
|
||||
else
|
||||
set_color(5, 0, 0)
|
||||
end
|
||||
neo:update()
|
||||
tmr.delayms(50)
|
||||
set_color(0, 0, 0)
|
||||
neo:update()
|
||||
end)
|
||||
end
|
||||
|
||||
function draw_ui()
|
||||
cls()
|
||||
if playing then
|
||||
|
@ -129,6 +149,7 @@ function handle_letter(len, message, topic_len, topic_name)
|
|||
end
|
||||
letters_played = letters_played .. message
|
||||
if not is_in_word(message) then
|
||||
blink(false)
|
||||
lives = lives - 1
|
||||
if lives == 0 then
|
||||
playing = false
|
||||
|
@ -141,6 +162,7 @@ function handle_letter(len, message, topic_len, topic_name)
|
|||
console("du mot...")
|
||||
return
|
||||
end
|
||||
blink(true)
|
||||
if not is_won() then
|
||||
draw_ui()
|
||||
console(message .. " trouve ! Bien joue !")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue