Skip to content

Instantly share code, notes, and snippets.

@PogiNate
Last active August 25, 2020 16:43
Show Gist options
  • Save PogiNate/b5d4d4ac7ca33e814d893a97384cbd78 to your computer and use it in GitHub Desktop.
Save PogiNate/b5d4d4ac7ca33e814d893a97384cbd78 to your computer and use it in GitHub Desktop.
A simple layout for the Pimoroni Keybow.
-- Sideways Desktop Layout
-- Cord Comes Out Here Cord Comes Out Here
--
-- │ │
-- │ │
-- ▼ ▼
-- ┌────┬────┬────┬────┐ ┌────┬────┬────┬────┐
-- │ 11 │ 8 │ 5 │ 2 │ │LED │ F6 │ F7 │ F8 │ <- Global Shortcuts, Purple
-- │ │ │ │ │ │I/O │ │ │ │
-- ├────┼────┼────┼────┤ ├────┼────┼────┼────┤
-- │ 10 │ 7 │ 4 │ 1 │ │ <- │Play|Mute| -> │ <- Media Keys, greens
-- │ │ │ │ │ │ │Pau │ │ │
-- ├────┼────┼────┼────┤ ├────┼────┼────┼────┤
-- │ 9 │ 6 │ 3 │ 0 │ │ F1 │ F2 │ F3 │ F4 │ <- App-specific Assignable , Violet
-- │ │ │ │ │ │ │ │ │ │
-- └────┴────┴────┴────┘ └────┴────┴────┴────┘
-- ┌───────────────┐ ┌───────────────┐
-- │ Key Addresses │ │ Key Values │
-- └───────────────┘ └───────────────┘
require "keybow"
lights_are_on = false
function lights_on()
keybow.auto_lights(false)
keybow.clear_lights()
keybow.set_pixel(0, 49 , 57 , 198) -- Violet
keybow.set_pixel(1, 69 , 160, 61 ) -- Clover Green
keybow.set_pixel(2, 75 , 0 , 130) -- Purple
keybow.set_pixel(3, 49 , 57 , 198) -- Violet
keybow.set_pixel(4, 49 , 198, 116) -- Green
keybow.set_pixel(5, 75 , 0 , 130) -- Purple
keybow.set_pixel(6, 49 , 57 , 198) -- Violet
keybow.set_pixel(7, 49 , 198, 116) -- Green
keybow.set_pixel(8, 75 , 0 , 130) -- Purple
keybow.set_pixel(9, 49 , 57, 198) -- Violet
keybow.set_pixel(10, 69 , 160, 61 ) -- Clover Green
keybow.set_pixel(11, 255, 165, 0 ) -- Orange
lights_are_on = true
end
function lights_off()
keybow.auto_lights(false)
keybow.clear_lights()
lights_are_on = false
end
function setup() -- Set custom lights up
lights_on()
end
function allmods(key, pressed)
keybow.set_modifier(keybow.LEFT_META, keybow.KEY_DOWN)
keybow.set_modifier(keybow.LEFT_CTRL, keybow.KEY_DOWN)
keybow.set_modifier(keybow.LEFT_ALT, keybow.KEY_DOWN)
keybow.set_modifier(keybow.LEFT_SHIFT, keybow.KEY_DOWN)
keybow.tap_key(key, pressed)
keybow.set_modifier(keybow.LEFT_META, keybow.KEY_UP)
keybow.set_modifier(keybow.LEFT_CTRL, keybow.KEY_UP)
keybow.set_modifier(keybow.LEFT_ALT, keybow.KEY_UP)
keybow.set_modifier(keybow.LEFT_SHIFT, keybow.KEY_UP)
end
function handle_key_00(pressed)
if pressed then
allmods(keybow.F4,pressed)
end
end
function handle_key_01(pressed)
keybow.set_media_key(keybow.MEDIA_NEXT,pressed)
end
function handle_key_02(pressed)
if pressed then
allmods(keybow.F8,pressed)
end
end
function handle_key_03(pressed)
if pressed then
allmods(keybow.F3,pressed)
end
end
function handle_key_04(pressed)
keybow.set_media_key(keybow.MEDIA_MUTE, pressed)
end
function handle_key_05(pressed)
if pressed then
allmods(keybow.F7,pressed)
end
end
function handle_key_06(pressed)
if pressed then
allmods(keybow.F2,pressed)
end
end
function handle_key_07(pressed)
keybow.set_media_key(keybow.MEDIA_PLAYPAUSE, pressed)
end
function handle_key_08(pressed)
if pressed then
allmods(keybow.F6,pressed)
end
end
function handle_key_09(pressed)
if pressed then
allmods(keybow.F1,pressed)
end
end
function handle_key_10(pressed)
keybow.set_media_key(keybow.MEDIA_PREV, pressed)
end
function handle_key_11(pressed)
if pressed then
if lights_are_on==true then
lights_off()
else
lights_on()
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment