Skip to content

Instantly share code, notes, and snippets.

@loudoweb
Created May 19, 2022 10:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save loudoweb/a4de44ec5438b6514c3e91d30138af9e to your computer and use it in GitHub Desktop.
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