Read All About It News Announcements - Updated Hourly [Click Message To Learn
More]
by Craig Chadwick
This article provides an
example of how the HomeVisionÒ
home automation controller might be used by a handicapped individual.
Some such persons are limited to a "puff and sip" switch for
controlling their home.
Custom Solutions Inc.
Introduction
This article provides an example of how the HomeVisionÒ
home automation controller might be used by a handicapped individual. Some such
persons are limited to a "puff and sip" switch for controlling their
home. One of the challenges with such a device is providing access to a variety
of automation functions (lights, infrared, etc.) using only two switch inputs.
This example shows how the HomeVision video system can be used with such a
device to provide powerful control options through a television.
HomeVision Background
HomeVision is an automation controller that provides two-way X-10, two-way
infrared, 24 digital input/output ports, and a very powerful
programming/scheduling capability. It also has many expansion options (extra
serial ports, telephone interface, analog inputs, etc.). It is programmed from a
PC, after which it may be disconnected from the PC. One of its unique
capabilities is to display video screens on a television. These screens can be
used to control your home and display status information. There are more than 50
built-in screens, including screens for thermostats, security systems, X10, and
macros. The video screens are normally controlled through an infrared remote. If
the user is limited to a "puff and sip" switch, it is more difficult
to control these built-in screens. However, HomeVision's powerful programming
capability allows users to create their own screens and control them in any way
they desire. This article shows how to create custom screens that can be
controlled with a simple "puff and sip" switch.
Example Overview
Note: An example HomeVision schedule file implementing this system can be
downloaded from our web site. It can be easily modified by an
installer/programmer to provide additional functions.
This example schedule uses two video screens, each with eight command
options. One switch (we'll assume it is the "puff" switch) is used to
move a cursor through the command list, and the other switch (the
"sip" switch) selects the command. The "puff" switch is also
used to start the video screens if they are off. The two video screens appear as
shown below:
The cursor (an arrow) on the left edge shows which line is selected. Each
time the "puff" switch is activated, the cursor moves down one line.
If you go past the last line, the other screen is displayed. Selecting one of
the command lines (using the "sip" switch) performs the command. It
also briefly displays the message "COMMAND BEING PERFORMED" to provide
visual feedback to the user, and then returns to the previous screen. Selecting
the "EXIT" line shuts off the video system.
The "sip" and "puff" switches can be connected directly
to two HomeVision digital input ports (on Port B or C). For each switch, one
wire goes to an input port, the other to ground. When a switch is inactive, the
input port will be "high". When the switch is activated, the input
port will go "low".
Example Details
The complete example program is shown at the end of this article. The main
points are described below.
Two variables are used:
Variable #0, "Current screen number", indicates which
screen is being displayed. In this example, the only valid numbers are 1 and
2.
Variable #1, "Current line number", indicates which line
the cursor is currently on. In this example, the only valid numbers are 2
through 10 (line 1 is the screen title line, which can't be selected).
Six macros are used (listed out of order):
Macro #4, "Start video screens", turns the HomeVision
video system on. It also initializes the two variables so that the first
screen is displayed and the cursor is on the first command line. This macro
should be run whenever the user wants to turn the screens on.
Macro #0, "Draw video screen", draws the video screen
indicated by the "Current screen number" variable. If you want to
change the screen appearance or add more screens, this is the place to do
it.
Macro #1, "Draw cursor", draws the cursor to the left of
the selected line. It first erases the start of each line (where the old
cursor might be), and then draws the new cursor.
Macro #2, "Scroll 1 line", should be performed when the
user activates the "puff" switch to scroll one line. The macro
looks at the "Current line number" variable. If the line number is
less than or equal to 9, it increments the variable, then runs the
"Draw cursor" macro to draw the cursor on the new line. If the
line number is higher than 9 (which only occurs on the last line, number
10), it changes the current screen number variable to the number of the next
screen (either 1 or 2), then runs the "Draw video screen" and
"Draw cursor" macros to draw it.
Macro #3, "Select line", should be performed when the
user activates the "sip" switch to perform the selected command.
The macro looks at the current screen and line number to determine what
command to perform. In the example schedule, no real actions are performed.
However, the "Indicate performing command" macro is run to show a
brief message indicating the command was performed. If the EXIT line (line
10) was selected, the "Stop video system" command is performed to
shut off the video system. This macro is the place to put all the actions
you want the video screen commands to perform.
Macro #5, "Indicate performing command", displays the
message "COMMAND BEING PERFORMED" for two seconds, and then
returns to the previous screen. This provides feedback to the user
confirming that the command was performed.
Two X-10 "events" are used to perform actions when HomeVision
receives the corresponding X-10 signal. These are only for demonstration
purposes to simulate the "sip" and "puff" switches. In a
real user's system, the actions in these events would be put in the "low
actions" for the input ports that the two switches are connected to. Thus,
the actions would be performed whenever the switches are activated (causing the
input port to go low). The X-10 events in the example program are as follows:
P-1 ON simulates the "puff" switch. It turns the video
system on if it is off. If the video is already on, it runs macro 2,
"Scroll 1 line", to scroll the video screen one line.
P-1 OFF simulates the "sip" switch. It runs macro 3,
"Select line", to perform the command on the selected line
Conclusion
This example shows a simple way to control your home using only two switch
inputs. It could easily be expanded to show many more video screens and perform
dozens (or hundreds!) of commands. You could make other changes such as adding a
"Return to previous screen" command to each screen to make it easy to
go backwards. If you have a lot of screens, you might use the first page as a
menu to select more screens from. For example, the first line might select a
"Lighting" page, the next line might select an "Infrared
remote" page, and so on. You could also display status information (such as
the current thermostat setpoint) on one or more pages. You are only limited by
your imagination!
MACRO # 0 'Draw video screen'
;This macro draws the screen indicated by the "Current screen
number" variable
Video: Start internal video mode
Video: Display video screen # 0
Video: Set cursor row to 1
Video: Set cursor column to 1
;First, draw the correct screen:
If
Var #0 (Current screen number) = 1
Then
Video: Display text 'CONTROL MENU - PAGE 1'
Video: Do line feed and carriage return
Video: Display text ' Kitchen light on'
Video: Do line feed and carriage return
Video: Display text ' Kitchen light off'
Video: Do line feed and carriage return
Video: Display text ' Dining room light on'
Video: Do line feed and carriage return
Video: Display text ' Dining room light off'
Video: Do line feed and carriage return
Video: Display text ' Porch light on'
Video: Do line feed and carriage return
Video: Display text ' Porch light off'
Video: Do line feed and carriage return
Video: Display text ' Bedroom light on'
Video: Do line feed and carriage return
Video: Display text ' Bedroom light off'
Video: Do line feed and carriage return
Video: Display text ' EXIT'
Video: Do line feed and carriage return
End If
If
Var #0 (Current screen number) = 2
Then
Video: Display text 'CONTROL MENU - PAGE 2'
Video: Do line feed and carriage return
Video: Display text ' TV on'
Video: Do line feed and carriage return
Video: Display text ' TV off'
Video: Do line feed and carriage return
Video: Display text ' TV channel up'
Video: Do line feed and carriage return
Video: Display text ' TV channel down'
Video: Do line feed and carriage return
Video: Display text ' TV volume up'
Video: Do line feed and carriage return
Video: Display text ' TV volume down'
Video: Do line feed and carriage return
Video: Display text ' TV mute'
Video: Do line feed and carriage return
Video: Display text ' TV PIP'
Video: Do line feed and carriage return
Video: Display text ' EXIT'
Video: Do line feed and carriage return
End If
MACRO # 1 'Draw cursor'
;This macro draws the cursor (an arrow) at the start of the selected
line.
;First, we'll erase the first character in each row to delete the old
cursor:
Video: Set cursor row to 2
Video: Set cursor column to 1
Video: Display text ' '
Video: Do line feed and carriage return
Video: Display text ' '
Video: Do line feed and carriage return
Video: Display text ' '
Video: Do line feed and carriage return
Video: Display text ' '
Video: Do line feed and carriage return
Video: Display text ' '
Video: Do line feed and carriage return
Video: Display text ' '
Video: Do line feed and carriage return
Video: Display text ' '
Video: Do line feed and carriage return
Video: Display text ' '
Video: Do line feed and carriage return
Video: Display text ' '
;Now put arrow at start of current line:
If
Var #1 (Current line number) = 2
Then
Video: Set cursor row to 2
End If
If
Var #1 (Current line number) = 3
Then
Video: Set cursor row to 3
End If
If
Var #1 (Current line number) = 4
Then
Video: Set cursor row to 4
End If
If
Var #1 (Current line number) = 5
Then
Video: Set cursor row to 5
End If
If
Var #1 (Current line number) = 6
Then
Video: Set cursor row to 6
End If
If
Var #1 (Current line number) = 7
Then
Video: Set cursor row to 7
End If
If
Var #1 (Current line number) = 8
Then
Video: Set cursor row to 8
End If
If
Var #1 (Current line number) = 9
Then
Video: Set cursor row to 9
End If
If
Var #1 (Current line number) = 10
Then
Video: Set cursor row to 10
End If
Video: Set cursor column to 1
;This draws an arrow pointing to the right:
Video: Display text '#'
MACRO # 2 'Scroll 1 line'
;This macro should be run whenever the user uses the switch to scroll
down.
;We first need to find which screen number is being displayed
If
Var #0 (Current screen number) = 1
Then
If
Var #1 (Current line number) <= 9
Then
;We're not on the last line, so we'll just scroll down one line
Increment var #1 (Current line number) [roll over at 255]
Else
;We're on the last line, so move to start of next screen (line 2)
Var #1 (Current line number) = 2
Var #0 (Current screen number) = 2
;Call macro to redraw screen:
Do macro #0 (Draw video screen) once
End If
Else
If
Var #0 (Current screen number) = 2
Then
If
Var #1 (Current line number) <= 9
Then
;We're not on the last line, so we'll just scroll down one line
Increment var #1 (Current line number) [roll over at 255]
Else
;We're on the last line, so move to start of first screen (line 2)
Var #1 (Current line number) = 2
Var #0 (Current screen number) = 1
;Call macro to redraw screen:
Do macro #0 (Draw video screen) once
End If
Else
End If
End If
;Call macro to draw cursor pointing to current line:
Do macro #1 (Draw cursor) once
MACRO # 3 'Select line'
;This macro should be run whenever the user selects this line (i.e., we
should perform the selected command).
;First, check which screen number is being displayed.
If
Var #0 (Current screen number) = 1
Then
;Now check which line number was selected on screen 1
If
Var #1 (Current line number) = 2
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 3
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 4
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 5
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 6
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 7
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 8
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 9
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 10
Then
Video: Stop video mode
End If
End If
If
Var #0 (Current screen number) = 2
Then
;Now check which line number was selected on screen 2
If
Var #1 (Current line number) = 2
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 3
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 4
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 5
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 6
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 7
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 8
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 9
Then
;do whatever action you want
Do macro #5 (Indicate performing command) once
End If
If
Var #1 (Current line number) = 10
Then
Video: Stop video mode
End If
End If
MACRO # 4 'Start video screens'
;First, we'll set up the variables for the screen number and line number
Var #0 (Current screen number) = 1
Var #1 (Current line number) = 2
;Next we'll draw the first video screen
Video: Start internal video mode
Video: Display video screen # 0
Do macro #0 (Draw video screen) once
;Now we'll draw the cursor on the correct line
Do macro #1 (Draw cursor) once
MACRO # 5 'Indicate performing command'
;This macro briefly displays a message saying the selected command is
being performed.
;It should be run whenever a command is performed that requires visual
feedback to the user.
Video: Clear screen
Video: Set cursor row to 5
Video: Display text 'COMMAND BEING PERFORMED'
Delay for 2.000 seconds
;Now display the previous screen
Do macro #0 (Draw video screen) once
Do macro #1 (Draw cursor) once
X-10 SIGNAL 'ON' EVENT # P 1 'X10 P 1'
;This event is for testing purposes. We'll act as if the user triggered
the switch which should scroll the video screen.
;We will also use this to start the video screens if they are not
currently on.
If
Video Mode is not active
Then
;Since the video screens are off, we'll turn them on (but not scroll).
Do macro #4 (Start video screens) once
Else
;Since the video screen was already on, we'll do the macro to scroll one
line
Do macro #2 (Scroll 1 line) once
End If
X-10 SIGNAL 'OFF' EVENT # P 1 'X10 P 1'
;This event is for testing purposes. We'll act as if the user triggered
the switch which should perform the selected command.
Do macro #3 (Select line) once