diff --git a/platformio.ini b/platformio.ini index 8656613..d468130 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,6 +20,12 @@ lib_deps = waspinator/AccelStepper@^1.61 lib_ldf_mode = chain +[env:uno] +platform = atmelavr +board = uno +build_flags = -D MCU_UNO + + [env:nano] platform = atmelavr board = nanoatmega328new @@ -42,14 +48,14 @@ platform = ststm32 board = bluepill_f103c8 upload_protocol = stlink build_flags = - -D MCU_BLUEPILL - -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC - -D USBCON - -D USBD_VID=0x0483 - -D USBD_PID=0x5740 - -D USB_MANUFACTURER="Unknown" - -D USB_PRODUCT="\"BLUEPILL_F103C8\"" - -D HAL_PCD_MODULE_ENABLED + -D MCU_BLUEPILL + -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC + -D USBCON + -D USBD_VID=0x0483 + -D USBD_PID=0x5740 + -D USB_MANUFACTURER="Unknown" + -D USB_PRODUCT="\"BLUEPILL_F103C8\"" + -D HAL_PCD_MODULE_ENABLED [env:esp32] platform = espressif32 diff --git a/src/boards.h b/src/boards.h index 0ade14f..4482bd0 100644 --- a/src/boards.h +++ b/src/boards.h @@ -9,6 +9,8 @@ #define BOARD_SANGABOARDv5 #elif defined(MCU_ESP32) #define BOARD_CUSTOM_ESP32 + #elif defined(MCU_UNO) + #define BOARD_CUSTOM #else #error "Invalid build config - must specify MCU type" #endif @@ -23,6 +25,7 @@ #define ENDSTOPS_PULLUPS true #define WIRING_ENDSTOPS_MIN {A0,A1,A2} #define WIRING_ENDSTOPS_MAX {A3,A4,A5} + #define SERIAL_PORT Serial #elif defined(BOARD_SANGABOARDv2) #define BOARD_STRING "Sangaboard v0.2" #define WIRING_MOTOR_X 13, 12, 11, 10 @@ -32,6 +35,7 @@ #define ENDSTOPS_PULLUPS true #define WIRING_ENDSTOPS_MIN {A0,A1,A2} #define WIRING_ENDSTOPS_MAX {A3,A4,A5} + #define SERIAL_PORT Serial #elif defined(BOARD_CUSTOM_BLUEPILL) #define BOARD_STRING "Custom Bluepill board" #define WIRING_MOTOR_X PB11, PB10, PB1, PB0 @@ -41,6 +45,7 @@ #define ENDSTOPS_PULLUPS true #define WIRING_ENDSTOPS_MIN {A0,A1,A2} #define WIRING_ENDSTOPS_MAX {A3,A4,A5} + #define SERIAL_PORT Serial #elif defined(BOARD_CUSTOM_PICO) #define BOARD_STRING "Custom Pico board" #define WIRING_MOTOR_X 2, 3, 4, 5 @@ -54,6 +59,7 @@ #define WIRING_ADDITIONAL_STEPPERS = {{0, 1, 22, 23}} #define WIRING_STEPSTICK {13,14,15} //enable, step, dir todo: move to boards.h //TODO: illumination, 4th motor wiring + #define SERIAL_PORT Serial #elif defined(BOARD_SANGABOARDv5) #define BOARD_STRING "Sangaboard v0.5" #define WIRING_MOTOR_X 2, 3, 4, 5 @@ -66,7 +72,14 @@ #define ADDITIONAL_STEPPERS 1 #define WIRING_ADDITIONAL_STEPPERS = {{0, 1, 22, 23}} #define WIRING_STEPSTICK {23,22,1} //enable, step, dir todo: move to boards.h - //TODO: illumination, 4th motor wiring + #define WIRING_SERIAL_TX 8 + #define WIRING_SERIAL_RX 9 + #ifdef USB_SERIAL + #define SERIAL_PORT Serial + #else + #define SERIAL_PORT Serial2 + #endif + //TODO: move illumination wiring here, 4th motor support #elif defined(BOARD_CUSTOM_ESP32) #define BOARD_STRING "Custom ESP32 board" #define WIRING_MOTOR_X 34, 32, 25, 27 @@ -76,9 +89,10 @@ #define ENDSTOPS_PULLUPS true #define WIRING_ENDSTOPS_MIN {A0,A1,A2} #define WIRING_ENDSTOPS_MAX {A3,A4,A5} - #define WIRING_STEPSTICK {13,12,27} + #define WIRING_STEPSTICK {13,12,27} + #define SERIAL_PORT Serial #elif defined(BOARD_CUSTOM) - #define BOARD_STRING "Sangaboard v0.5" + #define BOARD_STRING "Custom board" #define WIRING_MOTOR_X 2, 3, 4, 5 #define WIRING_MOTOR_Y 2, 3, 4, 5 #define WIRING_MOTOR_Z 2, 3, 4, 5 @@ -89,4 +103,5 @@ #define ADDITIONAL_STEPPERS 1 #define WIRING_ADDITIONAL_STEPPERS = {{0, 1, 22, 23}} #define WIRING_STEPSTICK {8,9,10} //enable, step, dir todo: move to boards.h + #define SERIAL_PORT Serial #endif \ No newline at end of file diff --git a/src/config.h b/src/config.h index 5fb4fed..c43e0db 100644 --- a/src/config.h +++ b/src/config.h @@ -1,24 +1,19 @@ #ifndef CONFIGURED //board choice - //#define BOARD_AUTO - //#define BOARD_SANGABOARDv3 - //#define BOARD_SANGABOARDv2 - #define BOARD_SANGABOARDv5 - //#define BOARD_CUSTOM_ESP32 - //#define BOARD_CUSTOM_PICO + #define BOARD_AUTO + //#define BOARD_SANGABOARDv5 - //default to USB serial for now - //#define SERIAL_PORT PiSerial - #define SERIAL_PORT Serial + //without this, default to HW serial where available + //the details are board specific and configured in boards.h + //#define USB_SERIAL - //#define BOARD_CUSTOM #include //defines wiring //general settings #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.4" //temporary hack + #define VERSION_STRING "Sangaboard Firmware v1.0-beta" #define DEBUG_ON //module choice diff --git a/src/main.cpp b/src/main.cpp index 71753b9..c8a19ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,10 +44,6 @@ #include "modules/light_sensor/light_sensor.h" #endif -#ifdef BOARD_SANGABOARDv5 - //arduino::UART PiSerial(8, 9, NC, NC); //TODO this shouldn't be here -#endif - const Command *registered_commands[MAX_COMMANDS]; void (*registered_loop_functions[MAX_MODULES])(void); @@ -140,7 +136,11 @@ void get_modules(String) void setup() { // initialise serial port - //SERIAL_PORT.begin(115200); + #ifdef WIRING_SERIAL_TX + Serial2.setTX(WIRING_SERIAL_TX); + Serial2.setRX(WIRING_SERIAL_RX); + #endif + SERIAL_PORT.begin(115200); while (!SERIAL_PORT) delay(1); diff --git a/src/main.h b/src/main.h index e09d56f..e69ec23 100644 --- a/src/main.h +++ b/src/main.h @@ -13,12 +13,6 @@ } #define CHECK_END_COMMAND(C) check_end_command(C) -//TODO: temporarily disabled for philhower compatibilty -//extern arduino::UART PiSerial; - -#ifdef BOARD_SANGABOARDv5 -#endif - struct Command { const char * command; diff --git a/src/modules/illumination/illumination.cpp b/src/modules/illumination/illumination.cpp index c9ab59a..259616c 100644 --- a/src/modules/illumination/illumination.cpp +++ b/src/modules/illumination/illumination.cpp @@ -9,11 +9,10 @@ #define PWM_NUM 1 #define WIRING_PWM_LEDS {25} -//TODO: implement some fancier features of TMC controllers + const uint8_t pwm_led_pins[] = WIRING_PWM_LEDS; void illumination_pwm_freq(String command) { - //TODO: make this properly, this is just a test for hacked on/off char * args[1]; parse_arguments(args, command, 2); #ifdef MCU_PICO diff --git a/src/modules/stepstick/stepstick.cpp b/src/modules/stepstick/stepstick.cpp index 606bb3f..6a26c8a 100644 --- a/src/modules/stepstick/stepstick.cpp +++ b/src/modules/stepstick/stepstick.cpp @@ -1,5 +1,4 @@ #include "config.h" -#define STEPSTICK //TODO: remove #ifdef STEPSTICK #include "stepstick.h" #ifdef SUPPORT_EEPROM