Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Sony lcd #70

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions modules/sony/display/cbx.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module Sony; end
module Sony::Display; end

# Documentation: https://docs.google.com/spreadsheets/d/1F8RyaDqLYlKBT7fHJ_PT7yHwH3vVMZue4zUc5McJVYM/edit?usp=sharing

class Sony::Display::CBX
include ::Orchestrator::Constants
include ::Orchestrator::Transcoder

# Discovery Information
tcp_port 4999
descriptive_name 'Sony CBX Display'
generic_name :Display

def on_load
on_update
end

def on_update
end

def connected
schedule.every('60s') { power? }
end

def disconnected
schedule.clear
jeremy-west marked this conversation as resolved.
Show resolved Hide resolved
end

#
# Power commands
#
def power(state, opt = nil)
jeremy-west marked this conversation as resolved.
Show resolved Hide resolved
if is_affirmative?(state)
send("8C 00 00 02 01 8F", hex_string: true)
logger.debug "-- sony display requested to power on"
else
send("8C 00 00 02 01 8F", hex_string: true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same hex string as the power on command. Is this a toggle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We believe so, not 100% sure, hence added the else statement just to be sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The protocol doc in the comment at the top of this file makes reference to both power on and power off commands?

Regardless, if only a toggle is supported, provide a power method that accepts a state param, but always toggles is a little disingenuous. With this user would expect to be able to call power :on or power :off and have the device state reflect this. If there are no discrete power commands it's worth using the current known state (if this is accurate) to only execute the toggle is required.

logger.debug "-- sony display requested to power off"
end

# Request status update
power?
jeremy-west marked this conversation as resolved.
Show resolved Hide resolved
end

def power?(options = {})
options[:priority] = 0
options[:hex_string] = true
send("83 00 00 FF FF 81", options)
end

def received(byte_str, resolve, command) # Data is default received as a string
logger.debug { "sony display sent: 0x#{byte_to_hex(byte_str)}" }
if byte_str.start_with?("\x70\x0\x0\x1")
self[:power] = true
elsif byte_str == "\x70\x0\x0\x0\x72"
self[:power] = false
end
:success
end
end