Commit 917d1df9 authored by Eric Duminil's avatar Eric Duminil
Browse files

Force F strings doc for commands

parent d855f4f1
Pipeline #2914 passed with stage
in 1 minute and 50 seconds
......@@ -71,14 +71,15 @@ namespace sensor {
Serial.print(F("Auto-calibration is "));
Serial.println(config::auto_calibrate_sensor ? "ON." : "OFF.");
sensor_console::defineIntCommand("co2", setCO2forDebugging, " 1500 (Sets co2 level, for debugging purposes)");
sensor_console::defineIntCommand("timer", setTimer, " 30 (Sets measurement interval, in s)");
sensor_console::defineCommand("calibrate", startCalibrationProcess, " (Starts calibration process)");
sensor_console::defineIntCommand("co2", setCO2forDebugging, F(" 1500 (Sets co2 level, for debugging purposes)"));
sensor_console::defineIntCommand("timer", setTimer, F(" 30 (Sets measurement interval, in s)"));
sensor_console::defineCommand("calibrate", startCalibrationProcess, F(" (Starts calibration process)"));
sensor_console::defineIntCommand("calibrate", calibrateSensorToSpecificPPM,
" 600 (Starts calibration process, to given ppm)");
F(" 600 (Starts calibration process, to given ppm)"));
sensor_console::defineIntCommand("calibrate!", calibrateSensorRightNow,
" 600 (Calibrates right now, to given ppm)");
sensor_console::defineIntCommand("auto_calibrate", setAutoCalibration, " 0/1 (Disables/enables autocalibration)");
F(" 600 (Calibrates right now, to given ppm)"));
sensor_console::defineIntCommand("auto_calibrate", setAutoCalibration,
F(" 0/1 (Disables/enables autocalibration)"));
}
//NOTE: should timer deviation be used to adjust measurement_timestep?
......
......@@ -115,9 +115,9 @@ namespace csv_writer {
showFilesystemContent();
Serial.println();
sensor_console::defineIntCommand("csv", setCSVinterval, " 60 (Sets CSV writing interval, in s)");
sensor_console::defineCommand("format_filesystem", formatFilesystem, " (Deletes the whole filesystem)");
sensor_console::defineCommand("show_csv", showCSVContent, " (Displays the complete CSV file on Serial)");
sensor_console::defineIntCommand("csv", setCSVinterval, F(" 60 (Sets CSV writing interval, in s)"));
sensor_console::defineCommand("format_filesystem", formatFilesystem, F(" (Deletes the whole filesystem)"));
sensor_console::defineCommand("show_csv", showCSVContent, F(" (Displays the complete CSV file on Serial)"));
}
File openOrCreate() {
......
......@@ -74,7 +74,7 @@ namespace led_effects {
pixels.begin();
pixels.setBrightness(config::max_brightness);
LEDsOff();
sensor_console::defineCommand("night_mode", toggleNightMode, " (Toggles night mode on/off)");
sensor_console::defineCommand("night_mode", toggleNightMode, F(" (Toggles night mode on/off)"));
}
void toggleNightMode() {
......
......@@ -36,9 +36,9 @@ namespace mqtt {
// mqttClient.setSocketTimeout(config::mqtt_timeout); //NOTE: somehow doesn't seem to have any effect on connect()
mqttClient.setServer(config::mqtt_server, config::mqtt_port);
sensor_console::defineIntCommand("mqtt", setMQTTinterval, " 60 (Sets MQTT sending interval, in s)");
sensor_console::defineIntCommand("mqtt", setMQTTinterval, F(" 60 (Sets MQTT sending interval, in s)"));
sensor_console::defineCommand("local_ip", sendInfoAboutLocalNetwork,
" (Sends local IP and SSID via MQTT. Can be useful to find sensor)");
F(" (Sends local IP and SSID via MQTT. Can be useful to find sensor)"));
}
void publish(const char *timestamp, int16_t co2, float temperature, float humidity) {
......
......@@ -19,8 +19,8 @@ namespace sensor_console {
Command commands[MAX_COMMANDS];
//NOTE: Probably possible to DRY (with templates?)
//TODO: Allow F-Strings
void defineCommand(const char *name, void (*function)(void), const char *doc) {
void defineCommand(const char *name, void (*function)(void), const __FlashStringHelper *doc_fstring) {
const char *doc = (const char PROGMEM*) doc_fstring;
if (commands_count < MAX_COMMANDS) {
commands[commands_count].name = name;
commands[commands_count].voidFunction = function;
......@@ -32,7 +32,8 @@ namespace sensor_console {
}
}
void defineIntCommand(const char *name, void (*function)(int32_t), const char *doc) {
void defineIntCommand(const char *name, void (*function)(int32_t), const __FlashStringHelper *doc_fstring) {
const char *doc = (const char PROGMEM*) doc_fstring;
if (commands_count < MAX_COMMANDS) {
commands[commands_count].name = name;
commands[commands_count].intFunction = function;
......
......@@ -10,8 +10,8 @@
namespace sensor_console {
void processSerialInput(const byte in_byte);
void runCommand(const char *command);
void defineIntCommand(const char *command, void (*function)(int32_t), const char *doc);
void defineCommand(const char *command, void (*function)(void), const char *doc);
void defineIntCommand(const char *command, void (*function)(int32_t), const __FlashStringHelper *ifsh);
void defineCommand(const char *command, void (*function)(void), const __FlashStringHelper *ifsh);
}
#endif
......@@ -67,11 +67,11 @@ void Ampel::showFreeSpace() {
Ampel::Ampel() :
board(current_board), sensorId("ESP" + macToID()), max_loop_duration(0) {
sensor_console::defineIntCommand("set_time", ntp::setLocalTime, " 1618829570 (Sets time to the given UNIX time)");
sensor_console::defineCommand("free", Ampel::showFreeSpace, " (Displays available heap space)");
sensor_console::defineIntCommand("set_time", ntp::setLocalTime, F(" 1618829570 (Sets time to the given UNIX time)"));
sensor_console::defineCommand("free", Ampel::showFreeSpace, F(" (Displays available heap space)"));
sensor_console::defineCommand("reset", []() {
ESP.restart();
}, " (Restarts the sensor)");
}, F(" (Restarts the sensor)"));
}
Ampel ampel;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment