-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
108 lines (89 loc) · 3.24 KB
/
index.html
File metadata and controls
108 lines (89 loc) · 3.24 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
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Haptic Things</title>
<!-- Include p5.js and p5.ble.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.js"></script>
<script src="https://unpkg.com/p5.ble.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h1 {
color: #333;
}
label {
display: block;
margin: 10px 0 5px;
}
input {
margin-bottom: 15px;
}
button {
padding: 10px 20px;
background-color: #007BFF;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<h1>Haptic Things</h1>
<!-- Frequency input -->
<label for="frequency">Frequency:</label>
<input type="number" id="frequency" name="frequency" step="0.1" placeholder="Enter frequency">
<!-- Granularity input -->
<label for="granularity">Granularity:</label>
<input type="number" id="granularity" name="granularity" step="0.1" placeholder="Enter granularity">
<!-- Checkboxes -->
<label><input type="checkbox" id="pressure"> Pressure</label>
<label><input type="checkbox" id="tilt"> Tilt</label>
<label><input type="checkbox" id="imuX"> IMU X</label>
<label><input type="checkbox" id="imuY"> IMU Y</label>
<label><input type="checkbox" id="imuZ"> IMU Z</label>
<!-- Send button -->
<button id="sendButton">Send</button>
<script>
let myBLE;
// Initialize the p5.ble.js instance
function setup() {
noCanvas(); // No need for a canvas in this application
myBLE = new p5ble();
// Attach the click event to the Send button
const sendButton = document.getElementById('sendButton');
sendButton.addEventListener('click', sendData);
}
// Function to handle sending data to a BLE device
function sendData() {
const frequency = parseFloat(document.getElementById('frequency').value);
const granularity = parseFloat(document.getElementById('granularity').value);
const pressure = document.getElementById('pressure').checked;
const tilt = document.getElementById('tilt').checked;
const imuX = document.getElementById('imuX').checked;
const imuY = document.getElementById('imuY').checked;
const imuZ = document.getElementById('imuZ').checked;
// Create a data object to send
const data = {
frequency: frequency,
granularity: granularity,
pressure: pressure,
tilt: tilt,
imuX: imuX,
imuY: imuY,
imuZ: imuZ
};
console.log('Data to send:', data);
// TODO: Implement BLE device connection and send data
// Example: myBLE.write(characteristic, JSON.stringify(data));
}
</script>
</body>
</html>