diff options
author | Joey Castillo <joeycastillo@utexas.edu> | 2022-05-09 12:55:58 -0400 |
---|---|---|
committer | Joey Castillo <joeycastillo@utexas.edu> | 2022-05-09 13:00:15 -0400 |
commit | 22b1ac0283a6aed800ea86960305284199747cdc (patch) | |
tree | 4756b7024263098ea9f43ef42df15566f296304e /watch-library | |
parent | 21ee056e26c3e158cf56f8577169f86b8d577a65 (diff) | |
download | Sensor-Watch-22b1ac0283a6aed800ea86960305284199747cdc.tar.gz Sensor-Watch-22b1ac0283a6aed800ea86960305284199747cdc.tar.bz2 Sensor-Watch-22b1ac0283a6aed800ea86960305284199747cdc.zip |
simulator: add USB serial input field
Diffstat (limited to 'watch-library')
-rw-r--r-- | watch-library/hardware/watch/watch.c | 4 | ||||
-rw-r--r-- | watch-library/shared/watch/watch.h | 4 | ||||
-rw-r--r-- | watch-library/simulator/shell.html | 9 | ||||
-rw-r--r-- | watch-library/simulator/watch/watch.c | 4 |
4 files changed, 21 insertions, 0 deletions
diff --git a/watch-library/hardware/watch/watch.c b/watch-library/hardware/watch/watch.c index 32bbccbb..b3dc4e8d 100644 --- a/watch-library/hardware/watch/watch.c +++ b/watch-library/hardware/watch/watch.c @@ -41,3 +41,7 @@ void SYSTEM_Handler(void) { bool watch_is_buzzer_or_led_enabled(void){ return hri_mclk_get_APBCMASK_TCC0_bit(MCLK); } + +bool watch_is_usb_enabled(void) { + return USB->DEVICE.CTRLA.bit.ENABLE; +} diff --git a/watch-library/shared/watch/watch.h b/watch-library/shared/watch/watch.h index b307feca..b94d36fb 100644 --- a/watch-library/shared/watch/watch.h +++ b/watch-library/shared/watch/watch.h @@ -76,6 +76,10 @@ */ bool watch_is_buzzer_or_led_enabled(void); +/** @brief Returns true if USB is enabled. + */ +bool watch_is_usb_enabled(void); + /** @brief Reads up to len bytes from the USB serial. * @param file ignored, you can pass in 0 * @param ptr pointer to a buffer of at least len bytes diff --git a/watch-library/simulator/shell.html b/watch-library/simulator/shell.html index 2f560aba..80e1e2ea 100644 --- a/watch-library/simulator/shell.html +++ b/watch-library/simulator/shell.html @@ -323,6 +323,9 @@ <button onclick="getLocation()">Set location register (will prompt for access)</button> <br> +<input id="input" style="width: 500px"></input> +<button id="submit" onclick="sendText()">Send</button> +<br> <textarea id="output" rows="8" style="width: 100%"></textarea> <script type='text/javascript'> @@ -365,10 +368,16 @@ }; lat = 0; lon = 0; + tx = ""; function updateLocation(location) { lat = Math.round(location.coords.latitude * 100); lon = Math.round(location.coords.longitude * 100); } + function sendText() { + var inputElement = document.getElementById('input'); + tx = inputElement.value + "\n"; + inputElement.value = ""; + } function showError(error) { switch(error.code) { case error.PERMISSION_DENIED: diff --git a/watch-library/simulator/watch/watch.c b/watch-library/simulator/watch/watch.c index 1c965aad..749651af 100644 --- a/watch-library/simulator/watch/watch.c +++ b/watch-library/simulator/watch/watch.c @@ -3,3 +3,7 @@ bool watch_is_buzzer_or_led_enabled(void) { return false; } + +bool watch_is_usb_enabled(void) { + return true; +} |