Created
April 4, 2023 09:16
-
-
Save yhara/354ee686532924d0587e01881b70aa48 to your computer and use it in GitHub Desktop.
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
kbd = Keyboard.new | |
kbd.init_direct_pins( | |
# For SparkFun RP2040 ProMicro | |
# https://learn.sparkfun.com/tutorials/pro-micro-rp2040-hookup-guide | |
[2, 3, 4, 5, 6, 7, 8, 9, | |
29, 28, 27, 26, 22, 20, 23, 21] | |
# See this if you are using Adafruit Kb2040 | |
# https://github.com/alg0002/PRK_Firmware_keymap_rb/blob/main/Kasumigasane/KB2040/keymap.rb | |
) | |
#kbd.add_layer :default, %i[ | |
# KC_1 KC_2 KC_3 KC_4 | |
# KC_5 KC_6 KC_7 KC_8 | |
# KC_9 KC_0 KC_A KC_B | |
# KC_C KC_D KC_E KC_F | |
#] | |
kbd.add_layer :default, %i[ | |
KC_7 KC_8 KC_9 KC_BSPC | |
KC_4 KC_5 KC_6 KC_ENT | |
KC_1 KC_2 KC_3 KC_COLON | |
KC_0 KC_PLUS KC_DOT KC_SLASH | |
] | |
class RGB | |
def show | |
if @offed | |
ws2812_fill(0, @pixel_size) | |
sleep 1 | |
return | |
end | |
(1..16).each do |i| | |
color = | |
if i%15 == 0 then hsv2rgb(0, @saturation, @max_value) | |
elsif i%5 == 0 then hsv2rgb(25, @saturation, @max_value) | |
elsif i%3 == 0 then hsv2rgb(50, @saturation, @max_value) | |
else 0 | |
end | |
ws2812_set_pixel_at(i-1, color) | |
end | |
ws2812_show() | |
#ws2812_fill(hsv2rgb(@hue, @saturation, @max_value), @pixel_size) | |
sleep_ms @delay | |
end | |
end | |
rgb = RGB.new( | |
1, # pin number | |
0, # size of underglow pixel | |
16, # size of backlight pixel | |
false # 32bit data will be sent to a pixel if true while 24bit if false | |
) | |
rgb.add_pixel(0, 64) | |
rgb.add_pixel(16, 64) | |
rgb.add_pixel(32, 64) | |
rgb.add_pixel(64, 64) | |
rgb.add_pixel(64, 32) | |
rgb.add_pixel(32, 32) | |
rgb.add_pixel(16, 32) | |
rgb.add_pixel(0, 32) | |
rgb.add_pixel(0, 16) | |
rgb.add_pixel(16, 16) | |
rgb.add_pixel(32, 16) | |
rgb.add_pixel(64, 16) | |
rgb.add_pixel(0, 0) | |
rgb.add_pixel(16, 0) | |
rgb.add_pixel(32, 0) | |
rgb.add_pixel(64, 0) | |
rgb.effect = :static | |
rgb.speed = 22 #31 # 1-31 / default: 22 | |
rgb.hue = 0 # 0-100 / default: 0 | |
rgb.saturation = 100 # 0-100 / default: 100 | |
rgb.value = 13 # 1-31 / default: 13 | |
kbd.append rgb | |
kbd.start! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment