1
0
Files
MAX7456JSON/src/main.cpp

75 lines
1.7 KiB
C++
Raw Normal View History

#include "Arduino.h"
2019-01-10 16:42:29 +01:00
#include <SPI.h>
#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
#include "max7456.h"
Max7456 osd;
2019-09-04 15:28:38 +02:00
DisplayProxyMAX7456 proxy(&osd);
CommandHandler cmd_handler(&proxy);
2019-01-10 16:42:29 +01:00
void processSerial()
{
static byte ndx = 0;
char endMarker = '\n';
char rc;
const byte numChars = 128;
char receivedChars[numChars]; // an array to store the received data
while (Serial.available() > 0)
{
rc = Serial.read();
if (rc != endMarker)
{
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars)
{
ndx = numChars - 1;
}
}
else
{
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
2019-09-04 15:28:38 +02:00
cmd_handler.parse(receivedChars);
2019-01-10 16:42:29 +01:00
}
}
}
void setup()
{
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...");
SPI.begin();
osd.init(6);
osd.clearScreen();
osd.setDisplayOffsets(DISP_OFFSET_X, DISP_OFFSET_Y);
osd.setBlinkParams(_8fields, _BT_3BT);
osd.activateOSD();
osd.activateExternalVideo(false);
osd.print("==========================", 0, 0);
osd.print("Firmware: " PROJECT_NAME, 0, 1);
osd.print("Version: " VERSION_STRING, 0, 2);
osd.print("Built: " __DATE__ ", " __TIME__, 0, 3);
osd.print("==========================", 0, 4);
delay(3000);
osd.clearScreen();
Serial.println("Ready!");
}
void loop()
{
processSerial();
2019-01-10 16:42:29 +01:00
}