Compare commits
5 Commits
364c711a04
...
def4197c0b
| Author | SHA1 | Date | |
|---|---|---|---|
| def4197c0b | |||
| 95b1f4f019 | |||
| 8954979aa1 | |||
| 244cfa02c4 | |||
| e13f608b58 |
12
src/custom_types.h
Normal file
12
src/custom_types.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <inttypes.h>
|
||||
typedef struct vehicle_config{
|
||||
uint16_t config_lock;
|
||||
bool auto_detect_track;
|
||||
uint8_t num_tracks;
|
||||
uint8_t selected_track;
|
||||
};
|
||||
|
||||
typedef struct track_data {
|
||||
char name[64];
|
||||
|
||||
};
|
||||
4
src/flags.h
Normal file
4
src/flags.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#define INFO
|
||||
#define WARN
|
||||
#define ERROR
|
||||
#define DEBUG
|
||||
38
src/main.cpp
38
src/main.cpp
@@ -1,18 +1,34 @@
|
||||
#include <Arduino.h>
|
||||
#include "flags.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "modules/lcd/lcd.h"
|
||||
#include "modules/gps/gps.h"
|
||||
#include "modules/logger/system_logger.h"
|
||||
|
||||
|
||||
system_logger *logger_output = new system_logger(&Serial);
|
||||
|
||||
lcd *driver_display = new lcd();
|
||||
gps *gps_module = new gps(&Serial2, logger_output);
|
||||
|
||||
// put function declarations here:
|
||||
int myFunction(int, int);
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
int result = myFunction(2, 3);
|
||||
driver_display->init();
|
||||
driver_display->print_message("Starting Initialization");
|
||||
delay(1000);
|
||||
|
||||
driver_display->print_message("Serial Init...");
|
||||
Serial.begin(115200);
|
||||
delay(500);
|
||||
driver_display->print_message("Serial Init Complete");
|
||||
delay(500);
|
||||
|
||||
driver_display->print_message("GPS Init...");
|
||||
gps_module->init();
|
||||
delay(500);
|
||||
driver_display->print_message("GPS Init Complete");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
|
||||
// put function definitions here:
|
||||
int myFunction(int x, int y) {
|
||||
return x + y;
|
||||
gps_module->parse_task(500);
|
||||
}
|
||||
45
src/modules/lcd/lcd.h
Normal file
45
src/modules/lcd/lcd.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#include "flags.h"
|
||||
#include "modules/logger/system_logger.h"
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
class lcd {
|
||||
private:
|
||||
LiquidCrystal_I2C *_display;
|
||||
system_logger *_logger = nullptr;
|
||||
|
||||
public:
|
||||
lcd();
|
||||
lcd(system_logger *logger);
|
||||
~lcd();
|
||||
int init();
|
||||
int print_message(String message);
|
||||
};
|
||||
|
||||
lcd::lcd() { _display = new LiquidCrystal_I2C(0x27, 20, 4); }
|
||||
|
||||
lcd::lcd(system_logger *logger) {
|
||||
_display = new LiquidCrystal_I2C(0x27, 20, 4);
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
lcd::~lcd() {}
|
||||
|
||||
int lcd::init() {
|
||||
_display->init();
|
||||
_display->backlight();
|
||||
_display->clear();
|
||||
_display->setCursor(0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lcd::print_message(String message) {
|
||||
_display->clear();
|
||||
_display->setCursor(0, 0);
|
||||
_display->print(message);
|
||||
#ifdef INFO
|
||||
if (_logger != nullptr) {
|
||||
_logger->info(message);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
71
src/modules/logger/system_logger.h
Normal file
71
src/modules/logger/system_logger.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "flags.h"
|
||||
|
||||
class system_logger
|
||||
{
|
||||
private:
|
||||
HardwareSerial *_output;
|
||||
int print_message(String pre, String message);
|
||||
public:
|
||||
system_logger(HardwareSerial *output);
|
||||
~system_logger();
|
||||
#ifdef INFO
|
||||
int info(String message);
|
||||
#endif
|
||||
|
||||
#ifdef WARN
|
||||
int warn(String message);
|
||||
#endif
|
||||
|
||||
#ifdef ERROR
|
||||
int error(String message);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
int debug(String message);
|
||||
#endif
|
||||
};
|
||||
|
||||
system_logger::system_logger(HardwareSerial *output)
|
||||
{
|
||||
_output = output;
|
||||
}
|
||||
|
||||
system_logger::~system_logger()
|
||||
{
|
||||
}
|
||||
|
||||
int system_logger::print_message(String pre, String message) {
|
||||
if (_output->availableForWrite()) {
|
||||
_output->print(millis());
|
||||
_output->print(pre);
|
||||
_output->println(message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef INFO
|
||||
int system_logger::info(String message) {
|
||||
return this->print_message(" [INFO] ", message);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WARN
|
||||
int system_logger::warn(String message) {
|
||||
return this->print_message(" [WARNING] ", message);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ERROR
|
||||
int system_logger::error(String message) {
|
||||
return this->print_message(" [ERROR] ", message);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
int system_logger::debug(String message) {
|
||||
return this->print_message(" [DEBUG] ", message);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user