CRINSA-team2025 V1
Documentation du Club Robot INSA Rennes 2025
Chargement...
Recherche...
Aucune correspondance
Logger.h
1//
2// Created by boris on 27/01/2025.
3//
4
5#ifndef LOGGER_H
6#define LOGGER_H
7
8#include <Arduino.h>
9#include "coloring.h"
10#if LCD_OUTPUT
11#include "LiquidCrystal.h"
12#include <string>
13#endif
14
15#define MAX_NAME 50
16#define ERROR_LEVEL 3
17#define WARNING_LEVEL 2
18#define GOOD_LEVEL 1
19#define INFO_LEVEL 0
20#define SCREEN_LEVEL 10
21
22#undef Error_Handler
23#define Error_Handler() \
24while (1) {\
25printf("ERREUR MAJEURE dans %s:%d:%s \n", __FILE__, __LINE__,__FUNCTION__);\
26digitalWrite(LED_RED, HIGH);\
27delay(500);\
28digitalWrite(LED_RED, LOW);\
29delay(500);\
30}
31
32class Logger {
33public:
34 Logger(const char* name);
35 int log(uint8_t level, const char* format, ...);
36 static void setLcdOutput(LiquidCrystal &lcd) {
37 _lcdOutput = &lcd;
38 }
39 static void sameLine(const char* str);
40private:
41 char _name[50];
42 static int log_static(uint8_t level,char* name, const char* format, va_list args);
43 static LiquidCrystal* _lcdOutput;
44 static char _lcdBuffer[4][21];
45 static uint8_t _lcdCursor;
46}; // Logger
47
48#endif //LOGGER_H