module RfRgb::Protocol
Constants
- BRIGHTNESS_HIGH
- BRIGHTNESS_LOW
- BRIGHTNESS_MEDIUM
- HEIGHT_15
Actuation heights
- HEIGHT_22
- HEIGHT_30
- INTERVAL_0
Only the Shooting Star effect uses these.
- INTERVAL_1
- INTERVAL_2
- INTERVAL_3
- INTERVAL_4
- INTERVAL_5
- INTERVAL_6
- INTERVAL_7
- INTERVAL_8
- INTERVAL_9
- USER_0
I'm not actually clear on the point of users, but here they are.
- USER_1
- USER_2
- USER_3
Public Class Methods
change_actuation_height_all(new_height)
click to toggle source
# File lib/rf_rgb/protocol.rb, line 133 def self.change_actuation_height_all(new_height) "\xaa\xaa\x20\x00\x01#{new_height}".force_encoding(Encoding::BINARY).freeze end
change_brightness(new_brightness)
click to toggle source
# File lib/rf_rgb/protocol.rb, line 129 def self.change_brightness(new_brightness) "\xaa\xaa\x42\x00\x01#{new_brightness}".force_encoding(Encoding::BINARY).freeze end
color_bar()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 113 def self.color_bar "\xaa\xaa\x68".force_encoding(Encoding::BINARY).freeze end
color_transform(color)
click to toggle source
# File lib/rf_rgb/protocol.rb, line 145 def self.color_transform(color) return nil unless color return color unless color.length == 6 # rrggbb string [color].pack('H*').force_encoding(Encoding::UTF_8) end
demo_mode()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 105 def self.demo_mode "\xaa\xaa\x66".force_encoding(Encoding::BINARY).freeze end
disable_effects()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 117 def self.disable_effects "\xaa\xaa\x69".force_encoding(Encoding::BINARY).freeze end
key_lock()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 121 def self.key_lock "\xaa\xaa\x82\x00\x01\x01".force_encoding(Encoding::BINARY).freeze end
key_unlock()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 125 def self.key_unlock "\xaa\xaa\x82\x00\x01\x00".force_encoding(Encoding::BINARY).freeze end
pressed_key_lighting(rgb_hex, user = :user0)
click to toggle source
# File lib/rf_rgb/protocol.rb, line 87 def self.pressed_key_lighting(rgb_hex, user = :user0) # byte number 6 (just before rgb) determines user. 0x00-0x03 "\xaa\xaa\x62\x00\x04\x00#{color_transform rgb_hex}".force_encoding(Encoding::BINARY).freeze end
pressed_key_lighting_with_backlight(rgb_hex, user = :user0)
click to toggle source
Backlight color can't be changed AFAICT. Always white.
# File lib/rf_rgb/protocol.rb, line 93 def self.pressed_key_lighting_with_backlight(rgb_hex, user = :user0) "\xaa\xaa\x63\x00\x04\x00#{color_transform rgb_hex}".force_encoding(Encoding::BINARY).freeze end
rainbow_wave()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 97 def self.rainbow_wave "\xaa\xaa\x61".force_encoding(Encoding::BINARY).freeze end
random_lights()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 109 def self.random_lights "\xaa\xaa\x67".force_encoding(Encoding::BINARY).freeze end
reset_effect()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 30 def self.reset_effect "\xaa\xaa\x60".force_encoding(Encoding::BINARY).freeze end
save_changes()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 34 def self.save_changes "\xaa\xaa\x04".force_encoding(Encoding::BINARY).freeze end
shooting_star(rgb_hex, interval, user = USER_0)
click to toggle source
# File lib/rf_rgb/protocol.rb, line 101 def self.shooting_star(rgb_hex, interval, user = USER_0) "\xaa\xaa\x64\x00\x05\x00#{interval}#{rgb_hex}".force_encoding(Encoding::BINARY).freeze end
swap_caps_ctrl()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 137 def self.swap_caps_ctrl "\xaa\xaa\x84\x00\x01\x01".force_encoding(Encoding::BINARY).freeze end
unswap_caps_ctrl()
click to toggle source
# File lib/rf_rgb/protocol.rb, line 141 def self.unswap_caps_ctrl "\xaa\xaa\x84\x00\x01\x00".force_encoding(Encoding::BINARY).freeze end
user_specified_actuation_heights(mapping)
click to toggle source
# File lib/rf_rgb/protocol.rb, line 53 def self.user_specified_actuation_heights(mapping) bytes = { '15' => HEIGHT_15, '22' => HEIGHT_22, '30' => HEIGHT_30 } m = lambda { |sym| bytes[mapping[sym].to_s] || bytes[mapping[:default].to_s] || HEIGHT_15 } [ "\xaa\xaa\x21\x41\x3b\x00#{m[:grave]}#{m[:one]}#{m[:two]}#{m[:three]}#{m[:four]}#{m[:five]}#{m[:six]}#{m[:seven]}#{m[:eight]}#{m[:nine]}#{m[:zero]}#{m[:hyphen]}#{m[:equals]}\x00#{m[:backspace]}#{m[:tab]}#{m[:q]}#{m[:w]}#{m[:e]}#{m[:r]}#{m[:t]}#{m[:y]}#{m[:u]}#{m[:i]}#{m[:o]}#{m[:p]}#{m[:lbracket]}#{m[:rbracket]}#{m[:backslash]}#{m[:capslock]}#{m[:a]}#{m[:s]}#{m[:d]}#{m[:f]}#{m[:g]}#{m[:h]}#{m[:j]}#{m[:k]}#{m[:l]}#{m[:semicolon]}#{m[:apostrophe]}\x00#{m[:enter]}#{m[:lshift]}\x00#{m[:z]}#{m[:x]}#{m[:c]}#{m[:v]}#{m[:b]}#{m[:n]}#{m[:m]}#{m[:comma]}#{m[:period]}#{m[:slash]}\x00#{m[:rshift]}#{m[:lctrl]}".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x21\x82\x3b\x00#{m[:lalt]}#{m[:space]}#{m[:ralt]}\x00#{m[:rctrl]}\x00\x00\x00#{m[:lwin]}#{m[:rwin]}#{m[:fn]}#{m[:mute]}#{m[:voldown]}#{m[:volup]}#{m[:actuation]}#{m[:ins]}#{m[:del]}\x00\x00#{m[:left]}#{m[:home]}#{m[:end]}\x00#{m[:up]}#{m[:down]}#{m[:pgup]}#{m[:pgdn]}\x00\x00#{m[:right]}#{m[:numlk]}#{m[:np_seven]}#{m[:np_four]}#{m[:np_one]}\x00#{m[:np_div]}#{m[:np_eight]}#{m[:np_five]}#{m[:np_two]}#{m[:np_zero]}#{m[:np_mult]}#{m[:np_nine]}#{m[:np_six]}#{m[:np_three]}#{m[:np_dot]}#{m[:np_minus]}#{m[:np_plus]}\x00#{m[:np_enter]}\x00#{m[:esc]}\x00#{m[:f1]}#{m[:f2]}#{m[:f3]}#{m[:f4]}#{m[:f5]}#{m[:f6]}".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x21\xc3\x0a#{m[:f7]}#{m[:f8]}#{m[:f9]}#{m[:f10]}#{m[:f11]}#{m[:f12]}#{m[:prtsc]}#{m[:scrlk]}#{m[:pause]}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze ] end
user_specified_colors(mapping, user = USER_1)
click to toggle source
# File lib/rf_rgb/protocol.rb, line 38 def self.user_specified_colors(mapping, user = USER_1) m = lambda { |sym| color_transform(mapping[sym]) || color_transform(mapping[:default]) || "\x00\x00\x00" } [ "\xaa\xaa\x40\x41\x3a#{user}\x00\x00\x00#{m[:grave]}#{m[:one]}#{m[:two]}#{m[:three]}#{m[:four]}#{m[:five]}#{m[:six]}#{m[:seven]}#{m[:eight]}#{m[:nine]}#{m[:zero]}#{m[:hyphen]}#{m[:equals]}\x00\x00\x00#{m[:backspace]}#{m[:tab]}#{m[:q]}#{m[:w]}\x00".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x40\x82\x3a#{user}#{m[:e]}#{m[:r]}#{m[:t]}#{m[:y]}#{m[:u]}#{m[:i]}#{m[:o]}#{m[:p]}#{m[:lbracket]}#{m[:rbracket]}#{m[:backslash]}#{m[:capslock]}#{m[:a]}#{m[:s]}#{m[:d]}#{m[:f]}#{m[:g]}#{m[:h]}#{m[:j]}\x00".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x40\x83\x3a#{user}#{m[:k]}#{m[:l]}#{m[:semicolon]}#{m[:apostrophe]}\x00\x00\x00#{m[:enter]}#{m[:lshift]}\x00\x00\x00#{m[:z]}#{m[:x]}#{m[:c]}#{m[:v]}#{m[:b]}#{m[:n]}#{m[:m]}#{m[:comma]}#{m[:period]}#{m[:slash]}\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x40\x84\x3a#{user}#{m[:rshift]}#{m[:lctrl]}\x00\x00\x00#{m[:lalt]}#{m[:space]}#{m[:ralt]}\x00\x00\x00#{m[:rctrl]}\x00\x00\x00\x00\x00\x00\x00\x00\x00#{m[:lwin]}#{m[:rwin]}#{m[:fn]}#{m[:mute]}#{m[:voldown]}#{m[:volup]}#{m[:actuation]}#{m[:ins]}\x00".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x40\x85\x3a#{user}#{m[:del]}\x00\x00\x00\x00\x00\x00#{m[:left]}#{m[:home]}#{m[:end]}\x00\x00\x00#{m[:up]}#{m[:down]}#{m[:pgup]}#{m[:pgdn]}\x00\x00\x00\x00\x00\x00#{m[:right]}#{m[:numlk]}#{m[:np_seven]}#{m[:np_four]}#{m[:np_one]}\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x40\x86\x3a#{user}#{m[:np_div]}#{m[:np_eight]}#{m[:np_five]}#{m[:np_two]}#{m[:np_zero]}#{m[:np_mult]}#{m[:np_nine]}#{m[:np_six]}#{m[:np_three]}#{m[:np_dot]}#{m[:np_minus]}#{m[:np_plus]}\x00\x00\x00#{m[:np_enter]}\x00\x00\x00#{m[:esc]}\x00\x00\x00#{m[:f1]}#{m[:f2]}\x00".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x40\xc7\x2b#{user}#{m[:f3]}#{m[:f4]}#{m[:f5]}#{m[:f6]}#{m[:f7]}#{m[:f8]}#{m[:f9]}#{m[:f10]}#{m[:f11]}#{m[:f12]}#{m[:prtsc]}#{m[:scrlk]}#{m[:pause]}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x44\x00\x0d#{user}".force_encoding(Encoding::BINARY).freeze ] end
user_specified_key_locks(mapping)
click to toggle source
TODO this doesn't seem to do anything.
# File lib/rf_rgb/protocol.rb, line 70 def self.user_specified_key_locks(mapping) # aa:aa:80:41:3b:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 # aa:aa:80:82:3b:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01:00:01:00:00:00:00:00 # aa:aa:80:c3:0a:00:01:00:00:01:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01:00:01:00:00:00:00:00 bytes = { true: "\x01", false: "\x00" } m = lambda { |sym| bytes[mapping[sym]] || bytes[mapping[:default]] || false } [ "\xaa\xaa\x80\x41\x3b\x00#{m[:grave]}#{m[:one]}#{m[:two]}#{m[:three]}#{m[:four]}#{m[:five]}#{m[:six]}#{m[:seven]}#{m[:eight]}#{m[:nine]}#{m[:zero]}#{m[:hyphen]}#{m[:equals]}\x00#{m[:backspace]}#{m[:tab]}#{m[:q]}#{m[:w]}#{m[:e]}#{m[:r]}#{m[:t]}#{m[:y]}#{m[:u]}#{m[:i]}#{m[:o]}#{m[:p]}#{m[:lbracket]}#{m[:rbracket]}#{m[:backslash]}#{m[:capslock]}#{m[:a]}#{m[:s]}#{m[:d]}#{m[:f]}#{m[:g]}#{m[:h]}#{m[:j]}#{m[:k]}#{m[:l]}#{m[:semicolon]}#{m[:apostrophe]}\x00#{m[:enter]}#{m[:lshift]}\x00#{m[:z]}#{m[:x]}#{m[:c]}#{m[:v]}#{m[:b]}#{m[:n]}#{m[:m]}#{m[:comma]}#{m[:period]}#{m[:slash]}\x00#{m[:rshift]}#{m[:lctrl]}".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x80\x82\x3b\x00#{m[:lalt]}#{m[:space]}#{m[:ralt]}\x00#{m[:rctrl]}\x00\x00\x00#{m[:lwin]}#{m[:rwin]}#{m[:fn]}#{m[:mute]}#{m[:voldown]}#{m[:volup]}#{m[:actuation]}#{m[:ins]}#{m[:del]}\x00\x00#{m[:left]}#{m[:home]}#{m[:end]}\x00#{m[:up]}#{m[:down]}#{m[:pgup]}#{m[:pgdn]}\x00\x00#{m[:right]}#{m[:numlk]}#{m[:np_seven]}#{m[:np_four]}#{m[:np_one]}\x00#{m[:np_div]}#{m[:np_eight]}#{m[:np_five]}#{m[:np_two]}#{m[:np_zero]}#{m[:np_mult]}#{m[:np_nine]}#{m[:np_six]}#{m[:np_three]}#{m[:np_dot]}#{m[:np_minus]}#{m[:np_plus]}\x00#{m[:np_enter]}\x00#{m[:esc]}\x00#{m[:f1]}#{m[:f2]}#{m[:f3]}#{m[:f4]}#{m[:f5]}#{m[:f6]}".force_encoding(Encoding::BINARY).freeze, "\xaa\xaa\x80\xc3\x0a#{m[:f7]}#{m[:f8]}#{m[:f9]}#{m[:f10]}#{m[:f11]}#{m[:f12]}#{m[:prtsc]}#{m[:scrlk]}#{m[:pause]}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze ] end