Skip to content

Commit

Permalink
Added new interface
Browse files Browse the repository at this point in the history
  • Loading branch information
miharix committed May 7, 2019
1 parent 37c9c7d commit 5d78c89
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 7 deletions.
62 changes: 56 additions & 6 deletions Arduino/socket/socket-6servo-advance/bin/multiple.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,65 @@

#!/bin/bash
echo ""Miharix WiFi RC""
read -p "Zacnem programirati? Y/[N] : " programiraj
#
# Elapsed time. Usage:
#
# t=$(timer)
# ... # do something
# printf 'Elapsed time: %s\n' $(timer $t)
# ===> Elapsed time: 0:01:12
#
#https://www.linuxjournal.com/content/use-date-command-measure-elapsed-time
#####################################################################
# If called with no arguments a new timer is returned.
# If called with arguments the first is used as a timer
# value and the elapsed time is returned in the form HH:MM:SS.
#
function timer()
{
if [[ $# -eq 0 ]]; then
echo $(date '+%s')
else
local stime=$1
etime=$(date '+%s')

if [[ -z "$stime" ]]; then stime=$etime; fi

dt=$((etime - stime))
ds=$((dt % 60))
dm=$(((dt / 60) % 60))
dh=$((dt / 3600))
printf '%d:%02d:%02d' $dh $dm $ds
fi
}

# If invoked directly run test code.
if [[ $(basename $0 .sh) == 'timer' ]]; then
t=$(timer)
read -p 'Enter when ready...' p
printf 'Elapsed time: %s\n' $(timer $t)
fi

## vim: tabstop=4: shiftwidth=4: noexpandtab:
## kate: tab-width 4; indent-width 4; replace-tabs false;

#glavna koda

echo "Miharix WiFi RC"
stevec=0
cas=$(timer)
read -p "Začnem programirati? Y/[N] : " programiraj
programiraj=${programiraj:="n"}
while [ $programiraj == 'y' ] || [ $programiraj == 'Y' ]
do
echo "Zaganjam programiranje"
stevec=$((stevec+1))
printf '\nZaganjam programiranje %s. vezja\n' $stevec

esptool.py --port /dev/ttyUSB0 write_flash 0x000000 socket-6servo-advance.ino.bin 0x300000 socket-6servo-advance.spiffs.bin

echo "Programiranje končano"
printf '\nProgramiranje %s. vezja končano\n\n' $stevec

read -p "Zacnem programirati naslednjega? [Y]/N : " programiraj
read -p "Začnem programirati naslednjega? [Y]/N : " programiraj
programiraj=${programiraj:="y"}
done
done
printf '\n\nSprogramiranih je bilo %s vezij\n' $stevec
printf 'Za kar je bilo potrebno %s časa\n\n' $(timer $cas)
Binary file not shown.
16 changes: 16 additions & 0 deletions Arduino/socket/socket-6servo-advance/data/control15.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--http://twiggle-web-design.com/tutorials/Custom-Vertical-Input-Range-CSS3.html-->
<html><head><title>Miharix WiFi RC</title>
<script src='control15.js' charset='utf-8'></script>
<link rel="icon" type="image/png" href="icona.png" />
<link rel="stylesheet" type="text/css" href="control3.css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
</head>
<body>

Miharix WiFi RC
<input id='S1' class='range horizontal-lowest-first round servo1' type='range' oninput='sendServo();' onmouseup='S1Up()' ontouchend='S1Up()' onmouseout='S1Up()' min='0' max='180' step='1' value='90' >

<input id='S2' class='range horizontal-lowest-first round servo2' type='range' oninput='sendServo();' onmouseup='S2Up()' ontouchend='S2Up()' onmouseout='S2Up()' min='0' max='180' step='1' value='90' >

</body>
</html>
47 changes: 47 additions & 0 deletions Arduino/socket/socket-6servo-advance/data/control15.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
var Servo1=0;
var Servo2=0;
var Servo3=0;
var Servo4=0;
var Servo5=0;
var Servo6=0;

var connection = new WebSocket('ws://'+location.hostname+':81/', ['arduino']);
connection.onopen = function () {
// connection.send('Connect ' + new Date());
};
connection.onerror = function (error) {
console.log('WebSocket Error ', error);
};
connection.onmessage = function (e) {
// console.log('Server: ', e.data);
};
function sendServo(){

var S1 = parseInt(document.getElementById('S1').value).toString(16);
var S2 = parseInt(document.getElementById('S2').value).toString(16);
var S3 = 90;
var S4 = 90;
var S5 = 90;
var S6 = 90;

if(S1.length < 2) { S1 = '0' + S1; }
if(S2.length < 2) { S2 = '0' + S2; }
if(S3.length < 2) { S3 = '0' + S3; }
if(S4.length < 2) { S4 = '0' + S4; }
if(S5.length < 2) { S5 = '0' + S5; }
if(S6.length < 2) { S6 = '0' + S6; }

var S1_6 = S1+S2+S3+S4+S5+S6;
// console.log('S1_6: ' + S1_6);
connection.send('S'+S1_6+'\n');
}

function S2Up(){
//document.getElementById('S2').value=90;
sendServo();
}
function S1Up(){
//document.getElementById('S1').value=90;
sendServo();
}

2 changes: 1 addition & 1 deletion Arduino/socket/socket-6servo-advance/data/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
<div class='d'>Fail. time:</div>
<input type='number' Id='Ftime' name='Ftime' value='5' step='1' min='1' max='20'>
<div class='d'>Mode:</div>
<input type='number' Id='Mode' name='Mode' value='4' step='1' min='0' max='14'>
<input type='number' Id='Mode' name='Mode' value='4' step='1' min='0' max='15'>
<div class='d'>RC Name:</div>
<input type='text' id='rcname' name='rcname' required placeholder='rcname' minlength='1' maxlength='32'>
<div class='d'>SSID(1-32):</div>
Expand Down

0 comments on commit 5d78c89

Please sign in to comment.