summaryrefslogtreecommitdiffstats
path: root/watch-library/simulator
diff options
context:
space:
mode:
authorjoeycastillo <joeycastillo@utexas.edu>2022-08-03 11:56:52 -0600
committerGitHub <noreply@github.com>2022-08-03 11:56:52 -0600
commite790a025787e0e1aa59b98b95e194cf4318d1578 (patch)
tree149bd53bbd46ebddd31957cc827a7c40ccf6f1a0 /watch-library/simulator
parent6d87f5a6268a9a516d8c577dfd71b39a5bfc384a (diff)
parentbcd3b666848214a735f37a5a4f08b157ba7bb3a1 (diff)
downloadSensor-Watch-e790a025787e0e1aa59b98b95e194cf4318d1578.tar.gz
Sensor-Watch-e790a025787e0e1aa59b98b95e194cf4318d1578.tar.bz2
Sensor-Watch-e790a025787e0e1aa59b98b95e194cf4318d1578.zip
Merge pull request #80 from joeycastillo/lfs
Movement: add a lil file system with lfs
Diffstat (limited to 'watch-library/simulator')
-rw-r--r--watch-library/simulator/main.c2
-rw-r--r--watch-library/simulator/shell.html9
-rw-r--r--watch-library/simulator/watch/watch.c4
-rw-r--r--watch-library/simulator/watch/watch_private.c4
-rw-r--r--watch-library/simulator/watch/watch_storage.c32
5 files changed, 47 insertions, 4 deletions
diff --git a/watch-library/simulator/main.c b/watch-library/simulator/main.c
index 14bf44e6..ac9db6ac 100644
--- a/watch-library/simulator/main.c
+++ b/watch-library/simulator/main.c
@@ -102,8 +102,6 @@ static void main_loop_set_sleeping(bool sleeping) {
}
int main(void) {
- printf("Hello, world!\n");
-
app_init();
_watch_init();
app_setup();
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;
+}
diff --git a/watch-library/simulator/watch/watch_private.c b/watch-library/simulator/watch/watch_private.c
index 4ddc2182..3425341a 100644
--- a/watch-library/simulator/watch/watch_private.c
+++ b/watch-library/simulator/watch/watch_private.c
@@ -63,7 +63,7 @@ int _write(int file, char *ptr, int len) {
return 0;
}
-// this method could be overridden to read stuff from the USB console? but no need rn.
-int _read(void) {
+int _read(int file, char *ptr, int len) {
+ // TODO: hook to UI
return 0;
}
diff --git a/watch-library/simulator/watch/watch_storage.c b/watch-library/simulator/watch/watch_storage.c
new file mode 100644
index 00000000..27011807
--- /dev/null
+++ b/watch-library/simulator/watch/watch_storage.c
@@ -0,0 +1,32 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "watch_storage.h"
+
+uint8_t storage[NVMCTRL_ROW_SIZE * NVMCTRL_RWWEE_PAGES];
+
+bool watch_storage_read(uint32_t row, uint32_t offset, uint8_t *buffer, uint32_t size) {
+ // printf("read row %ld offset %ld size %ld\n", row, offset, size);
+ memcpy(buffer, storage + row * NVMCTRL_ROW_SIZE + offset, size);
+
+ return true;
+}
+
+bool watch_storage_write(uint32_t row, uint32_t offset, const uint8_t *buffer, uint32_t size) {
+ // printf("write row %ld offset %ld size %ld\n", row, offset, size);
+ memcpy(storage + row * NVMCTRL_ROW_SIZE + offset, buffer, size);
+
+ return true;
+}
+
+bool watch_storage_erase(uint32_t row) {
+ // printf("erase row %ld\n", row);
+ memset(storage + row * NVMCTRL_ROW_SIZE, 0xff, NVMCTRL_ROW_SIZE);
+
+ return true;
+}
+
+bool watch_storage_sync(void) {
+ // nothing to do here!
+ return true;
+}