Skip to content

Commit

Permalink
interfacing directly with the target software instead of using sikuli
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Igo committed Apr 26, 2015
1 parent 660c786 commit b1a4adf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion desktop_software/README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is the Desktop-side code base for the DeskAttendant project.

Specifics
--
The daemon listens to the serial port where the Arduino is attached and will invoke the Sikuli script if the Arduino says to. Combined, the two sets of code mirror on the desktop the pause/run state that the Arduino is in at the time.
The shell script preps the given USB port and launches the python script. The python script listens to the serial port where the Arduino is attached and will apply changes to the three tracked applications, if they are running. In visual mode, a python script uses Sikuli to interact with applications via the GUI. In CLI mode, a different python script controls applications via shell commands. The end result is that the desktop applications are made to mirror the pause/run state that the Arduino is in at the time.

How to use this code
==
Expand Down
10 changes: 6 additions & 4 deletions desktop_software/ubuntu/README.mdown
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
What's this?
==
This is an Ubuntu-compatible daemon that listens for status changes from the Arduino and invokes the project's Sikuli script when appropriate.
desk_attendant.sh is a launcher for a python script that listens for status changes from the Arduino and applies those changes to tracked desktop apps as needed. If passed an optional '-v' argument, the python script called will use Sikuli to interact with the desktop apps via their GUIs. If omitted, the interaction is done via shell commands.

The Ubuntu daemon monitors the serial port of the attached Arduino for status information. When it sees that there has been an actionable status change (from "human present" to "human absent" or from "human absent" to "human present"), it launches one of the bundled Sikuli scripts to set desktop software to the appropriate run mode.
desk_attendant.py applies status changes via shell commands. It monitors the serial port of the attached Arduino for status information. When it sees that there has been an actionable status change (from "human present" to "human absent" or from "human absent" to "human present"), it invokes shell commands to set the tracked desktop applications (if running) to the appropriate run mode.

For example, if the daemon sees status going from "human present" to "human absent" it will launch the Sikuli script that pauses activities such as time tracking and music playing.
deskattendant.sikuli/deskattendant.py applies status changes via Sikuli, using openCV to detect click targets and using Sikuli libraries to click them.

For example, if the daemon sees status going from "human present" to "human absent" it will pause activities such as time tracking and music playing.

Invocation
==
`desk_attendant.sh -p [port]`
`desk_attendant.sh -p PORT`

e.g.

Expand Down
15 changes: 10 additions & 5 deletions desktop_software/ubuntu/desk_attendant.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2012-2014 Robert W Igo
# Copyright 2012-2015 Robert W Igo
#
# [email protected]
# http://bob.igo.name
Expand All @@ -23,16 +23,18 @@

Usage() {
echo "USAGE:"
echo `basename $0` "[-p port]"
echo `basename $0` "-p PORT [-v]"
echo "-p: Serial port where your Arduino is attached"
echo "-v: interact with apps visually (using Sikuli); otherwise use CLI mode"
echo "e.g."
echo "$0 -p /dev/ttyUSB0"
exit 4
}

while getopts "p:" FLAG ; do
while getopts "p:v:" FLAG ; do
case "$FLAG" in
p) port="$OPTARG";;
v) mode="visual";;
*) Usage;;
esac
done
Expand All @@ -56,5 +58,8 @@ stty -F $port raw ispeed $baud ospeed $baud time 3 min 1 -hupcl

# NOTE: The paths used (or omitted) here must be compatible with your Sikuli installation and
# with the location where you installed the deskattendant.sikuli directory.
#sikuli-ide -r /repos/DeskAttendant/desktop_software/sikuli/deskattendant.sikuli -args $port
python /repos/DeskAttendant/desktop_software/ubuntu/desk_attendant.py $port
if [ "$mode" == "visual" ]; then
sikuli-ide -r /repos/DeskAttendant/desktop_software/sikuli/deskattendant.sikuli -args $port
else
python /repos/DeskAttendant/desktop_software/ubuntu/desk_attendant.py $port
fi

0 comments on commit b1a4adf

Please sign in to comment.