style changes, add .clang-format config file
This commit is contained in:
parent
1c8e725282
commit
2fb61c4be3
4 changed files with 56 additions and 42 deletions
12
.clang-format
Normal file
12
.clang-format
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
BreakBeforeBraces: Allman
|
||||||
|
ColumnLimit: 0
|
||||||
|
FixNamespaceComments: false
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 4
|
||||||
|
NamespaceIndentation: All
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
68
src/main.cpp
68
src/main.cpp
|
|
@ -15,28 +15,28 @@
|
||||||
* Released under GPL v3, 2021
|
* Released under GPL v3, 2021
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "config.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "config.h"
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#ifdef HELP
|
#ifdef HELP
|
||||||
#include "modules/help/help.h"
|
#include "modules/help/help.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STAGE
|
#ifdef STAGE
|
||||||
#include "modules/stage/stage.h"
|
#include "modules/stage/stage.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENDSTOPS
|
#ifdef ENDSTOPS
|
||||||
#include "modules/endstops/endstops.h"
|
#include "modules/endstops/endstops.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LIGHT_SENSOR
|
#ifdef LIGHT_SENSOR
|
||||||
#include "modules/light_sensor/light_sensor.h"
|
#include "modules/light_sensor/light_sensor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const Command * registered_commands[MAX_COMMANDS];
|
const Command *registered_commands[MAX_COMMANDS];
|
||||||
void (*registered_loop_functions[MAX_MODULES])(void);
|
void (*registered_loop_functions[MAX_MODULES])(void);
|
||||||
|
|
||||||
uint8_t registered_commands_count = 0;
|
uint8_t registered_commands_count = 0;
|
||||||
|
|
@ -71,7 +71,7 @@ void handle_command(String received_command)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t parse_arguments(char ** arguments, String command, uint8_t max_args)
|
uint8_t parse_arguments(char **arguments, String command, uint8_t max_args)
|
||||||
{
|
{
|
||||||
char buffer[MAX_ARGUMENT_LENGTH];
|
char buffer[MAX_ARGUMENT_LENGTH];
|
||||||
|
|
||||||
|
|
@ -102,25 +102,25 @@ void get_version(String)
|
||||||
|
|
||||||
void get_modules(String)
|
void get_modules(String)
|
||||||
{
|
{
|
||||||
#if defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_TSL2591)
|
#if defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_TSL2591)
|
||||||
Serial.println(F("Light Sensor: TSL2591"));
|
Serial.println(F("Light Sensor: TSL2591"));
|
||||||
#elif defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_ADS1115)
|
#elif defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_ADS1115)
|
||||||
Serial.println(F("Light Sensor: ADS1115"));
|
Serial.println(F("Light Sensor: ADS1115"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENDSTOPS)
|
#if defined(ENDSTOPS)
|
||||||
Serial.print("Endstops:");
|
Serial.print("Endstops:");
|
||||||
#ifdef ENDSTOPS_MIN
|
#ifdef ENDSTOPS_MIN
|
||||||
Serial.print(" min");
|
Serial.print(" min");
|
||||||
#endif
|
|
||||||
#ifdef ENDSTOPS_MAX
|
|
||||||
Serial.print(" max");
|
|
||||||
#endif
|
|
||||||
#ifdef ENDSTOPS_SOFT
|
|
||||||
Serial.print(" soft");
|
|
||||||
#endif
|
|
||||||
Serial.println();
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENDSTOPS_MAX
|
||||||
|
Serial.print(" max");
|
||||||
|
#endif
|
||||||
|
#ifdef ENDSTOPS_SOFT
|
||||||
|
Serial.print(" soft");
|
||||||
|
#endif
|
||||||
|
Serial.println();
|
||||||
|
#endif
|
||||||
Serial.println("--END--");
|
Serial.println("--END--");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,22 +134,22 @@ void setup()
|
||||||
|
|
||||||
register_module(core_commands, NULL);
|
register_module(core_commands, NULL);
|
||||||
|
|
||||||
#ifdef HELP
|
#ifdef HELP
|
||||||
help_setup();
|
help_setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//register modules
|
//register modules
|
||||||
#ifdef STAGE
|
#ifdef STAGE
|
||||||
stage_setup();
|
stage_setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LIGHT_SENSOR
|
#ifdef LIGHT_SENSOR
|
||||||
light_sensor_setup();
|
light_sensor_setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENDSTOPS
|
#ifdef ENDSTOPS
|
||||||
endstops_setup();
|
endstops_setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
registered_commands[registered_commands_count] = &end_command;
|
registered_commands[registered_commands_count] = &end_command;
|
||||||
Serial.println(F(VERSION_STRING));
|
Serial.println(F(VERSION_STRING));
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#ifdef HELP
|
#ifdef HELP
|
||||||
#ifndef HELP_H
|
#ifndef HELP_H
|
||||||
#include <Arduino.h>
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
void help(String);
|
void help(String);
|
||||||
void help_setup();
|
void help_setup();
|
||||||
const struct Command help_commands[] = {
|
const struct Command help_commands[] = {
|
||||||
{"help", help},
|
{"help", help},
|
||||||
END_COMMAND
|
END_COMMAND};
|
||||||
};
|
|
||||||
#define HELP_H
|
#define HELP_H
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#include "stage.h"
|
#include "stage.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <limits.h>
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <limits.h>
|
||||||
#ifdef SUPPORT_EEPROM
|
#ifdef SUPPORT_EEPROM
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#else
|
#else
|
||||||
#include "dummyEEPROM.h"
|
#include "dummyEEPROM.h"
|
||||||
#endif
|
#endif
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
|
@ -164,6 +164,7 @@ void stage_loop()
|
||||||
{
|
{
|
||||||
scaled_t = elapsed_t;
|
scaled_t = elapsed_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
stage_moving = false;
|
stage_moving = false;
|
||||||
EACH_MOTOR
|
EACH_MOTOR
|
||||||
{
|
{
|
||||||
|
|
@ -179,6 +180,7 @@ void stage_loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stage_moving && notify_on_stop)
|
if (!stage_moving && notify_on_stop)
|
||||||
{
|
{
|
||||||
Serial.println("stopped");
|
Serial.println("stopped");
|
||||||
|
|
@ -206,6 +208,7 @@ void stage_mry(String command)
|
||||||
{
|
{
|
||||||
stage_move_single_axis(1, command);
|
stage_move_single_axis(1, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stage_mrz(String command)
|
void stage_mrz(String command)
|
||||||
{
|
{
|
||||||
stage_move_single_axis(2, command);
|
stage_move_single_axis(2, command);
|
||||||
|
|
@ -276,7 +279,7 @@ void stage_ramp_time(String command)
|
||||||
|
|
||||||
void update_blocking_moves(String command)
|
void update_blocking_moves(String command)
|
||||||
{
|
{
|
||||||
char * args[1];
|
char *args[1];
|
||||||
parse_arguments(args, command, 1);
|
parse_arguments(args, command, 1);
|
||||||
if (args[0][0] == '?')
|
if (args[0][0] == '?')
|
||||||
{
|
{
|
||||||
|
|
@ -307,7 +310,7 @@ void stage_stop(String command)
|
||||||
void is_stage_moving(String command)
|
void is_stage_moving(String command)
|
||||||
{
|
{
|
||||||
//TODO: should I bother checking for a ?
|
//TODO: should I bother checking for a ?
|
||||||
Serial.println(stage_moving?"true":"false");
|
Serial.println(stage_moving ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
void activate_notify_on_stop(String command)
|
void activate_notify_on_stop(String command)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue