This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "keybow" | |
time = 0 | |
isKeyDown_00 = false | |
isKeyDown_01 = false | |
isKeyDown_02 = false | |
hasPipiTop = true | |
timer_00 = 0 | |
timer_00b = 0 | |
timer_01 = 0 | |
timer_02 = 0 | |
maxTime_00 = 23 * 60 * 60 * 1000 | |
maxTime_00b = 21 * 24 * 60 * 60 * 1000 | |
maxTime_01 = 30 * 24 * 60 * 60 * 1000 | |
maxTime_02 = 2 * 24 * 60 * 60 * 1000 | |
-- maxTime_00 = 10000 | |
-- maxTime_00b = 30 * 1000 | |
-- maxTime_01 = 60 * 1000 | |
-- maxTime_02 = 10 * 1000 | |
function setup() | |
keybow.use_mini() | |
keybow.auto_lights(false) | |
keybow.clear_lights() | |
keybow.set_pixel(0, 240, 195, 0) | |
keybow.set_pixel(1, 0, 0, 255) | |
keybow.set_pixel(2, 31, 200, 85) | |
end | |
function tick() | |
time = time + 1 | |
-- change color | |
if time > timer_00 and timer_00 > 0 then | |
keybow.set_pixel(0, 240, 195, 0) | |
timer_00 = 0 | |
hasPipiTop = true | |
end | |
if time > timer_00b and timer_00b > 0 then | |
keybow.set_pixel(0, 173, 79, 9) | |
timer_00b = 0 | |
hasPipiTop = false | |
end | |
if time > timer_01 and timer_01 > 0 then | |
keybow.set_pixel(1, 0, 0, 255) | |
timer_01 = 0 | |
end | |
if time > timer_02 and timer_02 > 0 then | |
keybow.set_pixel(2, 31, 200, 85) | |
timer_02 = 0 | |
end | |
end | |
-- Standard number pad mapping -- | |
-- Key mappings -- | |
function handle_minikey_00(pressed) | |
--litiere | |
if pressed then | |
if hasPipiTop and timer_00 == 0 then | |
timer_00 = time + maxTime_00 | |
hasPipiTop = false | |
elseif timer_00b == 0 then | |
timer_00b = time + maxTime_00b | |
hasPipiTop = true | |
end | |
if timer_00 > 0 and timer_00b > 0 then | |
keybow.set_pixel(0, 0, 0, 0) | |
elseif timer_00b > 0 then | |
keybow.set_pixel(0, 240, 195, 0) | |
elseif timer_00 > 0 then | |
keybow.set_pixel(0, 173, 79, 9) | |
end | |
end | |
isKeyDown_00 = pressed | |
end | |
function handle_minikey_01(pressed) | |
--filtre eau | |
if pressed and timer_01 == 0 then | |
keybow.set_pixel(1, 0, 0, 0) | |
timer_01 = time + maxTime_01 | |
end | |
isKeyDown_01 = pressed | |
end | |
function handle_minikey_02(pressed) | |
-- eau plante | |
if pressed and timer_02 == 0 then | |
keybow.set_pixel(2, 0, 0, 0) | |
timer_02 = time + maxTime_02 | |
end | |
isKeyDown_02 = pressed | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment