diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-06-26 22:03:36 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-06-26 22:03:36 +0200 |
commit | 0b50dfe730d87ff052ef08f0dd6df6071d50aef9 (patch) | |
tree | b87ef18d3bad97483b573c2469c1e28c7359f0df /robot | |
parent | 2a0270f3ba6eb993fb39ed3564f626d724156654 (diff) |
update sim, fix readme brainfarts & fix bomd command
Diffstat (limited to 'robot')
-rw-r--r-- | robot/makefile | 4 | ||||
-rw-r--r-- | robot/sim.c | 48 | ||||
-rw-r--r-- | robot/sim.h | 11 |
3 files changed, 61 insertions, 2 deletions
diff --git a/robot/makefile b/robot/makefile index 5f05872..a35162a 100644 --- a/robot/makefile +++ b/robot/makefile @@ -9,7 +9,7 @@ PORT ?= /dev/ttyACM0 # SIM = true CFLAGS=-g -Wall $(DEVICE_SPECIFIC_CFLAGS) -Os -LDFLAGS=-Wl,-u,vfprintf -lprintf_flt -lm -Wl,-relax -Wl,-gc-sections +LDFLAGS=-Wl,-u,vfprintf -lm -Wl,-relax -Wl,-gc-sections include ../shared/os.mk all: $(if $(SIM), $(TARGET), out.hex) @@ -20,7 +20,7 @@ include ../shared/makefile # simulation CFLAGS += $(if $(SIM), -DW2_SIM -DDBG_ENABLE_COLOR, -mcall-prologues -mmcu=$(MCU)) -LDFLAGS += $(if $(SIM), , -lpololu_$(DEVICE)) +LDFLAGS += $(if $(SIM), , -lpololu_$(DEVICE) -lprintf_flt) PREFIX := $(if $(SIM), , avr-) SOURCES += $(if $(SIM), sim.c, ) HEADERS += $(if $(SIM), sim.h, ) diff --git a/robot/sim.c b/robot/sim.c index 9cce12f..d68e6ff 100644 --- a/robot/sim.c +++ b/robot/sim.c @@ -156,3 +156,51 @@ void print(const char* str) { simprintfunc("print", "\"%s\"", str); } +void lcd_goto_xy(unsigned int x, unsigned int y) { + simprintfunc("lcd_goto_xy", "%u, %u", x, y); +} + +void delay(unsigned long duration) { + return delay_ms(duration); +} + +void delay_ms(unsigned long duration) { + simprintfunc("delay_ms", "%lu", duration); +} + +int read_battery_millivolts() { + simprintfunc("read_battery_millivolts", ""); + return W2_BATTERY_FULL; +} + +unsigned long get_ticks() { + simprintfunc("get_ticks", ""); +#ifdef W2_HOST_LINUX + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + return (now.tv_sec * 1e6) + (now.tv_nsec / 1e3); +#endif +} + +unsigned long ticks_to_microseconds(unsigned long num_ticks) { + simprintfunc("ticks_to_microseconds", "%lu", num_ticks); + return num_ticks; +} + +int read_line() { + return 0; +} + +void play_frequency(unsigned int freq, unsigned int duration, unsigned char volume) { + simprintfunc("play_frequency", "%u, %u, %u", freq, duration, volume); +} + +void calibrate_line_sensors(unsigned char read_mode) { + simprintfunc("calibrate_line_sensors", "%u", read_mode); +} + +unsigned char pololu_3pi_init(unsigned int line_sensor_timeout) { + simprintfunc("pololu_3pi_init", "%u", line_sensor_timeout); + return 0; +} + diff --git a/robot/sim.h b/robot/sim.h index 7d7c091..874a4ad 100644 --- a/robot/sim.h +++ b/robot/sim.h @@ -59,6 +59,7 @@ #define TOP_BUTTON 3 #define BOTTOM_BUTTON 4 #define QTR_EMITTERS_ON 0 +#define IR_EMITTERS_ON 0 /** * simulates pololu library functions for local testing @@ -79,6 +80,16 @@ unsigned char get_single_debounced_button_press(unsigned char buttons); // NOLIN 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 lcd_goto_xy(unsigned int x, unsigned int y); // NOLINT +void delay(unsigned long duration); // NOLINT +void delay_ms(unsigned long duration); // NOLINT +int read_battery_millivolts(); // NOLINT +unsigned long get_ticks(); // NOLINT +unsigned long ticks_to_microseconds(unsigned long num_ticks); // NOLINT +int read_line(); // NOLINT +void play_frequency(unsigned int freq, unsigned int duration, unsigned char volume); // NOLINT +void calibrate_line_sensors(unsigned char read_mode); // NOLINT +unsigned char pololu_3pi_init(unsigned int line_sensor_timeout); // NOLINT void w2_sim_setup(); void w2_sim_cycle_begin(); |