sangaboard-firmware/src/main.h
Filip Ayazi 1c8e725282 Reduce memory use
* Command definition now uses char * instead of String
 * registered_commands is now an array of pointers to Commands,
   previously this was an array of Command and was allocated to
   MAX_COMMANDS entries which were then overwritten with the module
   provided Commands, so every Command used twice as much memory. This
   saves ~200bytes
 * Several (u)ints are now (u)int8_t

On the nano with all modules included this reduces global RAM use from
1676 bytes to 1237 bytes (from 81.8% to 60.4%).
2021-07-14 01:47:21 +01:00

32 lines
No EOL
732 B
C

#ifndef MAIN_H
#include "config.h"
#include <Arduino.h>
#ifdef DEBUG_ON
#define D(x) Serial.println(x)
#else
#define D(x)
#endif
#define END_COMMAND \
{ \
"", NULL \
}
#define CHECK_END_COMMAND(C) check_end_command(C)
struct Command
{
const char * command;
void (*run)(String);
};
inline bool check_end_command(Command c) { return strlen(c.command) > 0; }
inline bool check_end_command(Command * c) {return strlen(c->command) > 0; }
const Command end_command = END_COMMAND;
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