Skip to content

Commit 6b7aa39

Browse files
committed
Fix log levels for STM32 conflict
1 parent 105a450 commit 6b7aa39

File tree

19 files changed

+96
-94
lines changed

19 files changed

+96
-94
lines changed

AtFinder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void AtFinder::setup(uint8_t maxTextLength, CallbackInterface *callback) {
5050
_maxTextLength = maxTextLength;
5151
_text = (char *)malloc(_maxTextLength + 1);
5252
_callback = callback;
53-
LOG(LogLevel::DEBUG, "AtFinder::setup with _maxTextLength %d", _maxTextLength);
53+
LOG(LogLevel::LOG_DEBUG, "AtFinder::setup with _maxTextLength %d", _maxTextLength);
5454
}
5555

5656
void AtFinder::processInputChar(char hot) {

Configurator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void Configurator::initialise() {
5050
if (display != nullptr) {
5151
_inputManager->setDisplay(display);
5252
} else {
53-
LOG(LogLevel::ERROR, "Could not get display ID %d required by the input, user input not available", displayId);
53+
LOG(LogLevel::LOG_ERROR, "Could not get display ID %d required by the input, user input not available", displayId);
5454
}
5555
}
5656
}

Configurator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Configurator {
3131
/// @param consoleStream Pointer to the Stream for console interaction
3232
/// @param commandStationStream Pointer to the Stream for the CommandStation connection
3333
/// @param logLevel LogLevel to set (default WARN)
34-
Configurator(Stream *consoleStream, Stream *commandStationStream, LogLevel logLevel = LogLevel::WARN);
34+
Configurator(Stream *consoleStream, Stream *commandStationStream, LogLevel logLevel = LogLevel::LOG_WARN);
3535

3636
/// @brief Call all one-shot initialisation or begin methods on startup
3737
void initialise();

Controller.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Controller::Controller(Stream *consoleStream, Stream *commandStationStream, Disp
3535
void Controller::begin() {
3636
_displayManager->startDisplays(); // Start displays
3737
_inputManager->startInput(); // Start input
38-
LOG(LogLevel::MESSAGE, "EX-Display version %s", VERSION);
38+
LOG(LogLevel::LOG_MESSAGE, "EX-Display version %s", VERSION);
3939
_displayManager->displayStartupInfo(VERSION); // Display version info
4040
}
4141

@@ -54,7 +54,7 @@ void Controller::update() {
5454
// Configurator
5555
// When the time has passed, turn the pause of and clear each display to enable normal display operation
5656
if (_pauseDisplayUpdates && millis() > _pauseDisplayUpdatesUntil) {
57-
LOG(LogLevel::DEBUG, "_pauseDisplayUpdatesUntil time exceeded, resume display updates");
57+
LOG(LogLevel::LOG_DEBUG, "_pauseDisplayUpdatesUntil time exceeded, resume display updates");
5858
_pauseDisplayUpdatesUntil = 0;
5959
_pauseDisplayUpdates = false;
6060
_displayManager->clearAllDisplays();
@@ -79,9 +79,9 @@ void Controller::update() {
7979
}
8080

8181
void Controller::updateScreen(uint8_t screenId, uint8_t row, const char *text) {
82-
LOG(LogLevel::DEBUG, "Controller::updateScreen(%d, %d, %s)", screenId, row, text);
82+
LOG(LogLevel::LOG_DEBUG, "Controller::updateScreen(%d, %d, %s)", screenId, row, text);
8383
if (_screenManager == nullptr) {
84-
LOG(LogLevel::DEBUG, "Controller::_screenManager == nullptr");
84+
LOG(LogLevel::LOG_DEBUG, "Controller::_screenManager == nullptr");
8585
return;
8686
}
8787
Screen *screen = _screenManager->updateScreen(screenId);
@@ -91,7 +91,7 @@ void Controller::updateScreen(uint8_t screenId, uint8_t row, const char *text) {
9191
}
9292

9393
void Controller::onInputAction(InputAction action) {
94-
LOG(LogLevel::DEBUG, "Controller::onInputAction(%d)", action);
94+
LOG(LogLevel::LOG_DEBUG, "Controller::onInputAction(%d)", action);
9595
// No inputs are valid if there are no displays or screens, so just bail out
9696
if (_displayManager == nullptr || _screenManager == nullptr || _displayManager->getFirstDisplay() == nullptr ||
9797
_screenManager->getFirstScreen() == nullptr) {
@@ -101,33 +101,33 @@ void Controller::onInputAction(InputAction action) {
101101
switch (action) {
102102
// Left press selects the previous screen for display
103103
case InputAction::PRESS_LEFT: {
104-
LOG(LogLevel::DEBUG, "Controller::onInputAction(InputAction::PRESS_LEFT)");
104+
LOG(LogLevel::LOG_DEBUG, "Controller::onInputAction(InputAction::PRESS_LEFT)");
105105
_selectPreviousScreen(display);
106106
break;
107107
}
108108
// Right press selects the next screen for display
109109
case InputAction::PRESS_RIGHT: {
110-
LOG(LogLevel::DEBUG, "Controller::onInputAction(InputAction::PRESS_RIGHT)");
110+
LOG(LogLevel::LOG_DEBUG, "Controller::onInputAction(InputAction::PRESS_RIGHT)");
111111
_selectNextScreen(display);
112112
break;
113113
}
114114
// Up scrolls the screen up one row
115115
case InputAction::PRESS_UP: {
116-
LOG(LogLevel::DEBUG, "Controller::onInputAction(InputAction::PRESS_UP)");
116+
LOG(LogLevel::LOG_DEBUG, "Controller::onInputAction(InputAction::PRESS_UP)");
117117
break;
118118
}
119119
// Down scrolls the screen down one row
120120
case InputAction::PRESS_DOWN: {
121-
LOG(LogLevel::DEBUG, "Controller::onInputAction(InputAction::PRESS_DOWN)");
121+
LOG(LogLevel::LOG_DEBUG, "Controller::onInputAction(InputAction::PRESS_DOWN)");
122122
break;
123123
}
124124
// Centre moves input control to the next display - does nothing until multiple displays are supported
125125
case InputAction::PRESS_CENTRE: {
126-
LOG(LogLevel::DEBUG, "Controller::onInputAction(InputAction::PRESS_CENTRE)");
126+
LOG(LogLevel::LOG_DEBUG, "Controller::onInputAction(InputAction::PRESS_CENTRE)");
127127
break;
128128
}
129129
default: {
130-
LOG(LogLevel::DEBUG, "Controller::onInputAction(Unknown)");
130+
LOG(LogLevel::LOG_DEBUG, "Controller::onInputAction(Unknown)");
131131
break;
132132
}
133133
}
@@ -153,7 +153,7 @@ void Controller::_selectPreviousScreen(DisplayInterface *display) {
153153
previousId = _screenManager->getPreviousScreen(screen)->getId();
154154
}
155155
display->setScreenId(previousId);
156-
LOG(LogLevel::DEBUG, "Controller::_selectPreviousScreen: _displayId=%d|screenId=%d|previousId=%d", display->getId(),
156+
LOG(LogLevel::LOG_DEBUG, "Controller::_selectPreviousScreen: _displayId=%d|screenId=%d|previousId=%d", display->getId(),
157157
screenId, previousId);
158158
}
159159

@@ -169,6 +169,6 @@ void Controller::_selectNextScreen(DisplayInterface *display) {
169169
nextId = _screenManager->getNextScreen(screen)->getId();
170170
}
171171
display->setScreenId(nextId);
172-
LOG(LogLevel::DEBUG, "Controller::_selectNextScreen: _displayId=%d|screenId=%d|nextId=%d", display->getId(),
172+
LOG(LogLevel::LOG_DEBUG, "Controller::_selectNextScreen: _displayId=%d|screenId=%d|nextId=%d", display->getId(),
173173
screenId, nextId);
174174
}

Defines.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020

2121
// Give log defines their values before user config
2222
#include "Logger.h"
23-
#define LOG_NONE LogLevel::NONE
24-
#define LOG_ERROR LogLevel::ERROR
25-
#define LOG_WARN LogLevel::WARN
26-
#define LOG_INFO LogLevel::INFO
27-
#define LOG_DEBUG LogLevel::DEBUG
23+
#define LOG_NONE LOG_NONE
24+
#define LOG_ERROR LOG_ERROR
25+
#define LOG_WARN LOG_WARN
26+
#define LOG_INFO LOG_INFO
27+
#define LOG_DEBUG LOG_DEBUG
2828

2929
#ifndef PIO_UNIT_TESTING // Don't warn or use user config when testing
3030
// Incude user's myConfig.h if it exists.

DisplayManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
DisplayManager::DisplayManager() : _firstDisplay(nullptr), _logger(nullptr), _nextDisplayId(0) {}
2424

2525
void DisplayManager::addDisplay(DisplayInterface *display) {
26-
LOG(LogLevel::DEBUG, "DisplayManager::addDisplay()");
26+
LOG(LogLevel::LOG_DEBUG, "DisplayManager::addDisplay()");
2727
if (display == nullptr) {
2828
return;
2929
}
@@ -43,7 +43,7 @@ void DisplayManager::addDisplay(DisplayInterface *display) {
4343
}
4444

4545
void DisplayManager::startDisplays() {
46-
LOG(LogLevel::DEBUG, "DisplayManager::startDisplays()");
46+
LOG(LogLevel::LOG_DEBUG, "DisplayManager::startDisplays()");
4747
if (_firstDisplay == nullptr) {
4848
return;
4949
}
@@ -54,7 +54,7 @@ void DisplayManager::startDisplays() {
5454
}
5555

5656
void DisplayManager::clearAllDisplays() {
57-
LOG(LogLevel::DEBUG, "DisplayManager::clearAllDisplays()");
57+
LOG(LogLevel::LOG_DEBUG, "DisplayManager::clearAllDisplays()");
5858
if (_firstDisplay == nullptr) {
5959
return;
6060
}
@@ -66,7 +66,7 @@ void DisplayManager::clearAllDisplays() {
6666
}
6767

6868
void DisplayManager::displayStartupInfo(const char *version) {
69-
LOG(LogLevel::DEBUG, "DisplayManager::displayStartupInfo(%s)", version);
69+
LOG(LogLevel::LOG_DEBUG, "DisplayManager::displayStartupInfo(%s)", version);
7070
// Do nothing if we don't have a DisplayManager or any displays
7171
if (_firstDisplay == nullptr) {
7272
return;

InputInterface.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void InputInterface::setDisplay(DisplayInterface *display) {
3030
return;
3131
}
3232
_display = display;
33-
LOG(LogLevel::DEBUG, "DisplayInterface::setDisplay() - display ID %d", _display->getId());
33+
LOG(LogLevel::LOG_DEBUG, "DisplayInterface::setDisplay() - display ID %d", _display->getId());
3434
}
3535

3636
void InputInterface::setDebounceDelay(unsigned long delay) { _debounceDelay = delay; }
@@ -48,12 +48,12 @@ InputAction InputInterface::_debounceOrHeld(InputAction currentAction) {
4848
// If we're going from some action to none and not holding, then it must've been a press
4949
if ((currentTime - _lastDebounceTime) > _debounceDelay && currentAction == InputAction::PRESS_NONE && !_isHolding) {
5050
returnAction = _lastAction;
51-
LOG(LogLevel::DEBUG, "InputInterface::_debounceOrHeld() - press detected: %d", returnAction);
51+
LOG(LogLevel::LOG_DEBUG, "InputInterface::_debounceOrHeld() - press detected: %d", returnAction);
5252
}
5353
_lastDebounceTime = currentTime;
5454
_lastAction = currentAction;
5555
_isHolding = false;
56-
LOG(LogLevel::DEBUG, "InputInterface::_debounceOrHeld() - action changed, resetting");
56+
LOG(LogLevel::LOG_DEBUG, "InputInterface::_debounceOrHeld() - action changed, resetting");
5757
return returnAction;
5858
}
5959
// Check if the debounce time has been exceeded
@@ -63,7 +63,7 @@ InputAction InputInterface::_debounceOrHeld(InputAction currentAction) {
6363
if (!_isHolding) {
6464
// Flag that we're holding, and change from PRESS to HOLD
6565
_isHolding = true;
66-
LOG(LogLevel::DEBUG, "InputInterface::_debounceOrHeld() - hold detected: %d", currentAction);
66+
LOG(LogLevel::LOG_DEBUG, "InputInterface::_debounceOrHeld() - hold detected: %d", currentAction);
6767
switch (currentAction) {
6868
case InputAction::PRESS_UP:
6969
returnAction = InputAction::HOLD_UP;
@@ -91,7 +91,7 @@ InputAction InputInterface::_debounceOrHeld(InputAction currentAction) {
9191
}
9292

9393
InputAction InputInterface::_calculateInputAction(int touchX, int touchY, int displayWidth, int displayHeight) {
94-
LOG(LogLevel::DEBUG, "InputInterface::_calculateInputAction(%d, %d, %d, %d)", touchX, touchY, displayWidth,
94+
LOG(LogLevel::LOG_DEBUG, "InputInterface::_calculateInputAction(%d, %d, %d, %d)", touchX, touchY, displayWidth,
9595
displayHeight);
9696
InputAction action = InputAction::PRESS_NONE;
9797
int thirdWidth = displayWidth / 3;

InputManager.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
InputManager::InputManager() : _display(nullptr), _input(nullptr), _logger(nullptr), _callback(nullptr) {}
2626

2727
void InputManager::addInput(InputInterface *input) {
28-
LOG(LogLevel::DEBUG, "InputManager::addInput()");
28+
LOG(LogLevel::LOG_DEBUG, "InputManager::addInput()");
2929
if (input == nullptr) {
30-
LOG(LogLevel::ERROR, "InputInterface doesn't exist, user input will not be available");
30+
LOG(LogLevel::LOG_ERROR, "InputInterface doesn't exist, user input will not be available");
3131
return;
3232
}
3333
_input = input;
3434
if (_logger) {
3535
_input->setLogger(_logger);
3636
}
3737
if (_callback == nullptr) {
38-
LOG(LogLevel::ERROR, "InputInterface callback not set, user input will not be available");
38+
LOG(LogLevel::LOG_ERROR, "InputInterface callback not set, user input will not be available");
3939
return;
4040
}
4141
_input->setCallback(_callback);
@@ -56,12 +56,12 @@ void InputManager::setDisplay(DisplayInterface *display) {
5656
if (display == nullptr || _input == nullptr) {
5757
return;
5858
}
59-
LOG(LogLevel::DEBUG, "InputManager::setDisplay() - display ID %d", display->getId());
59+
LOG(LogLevel::LOG_DEBUG, "InputManager::setDisplay() - display ID %d", display->getId());
6060
_input->setDisplay(display);
6161
}
6262

6363
void InputManager::startInput() {
64-
LOG(LogLevel::DEBUG, "InputManager::startInput()");
64+
LOG(LogLevel::LOG_DEBUG, "InputManager::startInput()");
6565
if (_input != nullptr) {
6666
_input->begin();
6767
}

Logger.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "Logger.h"
1919

20-
Logger::Logger(Stream *outputStream) : _outputStream(outputStream), _currentLevel(LogLevel::WARN) {}
20+
Logger::Logger(Stream *outputStream) : _outputStream(outputStream), _currentLevel(LogLevel::LOG_WARN) {}
2121

2222
void Logger::setLogLevel(LogLevel logLevel) { _currentLevel = logLevel; }
2323

@@ -28,19 +28,19 @@ void Logger::log(LogLevel logLevel, const char *format, ...) {
2828
// Setup the prefix
2929
const char *prefix;
3030
switch (logLevel) {
31-
case LogLevel::MESSAGE:
31+
case LogLevel::LOG_MESSAGE:
3232
prefix = "[MESSAGE] ";
3333
break;
34-
case LogLevel::ERROR:
34+
case LogLevel::LOG_ERROR:
3535
prefix = "[ERROR] ";
3636
break;
37-
case LogLevel::WARN:
37+
case LogLevel::LOG_WARN:
3838
prefix = "[WARN] ";
3939
break;
40-
case LogLevel::INFO:
40+
case LogLevel::LOG_INFO:
4141
prefix = "[INFO] ";
4242
break;
43-
case LogLevel::DEBUG:
43+
case LogLevel::LOG_DEBUG:
4444
prefix = "[DEBUG] ";
4545
break;
4646
default:

Logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
_logger->log(level, __VA_ARGS__)
2828

2929
/// @brief Define valid log levels in ascending order
30-
enum LogLevel { MESSAGE, NONE, ERROR, WARN, INFO, DEBUG };
30+
enum LogLevel { LOG_MESSAGE, LOG_NONE, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG };
3131

3232
/// @brief Class to enable simple logging to a Stream object with different log levels
3333
/// This enables embedding permanent error, warn, info, and debug messages in the software, with the user defining the

0 commit comments

Comments
 (0)