2021-11-03 12:00:05 +00:00
|
|
|
/**
|
|
|
|
* \file main.cpp
|
|
|
|
* Main application entry point.
|
|
|
|
* Arduino Style but still a .cpp file
|
|
|
|
*/
|
|
|
|
|
2019-09-04 13:00:53 +02:00
|
|
|
#include "Arduino.h"
|
2019-01-10 16:42:29 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
2019-09-04 15:28:38 +02:00
|
|
|
#include "CommandHandler.h"
|
|
|
|
#include "DisplayProxyMAX7456.h"
|
2019-01-10 16:42:29 +01:00
|
|
|
|
2021-11-03 12:00:05 +00:00
|
|
|
DisplayProxyMAX7456 display;
|
2021-10-28 11:50:57 +00:00
|
|
|
CommandHandler cmd_handler(&display);
|
2019-09-04 13:00:53 +02:00
|
|
|
|
2021-10-28 14:44:20 +00:00
|
|
|
/**
|
|
|
|
* Setup handler (Arduino Style)
|
2021-11-03 12:00:05 +00:00
|
|
|
*
|
2021-10-28 14:44:20 +00:00
|
|
|
* Write some debug information to the serial port and initialize the display.
|
|
|
|
*/
|
2019-09-04 13:00:53 +02:00
|
|
|
void setup()
|
|
|
|
{
|
2021-11-03 12:00:05 +00:00
|
|
|
Serial.begin(BAUDRATE);
|
|
|
|
|
|
|
|
Serial.println("================================================================================");
|
|
|
|
Serial.println("Firmware: " PROJECT_NAME);
|
|
|
|
Serial.println("Version: " VERSION_STRING);
|
|
|
|
Serial.println("Built: " __DATE__ ", " __TIME__);
|
|
|
|
Serial.println("================================================================================");
|
|
|
|
Serial.println("Initialize...");
|
|
|
|
|
|
|
|
display.setOffset(DISP_OFFSET_X, DISP_OFFSET_Y);
|
|
|
|
|
|
|
|
display.write(0, 0, "==========================");
|
|
|
|
display.write(0, 1, "Firmware: " PROJECT_NAME);
|
|
|
|
display.write(0, 2, "Version: " VERSION_STRING);
|
|
|
|
display.write(0, 3, "Built: " __DATE__ ", " __TIME__);
|
|
|
|
display.write(0, 4, "==========================");
|
|
|
|
|
|
|
|
delay(3000);
|
|
|
|
display.clear();
|
|
|
|
Serial.println("Ready!");
|
2019-09-04 13:00:53 +02:00
|
|
|
}
|
|
|
|
|
2021-10-28 14:44:20 +00:00
|
|
|
/**
|
|
|
|
* Loop handler (Arduino Style)
|
2021-11-03 12:00:05 +00:00
|
|
|
*
|
2021-10-28 14:44:20 +00:00
|
|
|
* Continously read the serial port if input is available. On line change send to the command handler.
|
|
|
|
*/
|
2019-09-04 13:00:53 +02:00
|
|
|
void loop()
|
|
|
|
{
|
2021-11-03 12:00:05 +00:00
|
|
|
while (Serial.available() > 0)
|
|
|
|
{
|
|
|
|
String input = Serial.readStringUntil('\n');
|
|
|
|
cmd_handler.parseJSON(input.c_str());
|
|
|
|
}
|
2019-01-10 16:42:29 +01:00
|
|
|
}
|