summaryrefslogtreecommitdiff
path: root/robot
diff options
context:
space:
mode:
Diffstat (limited to 'robot')
-rw-r--r--robot/io.c1
-rw-r--r--robot/io.h2
-rw-r--r--robot/readme.md4
-rw-r--r--robot/sim.c32
-rw-r--r--robot/sim.h11
5 files changed, 47 insertions, 3 deletions
diff --git a/robot/io.c b/robot/io.c
index f5fcffc..f98c87a 100644
--- a/robot/io.c
+++ b/robot/io.c
@@ -27,4 +27,3 @@ void w2_io_main() {
print(g_w2_io.lcd.text);
};
-void w2_io_init() { w2_modes_call(W2_M_SCAL); }
diff --git a/robot/io.h b/robot/io.h
index 6c2d262..ce67c73 100644
--- a/robot/io.h
+++ b/robot/io.h
@@ -3,6 +3,8 @@
#include <stdint.h>
#include <stdlib.h>
+void w2_io_main();
+
typedef struct {
bool pressed;
} w2_s_i_push;
diff --git a/robot/readme.md b/robot/readme.md
index eb1dd37..c1cae72 100644
--- a/robot/readme.md
+++ b/robot/readme.md
@@ -55,9 +55,9 @@ what they're supposed to do:
|module |internal name|due|author|purpose|
|------------------|-------------|-|-|-|
|hypervisor |`hypervisor `|done|N/a| backbone of all other modules; stores global variables; controls when other modules run|
-|pc communication |`sercomm `|may 27|Loek| reads and parses incoming serial data; sends all data in the message buffer|
+|pc communication |`sercomm `|done|Loek| reads and parses incoming serial data; sends all data in the message buffer|
|error handling |`errcatch `|done|Loek| receives error codes; controls how errors are handled|
-|i/o read & write |`io `|may 27|Jorn & Abdullaahi| reads all inputs to global state; writes all outputs|
+|i/o read & write |`io `|done|Jorn & Abdullaahi| reads all inputs to global state; writes all outputs|
|mode logic |`modes `|done|N/a| executes the appropriate module for current mode|
|maze |`mode_maze `|may 31|Jorn & Abdullaahi| controls robot during maze portion of map; hands off control to warehouse module|
|warehouse |`mode_grid `|may 31|Loek| controls robot during warehouse portion of map; hands off control to maze module|
diff --git a/robot/sim.c b/robot/sim.c
index ddc208a..0f1c7e6 100644
--- a/robot/sim.c
+++ b/robot/sim.c
@@ -126,3 +126,35 @@ void w2_sim_print_serial(w2_s_bin *data) {
void set_motors(int left, int right) {
simprintfunc("set_motors", "%i, %i", left, right);
}
+
+static const char* const W2_BUTTON_NAMES[] = {
+ "BUTTON_A",
+ "BUTTON_B",
+ "BUTTON_C",
+ "TOP_BUTTON",
+ "BOTTOM_BUTTON",
+};
+
+unsigned char get_single_debounced_button_press(unsigned char buttons) {
+ simprintfunc("get_single_debounced_button_press", "%s", W2_BUTTON_NAMES[buttons]);
+ return false;
+}
+
+void qtr_read(unsigned int* sensor_values, unsigned char read_mode) {
+ simprintfunc("qtr_read", "0x%016lx, %s", (uint64_t) sensor_values, read_mode == QTR_EMITTERS_ON ? "QTR_EMITTERS_ON" : "???");
+ sensor_values[0] = 0;
+ sensor_values[1] = 0;
+ sensor_values[2] = 0;
+ sensor_values[3] = 0;
+ sensor_values[4] = 0;
+}
+
+unsigned int analog_read(unsigned char channel) {
+ simprintfunc("analog_read", "ADC%i", channel);
+ return 0;
+}
+
+void print(const char* str) {
+ simprintfunc("print", "\"%s\"", str);
+}
+
diff --git a/robot/sim.h b/robot/sim.h
index a595042..f087517 100644
--- a/robot/sim.h
+++ b/robot/sim.h
@@ -40,6 +40,13 @@ extern bool g_w2_sim_headless;
#define simwarn(message, ...) if (DBG_ENABLE_SIMWARN) { simprintf(COL_YEL "[WARN] " COL_RST message, ##__VA_ARGS__); }
#define siminfo(message, ...) if (DBG_ENABLE_SIMINFO) { simprintf(COL_MAG "[INFO] " COL_RST message, ##__VA_ARGS__); }
+#define BUTTON_A 0
+#define BUTTON_B 1
+#define BUTTON_C 2
+#define TOP_BUTTON 3
+#define BOTTOM_BUTTON 4
+#define QTR_EMITTERS_ON 0
+
/**
* simulates pololu library functions for local testing
* NOLINT is so clang-tidy doesn't correct function names
@@ -55,6 +62,10 @@ void serial_send(char *message, unsigned int length); // NOLINT
void serial_receive_ring(char *buffer, unsigned char size); // NOLINT
unsigned char serial_get_received_bytes(); // NOLINT
void set_motors(int left, int right); // NOLINT
+unsigned char get_single_debounced_button_press(unsigned char buttons); // NOLINT
+void qtr_read(unsigned int* sensor_values, unsigned char read_mode); // NOLINT
+unsigned int analog_read(unsigned char channel); // NOLINT
+void print(const char* str); // NOLINT
void w2_sim_setup(int argc, char **argv);
void w2_sim_cycle_begin();