Compare commits

...

3 Commits

Author SHA1 Message Date
88fbbc103b git bug 2025-08-14 21:05:47 +02:00
76fe86a3bc fix bugs 2025-08-14 20:51:28 +02:00
6bf43409e4 concept for config edit form 2025-08-14 17:14:39 +00:00
2 changed files with 44 additions and 13 deletions

View File

@@ -30,6 +30,17 @@
cursor: pointer;
display: inline-block;
}
#edit_config {
position: absolute;
background-color: var(--background-second);
top: 0;
left: 0;
right: 0;
/* height: 100%; */
}
#edit_config form {
margin: 40px auto;
}
</style>
</head>
<body>
@@ -66,6 +77,19 @@
</thead>
<tbody id="clients"></tbody>
</table>
<div id="edit_config" style="display:none">
<form>
<input type="hidden" name="boart" />
name: <input type="text" name="name" id="edit_name" /><br/>
stuur trim max: <input type="range" name="ch0_max" id="edit_ch0_max" max="8192" min="4096" /><br/>
stuur trim mid: <input type="range" name="ch0_mid" id="edit_ch0_mid" max="8192" min="0" /><br/>
stuur trim min: <input type="range" name="ch0_min" id="edit_ch0_min" max="4096" min="0" /><br/>
motor trim max: <input type="range" name="ch1_max" id="edit_ch1_max" max="8192" min="4096" /><br/>
motor trim mid: <input type="range" name="ch1_mid" id="edit_ch1_mid" max="8192" min="0" /><br/>
motor trim min: <input type="range" name="ch1_min" id="edit_ch1_min" max="4096" min="0" /><br/>
<button class="btn" onclick="updateConfig()">toepassen</button> <button class="btn" onclick="document.getElementById('edit_config').style.display = 'none'">anulleren</button>
</form>
</div>
</main>
<script>
const passEl = document.getElementById('pass');
@@ -174,10 +198,14 @@
function getBoatLog(e)
{
let cmd = prompt("enter command");
// let cmd = prompt("enter command");
let boat = getDataFomEl(e.target);
console.log("send cmd", boat, cmd);
conn.send(passEl.value + ";sendcmd;" + boat['id'] + ";" + cmd);
// console.log("send cmd", boat, cmd);
// conn.send(passEl.value + ";sendcmd;" + boat['id'] + ";" + cmd);
conn.send(passEl.value + ";sendcmd;" + boat['id'] + ";servotrim:0");
conn.send(passEl.value + ";sendcmd;" + boat['id'] + ";servotrim:1");
}
function reqBoats()

View File

@@ -130,15 +130,16 @@ async def getlog(client, data):
async def sendcmd(data):
"""send command to boat"""
for b in Boats:
if b['id'] == data[2]:
del data[0]
del data[1]
del data[2]
print(data)
data = ";".join(data)
await sendToBoat(b, data + "\n")
return
if len(data) > 3:
for b in Boats:
if b['id'] == data[2]:
del data[2]
del data[1]
del data[0]
print(data)
data = ";".join(data)
await sendToBoat(b, data + "\n")
return
async def kick_client(clientId):
"""kick a client"""
@@ -159,7 +160,7 @@ async def on_message(message, client):
data = message.replace('\n', '').split(';')
if data[0] != client["id"]:
print("invalid id: " + str(data[0]) + " != " + str(client["id"]))
else:
elif len(data) >= 2:
if data[1] == "boats":
await echo_boats(client)
elif data[1] == "ctrl":
@@ -192,6 +193,8 @@ async def on_message(message, client):
print("WARN: invalid command (admin): '" + data[1] + "'")
else:
print("WARN: invalid command (" + client['id'] + "): '" + data[1] + "'")
else:
print("WARN: to little arguments")
async def new_client(clientId, ws):
"""handler for every new client connection"""