-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor
executable file
·109 lines (98 loc) · 3.7 KB
/
monitor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#
# @file monitor
# ☆ Script that talks with the Arduino GrblShield providing a monitor feature
# ala the Arduino Serial Monitor Tool. A jog mode is also provided to move
# the X, Y, Z axis using keystrokes of the keyboard.
# @author Alister Lewis-Bowen <alister@different.com>
# @requires color <http://code.google.com/p/ansi-color/>
#
# This software is distributed under the the MIT License.
#
# Copyright (c) 2012 Alister Lewis-Bowen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Bootstrap
#
LIB=$( cd "$( dirname "$0" )" && pwd )/lib
source $LIB/core # core vars and functions
source $LIB/connection # connection logic
source $LIB/jog # jog mode
source $LIB/waypoints # waypoint manager
function _helpCmd {
local helpText="$(color bd)Arduino GrblShield Serial Monitor Tool$(color)
Usage: $(color bd)monitor [$(color ul)options$(color bd)]$(color)
Options:
--clear-device Delete the stored USB device
--clear-waypoints Delete any stored waypoints
$(color)"
echo "$helpText"
exit 0;
}
function _helpLoop {
local helpText="$(color yellow)$(color bd)Arduino GrblShield Serial \
Monitor Tool commands:$(color)
:commands, :c ... show commands
:go, :g $(color ul)wp$(color) ...... move X, Y, Z position it waypoint named \
$(color ul)wp$(color)
:exit, :e ....... exit from monitor
:home, :h ....... attempt to move X, Y, Z axis to zero
:jog, :j ........ enter jog mode
:list, :l ....... list all waypoints
:limit, ......... record current X, Y, Z co-ords as the maximum limit
:report, :r ..... report position and state
:set, :s $(color ul)wp$(color) ..... set current X, Y, Z position as a waypoint \
named $(color ul)wp$(color)
$(color)"
echo "$helpText"
}
case "$1" in
'-h'|'--help'|'help') _helpCmd;;
'--clear-device') conRemoveStore;;
'--clear-waypoints') wpClearStore;;
esac
conOpen
wpGetLimit
while true; do
[ "$MODE" == "$START_UP" ] && _helpLoop # offer some help on start up
MODE=$RAW # default to raw mode
echo -n "$(color yellow)[monitor] > $(color)"
read input
cmd=$(echo $input | awk '{print $1}')
arg1=$(echo $input | awk '{print $2}')
case "$cmd" in
:commands|:c) _helpLoop;;
:report|:r) conReport;;
:exit|:e) conClose;;
:jog|:j) jogMode;;
:home|:h) jogHome;;
:limit) wpStoreLimit;;
:set|:s) wpStore $arg1;;
:remove|:r) wpRemove $arg1;;
:go|:g) wpGoto $arg1;;
:list|:l) wpList;;
* ) # Process raw input
if [ "${input:0:1}" != ':' ]; then
conSend "$input"
echo
else _helpLoop; fi
;;
esac
done