Skip to content

Commit

Permalink
Added Port Selector
Browse files Browse the repository at this point in the history
  • Loading branch information
MUmarShahbaz committed Aug 31, 2024
1 parent b7cd93d commit 5c17a9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/oscilloscope-setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ if (!window.settings) {
window.settings = {};
}

document.getElementById('settingsForm').addEventListener('submit', function(event) {
document.getElementById('settingsForm').addEventListener('submit', async(event) => {
event.preventDefault();
const port = await navigator.serial.requestPort();
const formData = new FormData(event.target);
window.settings = {
drawPoints: formData.get('drawPoints') !== null,
Expand All @@ -15,10 +16,10 @@ document.getElementById('settingsForm').addEventListener('submit', function(even
yGap: parseFloat(formData.get('yGap')),
minX: parseInt(formData.get('minX')),
maxX: parseInt(formData.get('maxX')),
xGap: parseFloat(formData.get('xGap'))
xGap: parseFloat(formData.get('xGap')),
baud: parseInt(formData.get('baudrate')),
port: port
};
//console.log(settings);
sessionStorage.setItem('settings', JSON.stringify(settings));
// You can pass these settings to your JavaScript functions here.
window.location.href = "oscilloscope.html";
window.location.href = "oscilloscope.html";
});
3 changes: 3 additions & 0 deletions setup-oscilloscope.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ <h2>Grid Settings</h2>
<label for="xGap">Gap between main X grid</label>
<input type="number" id="xGap" name="xGap" step="0.1" value="200" required>

<label for="baudrate">Serial Device Baudrate</label>
<input type="number" id="baudrate" name="baudrate" value="9600" required>

<input type="submit" value="Start Plotting">
</form>

Expand Down

0 comments on commit 5c17a9c

Please sign in to comment.