mirror of
https://github.com/gtxaspec/wz_mini_hacks.git
synced 2024-11-22 05:27:24 +00:00
enhance car web control
This commit is contained in:
parent
16def56fc9
commit
b59823b61e
@ -1 +1 @@
|
||||
Wed Jul 20 07:33:26 PM PDT 2022
|
||||
Thu Jul 21 10:08:24 PM PDT 2022
|
||||
|
@ -11,6 +11,19 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wz_car_BUTTON_N {
|
||||
background-color: #4CAF50; /* Green */
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 15px 32px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
margin: 4px 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wz_car_TABLE {
|
||||
width: 55%;
|
||||
border-collapse: collapse;
|
||||
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script src="car.js"></script>
|
||||
<script type="text/javascript" src="car.js"></script>
|
||||
<link rel="stylesheet" href="car.css">
|
||||
|
||||
</head>
|
||||
@ -27,14 +27,31 @@
|
||||
<tr style="height: 18px;">
|
||||
<td style="width: 33.3333%; height: 18px; text-align: left;"><button id="reverse_left" class="wz_car_BUTTON">z: rear left</button></td>
|
||||
<td style="width: 33.3333%; height: 18px; text-align: center;"><button id="all_stop" class="wz_car_BUTTON">x: all stop</button></td>
|
||||
<td style="width: 33.3333%; height: 18px; text-align: right;"><button id="reverse_right" class="wz_car_BUTTON">c: rear right</button></td>
|
||||
<td style="width: 33.3333%; height: 18px; text-align: right;"><button id="reverse_right" class="wz_car_BUTTON">c: rear right</button></td>
|
||||
</tr>
|
||||
<td style="width: 33.3333%; height: 21px; text-align: left;"><button id="headlight" class="wz_car_BUTTON">H: headlight</button></td>
|
||||
<td style="width: 33.3333%; height: 18px; text-align: center;"><button id="irled" class="wz_car_BUTTON">j: ir led</button></td>
|
||||
<td style="width: 33.3333%; height: 18px; text-align: center;"><button id="honk" class="wz_car_BUTTON">b: honk</button></td>
|
||||
<td style="width: 33.3333%; height: 18px; text-align: center;">
|
||||
<button id="headlight_on" class="wz_car_BUTTON_N">h: headlight on</button>
|
||||
<button id="headlight_off" class="wz_car_BUTTON_N">g: headlight off</button>
|
||||
</td>
|
||||
<td style="width: 33.3333%; height: 18px; text-align: center;"><button id="irled_on" class="wz_car_BUTTON">j: ir led on</button><button id="irled_off" class="wz_car_BUTTON">k: ir led off</button></td>
|
||||
<td style="width: 33.3333%; height: 18px; text-align: right;"><button id="honk" class="wz_car_BUTTON">b: honk</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><img id="car_feed" src="/cgi-bin/jpeg.cgi?channel=1" /></p>
|
||||
|
||||
Speed Sleep: <input type="text" size=5 id="sleep_timer" name="sleep_timer" value="0.15">
|
||||
|
||||
Car Speed:
|
||||
|
||||
<input type="radio" id="speed_fast" class="speed" name="fast" value="fast">
|
||||
<label for="fast">Fast</label>
|
||||
|
||||
<input type="radio" id="speed_slow" class="speed" name="slow" value="slow">
|
||||
<label for="slow">Slow</label>
|
||||
|
||||
<button onclick="set_vars()">Set Variables</button>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,12 +1,34 @@
|
||||
const queryString = window.location.search;
|
||||
console.log(queryString);
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
|
||||
const speed = urlParams.get('speed')
|
||||
console.log("speed is", speed);
|
||||
|
||||
const sleep_timer = urlParams.get('sleep_time')
|
||||
console.log("sleep_timer is", sleep_timer);
|
||||
|
||||
function set_sleep() {
|
||||
sleep_timer2 = document.getElementById("sleep_timer").value;
|
||||
window.location = "car.html?sleep_time=" + sleep_timer2;
|
||||
}
|
||||
|
||||
function set_vars() {
|
||||
sleep_timer2 = document.getElementById("sleep_timer").value;
|
||||
var speed = $('input[class="speed"]:checked').val();
|
||||
|
||||
window.location = "car.html?sleep_time=" + sleep_timer2 + "&speed=" + speed;
|
||||
}
|
||||
|
||||
|
||||
var wz_mini_car = {
|
||||
post: function(action)
|
||||
{
|
||||
$.post("../cgi-bin/car.sh", action);
|
||||
$.post( "../cgi-bin/car.sh", { speed: speed, action: action, sleep_time: sleep_timer } );
|
||||
} ,
|
||||
init: function() {
|
||||
this.logarray = [];
|
||||
|
||||
$('.wz_car_BUTTON').on('click',function(e){
|
||||
$("[class*='BUTTON']").on('click',function(e) {
|
||||
var action = $(this).attr('id');
|
||||
wz_mini_car.post(action);
|
||||
});
|
||||
@ -27,10 +49,11 @@ var wz_mini_car = {
|
||||
case "z": action = "reverse_left"; break;
|
||||
case "c": action = "reverse_right" ; break;
|
||||
case "x": action = "all_stop" ; break;
|
||||
/* everything was "x" below here ... assigned other letters */
|
||||
case "h": action = "headlight" ; break;
|
||||
case "i": action = "irled" ; break;
|
||||
case "k": action = "honk" ; break;
|
||||
case "h": action = "headlight_on" ; break;
|
||||
case "g": action = "headlight_off" ; break;
|
||||
case "j": action = "irled_on" ; break;
|
||||
case "k": action = "irled_off" ; break;
|
||||
case "b": action = "honk" ; break;
|
||||
}
|
||||
if (action) {
|
||||
wz_mini_car.post(action);
|
||||
@ -47,3 +70,8 @@ var wz_mini_car = {
|
||||
$(document).ready(function() {
|
||||
wz_mini_car.init();
|
||||
});
|
||||
|
||||
setInterval(function() {
|
||||
var myImageElement = document.getElementById('car_feed');
|
||||
myImageElement.src = '/cgi-bin/jpeg.cgi?channel=1&rand=' + Math.random();
|
||||
}, 1000);
|
||||
|
@ -1,59 +1,91 @@
|
||||
#!/bin/sh
|
||||
|
||||
SLEEP_TIME=0.1
|
||||
set -x
|
||||
|
||||
echo "HTTP/1.1 200"
|
||||
echo -e "Content-type: text/html\n\n"
|
||||
echo ""
|
||||
|
||||
read POST_STRING
|
||||
|
||||
if [ "$POST_STRING" = "forward" ]; then
|
||||
SPEED=$(echo $POST_STRING | sed 's/.*speed=//;s/\&.*//')
|
||||
ACTION=$(echo $POST_STRING | sed 's/.*action=//;s/\&.*//')
|
||||
SLEEP_TIME=$(echo $POST_STRING | sed 's/.*sleep_time=//;s/\&.*//')
|
||||
|
||||
echo "raw post string: $POST_STRING"
|
||||
echo "speed: $SPEED"
|
||||
echo "action: $ACTION"
|
||||
echo "sleep: $SLEEP_TIME"
|
||||
|
||||
if [ "$ACTION" = "forward" ]; then
|
||||
|
||||
if [ "$SPEED" = "slow" ]; then
|
||||
echo "slow"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\xca\x00\x02\xbb" > /dev/ttyUSB0
|
||||
else
|
||||
echo "forward"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\xe3\x00\x02\xd4" > /dev/ttyUSB0
|
||||
sleep $SLEEP_TIME
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
elif [ "$POST_STRING" = "reverse" ]; then
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\xe3\x00\x02\xd4" > /dev/ttyUSB0
|
||||
fi
|
||||
|
||||
sleep $SLEEP_TIME
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
|
||||
elif [ "$ACTION" = "reverse" ]; then
|
||||
echo "reverse"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x36\x00\x02\x27" > /dev/ttyUSB0
|
||||
|
||||
sleep $SLEEP_TIME
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
elif [ "$POST_STRING" = "left" ]; then
|
||||
elif [ "$ACTION" = "left" ]; then
|
||||
echo "left"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x76\x81\x00\x02\x68" > /dev/ttyUSB0
|
||||
|
||||
sleep $SLEEP_TIME
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
elif [ "$POST_STRING" = "right" ]; then
|
||||
elif [ "$ACTION" = "right" ]; then
|
||||
echo "right"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x8a\x81\x00\x02\x7c" > /dev/ttyUSB0
|
||||
|
||||
sleep $SLEEP_TIME
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
elif [ "$POST_STRING" = "forward_left" ]; then
|
||||
elif [ "$ACTION" = "forward_left" ]; then
|
||||
echo "left_forward"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x76\xe3\x00\x02\xca" > /dev/ttyUSB0
|
||||
|
||||
sleep $SLEEP_TIME
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
elif [ "$POST_STRING" = "forward_right" ]; then
|
||||
elif [ "$ACTION" = "forward_right" ]; then
|
||||
echo "right_forward"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x8a\xe3\x00\x02\xde" > /dev/ttyUSB0
|
||||
|
||||
sleep $SLEEP_TIME
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
elif [ "$POST_STRING" = "reverse_left" ]; then
|
||||
elif [ "$ACTION" = "reverse_left" ]; then
|
||||
echo "left_reverse"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x76\x36\x00\x02\x1d" > /dev/ttyUSB0
|
||||
sleep $SLEEP_TIME
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
elif [ "$POST_STRING" = "reverse_right" ]; then
|
||||
elif [ "$ACTION" = "reverse_right" ]; then
|
||||
echo "right_reverse"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x8a\x36\x00\x02\x31" > /dev/ttyUSB0
|
||||
sleep $SLEEP_TIME
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
elif [ "$POST_STRING" = "all_stop" ]; then
|
||||
elif [ "$ACTION" = "all_stop" ]; then
|
||||
echo "all stop"
|
||||
echo -ne "\xaa\x55\x43\x06\x29\x80\x80\x00\x02\x71" > /dev/ttyUSB0
|
||||
elif [ "$POST_STRING" = "headlight" ]; then
|
||||
echo "headlight"
|
||||
headlight
|
||||
elif [ "$POST_STRING" = "irled" ]; then
|
||||
echo "irled"
|
||||
irled
|
||||
elif [ "$POST_STRING" = "honk" ]; then
|
||||
elif [ "$ACTION" = "headlight_on" ]; then
|
||||
echo "headlight_on"
|
||||
echo -ne "\xaa\x55\x43\x04\x1e\x01\x01\x65" > /dev/ttyUSB0
|
||||
elif [ "$ACTION" = "headlight_off" ]; then
|
||||
echo "headlight_off"
|
||||
echo -ne "\xaa\x55\x43\x04\x1e\x02\x01\x66" > /dev/ttyUSB0
|
||||
elif [ "$ACTION" = "irled_on" ]; then
|
||||
echo "irled_on"
|
||||
cmd irled on > /dev/null
|
||||
elif [ "$ACTION" = "irled_off" ]; then
|
||||
echo "irled_off"
|
||||
cmd irled off > /dev/null
|
||||
elif [ "$ACTION" = "honk" ]; then
|
||||
echo "honk"
|
||||
/opt/wz_mini/bin/cmd aplay /opt/wz_mini/usr/share/audio/honk.wav 70 > /dev/null 2>&1 &
|
||||
|
||||
|
12
file.chk
12
file.chk
@ -12,13 +12,13 @@ bd74b1a5dfb722ea1109ea89a039a3e5 SD_ROOT/wz_mini/www/cgi-bin/RTMP_STREAM_ENABLE
|
||||
8e14bf2616556d8a45dbb9b183d86d57 SD_ROOT/wz_mini/www/cgi-bin/ENABLE_MP4_WRITE.md
|
||||
1013ee7201755bcf9047635b637e17c9 SD_ROOT/wz_mini/www/cgi-bin/ENABLE_WIREGUARD.md
|
||||
842b228d85468ab31c99e1521b35e37e SD_ROOT/wz_mini/www/cgi-bin/REMOTE_SPOTLIGHT.md
|
||||
b1e6e35b81031a838201ecfcf79fc6f8 SD_ROOT/wz_mini/www/cgi-bin/config.cgi
|
||||
38b9920ac65f5cf3179ece26b5fde345 SD_ROOT/wz_mini/www/cgi-bin/car.sh
|
||||
555bb860c40d1f39e0fa0d2b1d698a4a SD_ROOT/wz_mini/www/cgi-bin/config.cgi
|
||||
d43f6b975afedc1f7a5e5c4999dbcbbd SD_ROOT/wz_mini/www/cgi-bin/car.sh
|
||||
042848359c3840f5973baffca2457a5d SD_ROOT/wz_mini/www/cgi-bin/ENABLE_USB_DIRECT.md
|
||||
ddfa6179dc16a38d3b53a4353460dc25 SD_ROOT/wz_mini/www/config.js
|
||||
5f01772968d1d1472c6d6343761da2b3 SD_ROOT/wz_mini/www/car/car.js
|
||||
fc4ff21fb45c4be143efd78c196f021a SD_ROOT/wz_mini/www/car/car.css
|
||||
39a383f2b1f704738bfeec00f7914d77 SD_ROOT/wz_mini/www/car/car.html
|
||||
e344ffc55222c029c5d324037a5aa1f3 SD_ROOT/wz_mini/www/car/car.js
|
||||
540acfdf2638c341e1d168f1af5203de SD_ROOT/wz_mini/www/car/car.css
|
||||
63b23f78d6703f0c9a2e970604104996 SD_ROOT/wz_mini/www/car/car.html
|
||||
bd11d9a8352eca6a16554c87be50b2f5 SD_ROOT/wz_mini/www/index.html
|
||||
28cf061770da7b83fbc3752c455a02c3 SD_ROOT/wz_mini/etc/dnsmasq.conf
|
||||
34c6a4c3a941ff2becd9f487826d7692 SD_ROOT/wz_mini/etc/uvc.config
|
||||
@ -108,7 +108,7 @@ b339aee882a5d1c943ad08e4282ec3fd SD_ROOT/wz_mini/usr/bin/iCamera-dbg
|
||||
20b061689308b2cee7edf3b9b906bca7 SD_ROOT/wz_mini/usr/bin/ucamera
|
||||
3777d9e80c8b517c01a124e6360b6525 SD_ROOT/wz_mini/usr/bin/imp_helper.sh
|
||||
580b1b6e91e72b4a4fef7b21d8954403 SD_ROOT/wz_mini/usr/bin/getSensorType
|
||||
88ffb5c502a33fd110f372c0acf1b2bf SD_ROOT/wz_mini/usr/bin/app.ver
|
||||
aa855cdd5d51f55d2a14ab2556e715d9 SD_ROOT/wz_mini/usr/bin/app.ver
|
||||
4c780f0455481d106d47d89f0ae04ed5 SD_ROOT/wz_mini/lib/uClibc.tar
|
||||
9afeb088e4cbabbe0b04033b560204d0 SD_ROOT/wz_mini/lib/libimp.so
|
||||
4100755cb6cc6e3b76da20c7e3690e16 SD_ROOT/wz_mini/lib/libalog.so
|
||||
|
Loading…
Reference in New Issue
Block a user