Created
January 3, 2019 09:02
-
-
Save paul-ridgway/722ad9c6f5f41c5ebcf61e0b7eedc011 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
#!/usr/bin/env ruby | |
require 'hidapi' | |
bus_number = 1 | |
device_address = 4 | |
interface = 3 | |
SOLID_GRN = [0x08, 0x00, 0x01, 0x06, 0x32, 0x02, 0x01, 0xbb] | |
PRESS_FADE_GRN = [0x08, 0x00, 0x04, 0x0a, 0x32, 0x02, 0x01, 0xb4] | |
PRESS_FADE_YEL = [0x08, 0x00, 0x04, 0x0a, 0x32, 0x03, 0x01, 0xb3] | |
MARQUEE = [0x08, 0x00, 0x05, 0x06, 0x32, 0x01, 0x01, 0xb8] | |
begin | |
dev = HIDAPI::open_path("#{bus_number.to_s(16)}:#{device_address.to_s(16)}:#{interface.to_s(16)}") | |
dev.send_feature_report PRESS_FADE_YEL.pack('c*') | |
sleep 2 | |
dev.send_feature_report SOLID_GRN.pack('c*') | |
sleep 2 | |
dev.send_feature_report MARQUEE.pack('c*') | |
sleep 2 | |
dev.send_feature_report PRESS_FADE_GRN.pack('c*') | |
rescue Exception => e | |
puts "Error: #{e.message}" | |
puts e.backtrace | |
ensure | |
puts "Closing device" | |
dev.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment