Add endstops, light_sensor, test, many fixes
- Added endstop and light_sensor module - Improved configuration by splitting wiring configs to boards.h - Added a unit test for argument parsing - Fixed many smaller bugs
This commit is contained in:
parent
8f66bb7da9
commit
35d969aadd
16 changed files with 875 additions and 64 deletions
30
src/main.cpp
30
src/main.cpp
|
|
@ -28,6 +28,14 @@
|
|||
#include "modules/stage/stage.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENDSTOPS
|
||||
#include "modules/endstops/endstops.h"
|
||||
#endif
|
||||
|
||||
#ifdef LIGHT_SENSOR
|
||||
#include "modules/light_sensor/light_sensor.h"
|
||||
#endif
|
||||
|
||||
Command registered_commands[MAX_COMMANDS];
|
||||
void (*registered_loop_functions[MAX_MODULES])(void);
|
||||
|
||||
|
|
@ -62,19 +70,24 @@ void handle_command(String received_command)
|
|||
#endif
|
||||
}
|
||||
|
||||
uint8_t parse_arguments(String arguments[], String command, uint8_t max_args)
|
||||
uint8_t parse_arguments(char ** arguments, String command, uint8_t max_args)
|
||||
{
|
||||
char buffer[MAX_ARGUMENT_LENGTH];
|
||||
|
||||
uint8_t from = 0;
|
||||
while (command[from] == ' ' && from < command.length())
|
||||
from++;
|
||||
|
||||
uint8_t parsed = 0;
|
||||
while (from < command.length() && parsed < max_args)
|
||||
{
|
||||
int space = command.indexOf(" ", from + 1);
|
||||
int space = command.indexOf(' ', from);
|
||||
if (space == -1)
|
||||
space = command.length();
|
||||
arguments[parsed] = command.substring(from, space);
|
||||
arguments[parsed++].trim();
|
||||
|
||||
from = space;
|
||||
memcpy(buffer, &command[from], space - from);
|
||||
buffer[space - from] = '\0';
|
||||
arguments[parsed++] = strdup(buffer);
|
||||
from = space + 1;
|
||||
}
|
||||
|
||||
return parsed;
|
||||
|
|
@ -97,7 +110,6 @@ void setup()
|
|||
register_module(core_commands, NULL);
|
||||
|
||||
#ifdef HELP
|
||||
// D(help_commands_t[0].command);
|
||||
help_setup();
|
||||
#endif
|
||||
|
||||
|
|
@ -107,11 +119,11 @@ void setup()
|
|||
#endif
|
||||
|
||||
#ifdef LIGHT_SENSOR
|
||||
light_sensor_setup(); //TODO
|
||||
light_sensor_setup();
|
||||
#endif
|
||||
|
||||
#ifdef ENDSTOPS
|
||||
light_sensor_setup(); //TODO
|
||||
endstops_setup();
|
||||
#endif
|
||||
|
||||
registered_commands[registered_commands_count] = END_COMMAND;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue