-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.html
More file actions
100 lines (84 loc) · 3.61 KB
/
interface.html
File metadata and controls
100 lines (84 loc) · 3.61 KB
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
<!DOCTYPE html>
<html>
<head>
<title>WebSocket Test</title>
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.2/socket.io.js"></script>
</head>
<body data-bs-theme="dark">
<div class="container mt-3">
<div class="card col-md-8">
<div class="card-body">
<h5>GS232 Remote </h5>
<div class="col-md-6">
<div class="lcd-display">
<div class="lcd-backlight bg-success p-2 mb-2">
<h5>Azimuth: <span id="azimuthValue">0</span></h5>
<h5>Elevation: <span id="elevationValue">0</span></h5>
</div>
</div>
<div class="row p-2">
<div class="col-md-4">
<button class="btn col-md-12 btn-secondary btn-block" onclick=moveLeft() id="leftButton">LEFT</button>
</div>
<div class="col-md-4">
<button class="col-md-12 btn btn-secondary btn-block" onclick=moveStop() id="stopButton">STOP</button>
</div>
<div class="col-md-4">
<button class="col-md-12 btn btn-secondary btn-block" onclick=moveRight() id="rightButton">RIGHT</button>
</div>
</div>
<div class="row p-2">
<div class="col-md-3">
<button class="btn col-md-12 btn-secondary btn-block" onclick=setAzimuth(30) id="leftButton">EU/JA 30</button>
</div>
<div class="col-md-3">
<button class="col-md-12 btn btn-secondary btn-block" onclick=setAzimuth(60) id="stopButton">VK/ZL 60</button>
</div>
<div class="col-md-3">
<button class="col-md-12 btn btn-secondary btn-block" onclick=setAzimuth(210) id="rightButton">PY/LU 210</button>
</div>
<div class="col-md-3">
<button class="col-md-12 btn btn-secondary btn-block" onclick=setAzimuth(300) id="rightButton">W/VE 300</button>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function() {
var pollStatus = setInterval(getStatus, 1000)
})
const socket = io.connect('http://localhost:3001'); // Replace 'localhost' with your server's hostname or IP address
socket.on('connect', () => {
console.log('Connected to WebSocket server');
});
socket.on('disconnect', () => {
console.log('Disconnected from WebSocket server');
});
socket.on('status', (data) => {
console.log('Received status from server:', data);
$("#azimuthValue").text(data.azimuth)
$("#elevationValue").text(data.elevation)
});
function getStatus() {
socket.emit('get-status');
}
function setAzimuth(value) {
var value = $("#sendAzimuthValue").val()
socket.emit('set-azimuth', parseInt(value));
}
function moveLeft(value) {
socket.emit('move-left');
}
function moveRight(value) {
socket.emit('move-right');
}
function moveStop(value) {
socket.emit('move-stop');
}
</script>