Skip to content

Commit

Permalink
chore(kramer): run crystal tool format
Browse files Browse the repository at this point in the history
  • Loading branch information
pkheav committed Feb 10, 2021
1 parent f1f4434 commit 3b0843a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
34 changes: 18 additions & 16 deletions drivers/kramer/switches/protocol3000.cr
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ class Kramer::Switcher::Protocol3000 < PlaceOS::Driver
end

enum RouteType
Video = 1
Audio = 2
USB = 3
AudioVideo = 12
VideoUSB = 13
Video = 1
Audio = 2
USB = 3
AudioVideo = 12
VideoUSB = 13
AudioVideoUSB = 123
end

def route(map : Hash(Int32, Array(Int32)), type : RouteType = RouteType::AudioVideo)
map.each do |input, outputs|
outputs.each do |output|
Expand Down Expand Up @@ -134,8 +135,8 @@ class Kramer::Switcher::Protocol3000 < PlaceOS::Driver

case c = CMDS[cmd]
when "info"
self[:video_inputs] = args[1].to_i
self[:video_outputs] = args[3].to_i
self[:video_inputs] = args[1].to_i
self[:video_outputs] = args[3].to_i
when "route"
# response looks like ~01@ROUTE 12,1,4 OK
layer = args[0].to_i
Expand All @@ -147,7 +148,8 @@ class Kramer::Switcher::Protocol3000 < PlaceOS::Driver
case c
when "switch_audio" then type = "audio"
when "switch_video" then type = "video"
else type = "av" end
else type = "av"
end

args.each do |map|
inout = map.split('>')
Expand All @@ -169,16 +171,16 @@ class Kramer::Switcher::Protocol3000 < PlaceOS::Driver
end

CMDS = {
"info" => "INFO-IO?",
"login" => "LOGIN",
"route" => "ROUTE",
"switch" => "AV",
"info" => "INFO-IO?",
"login" => "LOGIN",
"route" => "ROUTE",
"switch" => "AV",
"switch_audio" => "AUD",
"switch_video" => "VID",
"audio_mute" => "MUTE",
"video_mute" => "VMUTE",
"help" => "HELP",
"model" => "MODEL?"
"audio_mute" => "MUTE",
"video_mute" => "VMUTE",
"help" => "HELP",
"model" => "MODEL?",
}
CMDS.merge!(CMDS.invert)

Expand Down
6 changes: 3 additions & 3 deletions drivers/kramer/switches/protocol3000_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ DriverSpecs.mock_driver "Kramer::Switcher::Protocol3000" do
responds("~01@ OK\x0D\x0A")

settings({
kramer_id: "01",
kramer_login: true,
kramer_password: "pass"
kramer_id: "01",
kramer_login: true,
kramer_password: "pass",
})
# on_update
# state
Expand Down
8 changes: 4 additions & 4 deletions drivers/kramer/switches/vs_hdmi.cr
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class Kramer::Switcher::VsHdmi < PlaceOS::Driver
end

enum Command
ResetVideo = 0
SwitchVideo = 1
StatusVideo = 5
DefineMachine = 62
ResetVideo = 0
SwitchVideo = 1
StatusVideo = 5
DefineMachine = 62
IdentifyMachine = 61
end

Expand Down
6 changes: 3 additions & 3 deletions drivers/kramer/switches/vs_hdmi_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ DriverSpecs.mock_driver "Kramer::Switcher::VsHdmi" do
status[:video_outputs].should eq(16)

exec(:switch_video, {
5 => [8]
5 => [8],
})
should_send(Bytes[1, 0x85, 0x88, 0xFF])
status[:video8].should eq(5)

exec(:switch_video, {
1 => [2,3],
4 => [5,6]
1 => [2, 3],
4 => [5, 6],
})
should_send(Bytes[1, 138, 144, 0xFF])
status[:video2].should eq(1)
Expand Down

0 comments on commit 3b0843a

Please sign in to comment.