From edd0246cc56c1949d0b560d13acc6c69c5658117 Mon Sep 17 00:00:00 2001 From: Filip Ayazi Date: Wed, 2 Jun 2021 00:56:23 +0100 Subject: [PATCH] some compatibility fixes and upload instructions --- README.md | 15 ++++++++++++--- src/config.h | 4 ++-- src/main.cpp | 27 ++++++++++++++++++++++++++- src/main.h | 1 + src/modules/stage/stage.cpp | 2 ++ src/modules/stage/stage.h | 1 - 6 files changed, 43 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5ebc712..c505242 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,20 @@ The code is split into the main part which mostly handles command parsing and mo Motor moves now do not block command processing and a new command `stop` was added which aborts any move in progress. -The firware can be build against different platforms (pi pico, stm32). `boards.h` contains wiring configuration which will need to be adjusted when used with a custom board. - ## Hardware +This is mainly intended for Sangaboard control boards and all configuration for these is already in `boards.h`, but it can also be used on different platforms (pi pico, stm32 (bluepill)). To use a custom board based on any of these platforms adjust `boards.h` to match your wiring. -Currently works on Arduino Nano + Sangaboard v0.2. Other platforms might work with appropriate `platform.ini` and `config.h` changes and will be supported in due course. +If you have additional hardware connected to the board (Endstops, Light sensor) support for these can be enabled in `config.h`. + +## Building and uploading +The easiest way to build and upload this firmware is to install `pio core` via pip. For arduino nano with sangaboard v0.2 run +``` +pip3 install platformio +pio lib install +pio run -e nano +pio run -e nano -t upload +``` +for sangaboard v0.3 replace `nano` with `leonardo` in the above commands (untested). ## TODO list diff --git a/src/config.h b/src/config.h index 173e94e..070fab9 100644 --- a/src/config.h +++ b/src/config.h @@ -10,13 +10,13 @@ #define MAX_COMMANDS 50 #define MAX_MODULES 10 #define MAX_ARGUMENT_LENGTH 20 //used in argument parsing, takes up ram - #define VERSION_STRING "Sangaboard Firmware v0.6" + #define VERSION_STRING "Sangaboard Firmware v0.5" //TODO: temporarily using the same version string for sangaboard.py compatibility #define DEBUG_ON //module choice #define HELP #define STAGE - #define ENDSTOPS + // #define ENDSTOPS // #define LIGHT_SENSOR //module configs diff --git a/src/main.cpp b/src/main.cpp index dd27ab2..b6e098b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,6 +44,7 @@ uint8_t registered_loop_fn_count = 0; const Command core_commands[] = { {"version", get_version}, + {"list_modules", get_modules}, END_COMMAND}; void register_module(const Command commands[], void (*loop_fn)(void)) @@ -95,10 +96,34 @@ uint8_t parse_arguments(char ** arguments, String command, uint8_t max_args) void get_version(String) { - Serial.println(F(VER_STRING)); + Serial.println(F(VERSION_STRING)); return; } +void get_modules(String) +{ + #if defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_TSL2591) + Serial.println(F("Light Sensor: TSL2591")); + #elif defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_ADS1115) + Serial.println(F("Light Sensor: ADS1115")); + #endif + + #if defined(ENDSTOPS) + Serial.print("Endstops:"); + #ifdef ENDSTOPS_MIN + Serial.print(" min"); + #endif + #ifdef ENDSTOPS_MAX + Serial.print(" max"); + #endif + #ifdef ENDSTOPS_SOFT + Serial.print(" soft"); + #endif + Serial.println(); + #endif + Serial.println("--END--"); +} + #ifndef UNIT_TEST void setup() { diff --git a/src/main.h b/src/main.h index 01fa659..c9a156b 100644 --- a/src/main.h +++ b/src/main.h @@ -23,5 +23,6 @@ uint8_t parse_arguments(char ** arguments, String, uint8_t); extern void register_module(const Command commands[], void (*loop_fn)(void)); void get_version(String); +void get_modules(String); #define MAIN_H #endif \ No newline at end of file diff --git a/src/modules/stage/stage.cpp b/src/modules/stage/stage.cpp index 95b5983..c37c1f0 100644 --- a/src/modules/stage/stage.cpp +++ b/src/modules/stage/stage.cpp @@ -110,6 +110,7 @@ void start_move(long displ[n_motors]) move_start_time = micros(); final_scaled_t = (float)max_steps * min_step_delay; //NB total time taken will be final_scaled_t + 2*ramp_time stage_moving = true; + Serial.println("done."); } void stage_loop() @@ -209,6 +210,7 @@ void stage_release(String command) { releaseMotor(i); } + Serial.println("done"); } void stage_p(String command) diff --git a/src/modules/stage/stage.h b/src/modules/stage/stage.h index 7e4ee94..68b0b16 100644 --- a/src/modules/stage/stage.h +++ b/src/modules/stage/stage.h @@ -4,7 +4,6 @@ #include #define EACH_MOTOR for (int i = 0; i < STAGE_N_MOTORS; i++) -#define VER_STRING "Sangaboard Firmware v0.6" void stage_setup(); void stage_loop();