2013-03-10 18:26:41 +00:00
|
|
|
/*
|
|
|
|
Serial Adapter Project: Dynamic serial TTY passthroughs
|
2013-03-27 01:38:14 +00:00
|
|
|
by: Mike Crosson
|
|
|
|
Nusku Networks
|
|
|
|
date: 2013/03/09
|
|
|
|
license: CC-BY SA 3.0 - Creative commons share-alike 3.0
|
|
|
|
use this code however you'd like, just keep this license and
|
|
|
|
attribute.
|
|
|
|
*/
|
2013-03-10 18:26:41 +00:00
|
|
|
|
2013-04-09 21:56:19 +00:00
|
|
|
#include <Metro.h>
|
|
|
|
|
2013-03-10 18:26:41 +00:00
|
|
|
#include "Project.h"
|
2013-04-07 03:20:17 +00:00
|
|
|
#include "Config.h"
|
2013-04-06 21:01:46 +00:00
|
|
|
#include "UIButton.h"
|
|
|
|
#include "UIJoystickPSP.h"
|
2013-04-06 23:21:06 +00:00
|
|
|
#include "UILCD.h"
|
2013-04-07 05:32:42 +00:00
|
|
|
#include "UI.h"
|
2013-03-13 20:29:54 +00:00
|
|
|
|
2013-04-06 22:44:34 +00:00
|
|
|
#include <Adafruit_GFX.h>
|
|
|
|
#include <Adafruit_ST7735.h>
|
|
|
|
#include <SD.h>
|
|
|
|
#include <SPI.h>
|
|
|
|
|
2013-04-25 02:49:26 +00:00
|
|
|
#include <TimerThree.h>
|
|
|
|
|
2013-04-07 05:32:42 +00:00
|
|
|
UI* ui;
|
|
|
|
Config* config;
|
2013-04-06 22:44:34 +00:00
|
|
|
|
2013-04-25 02:49:26 +00:00
|
|
|
// helper for interrupt method call
|
|
|
|
void processSerial() {
|
|
|
|
config->processSerialData();
|
|
|
|
}
|
|
|
|
|
2013-03-10 18:26:41 +00:00
|
|
|
void setup() {
|
2013-04-17 02:02:09 +00:00
|
|
|
Serial.begin(115200);
|
|
|
|
|
2013-04-07 03:20:17 +00:00
|
|
|
config = new Config();
|
|
|
|
config->setDefaults();
|
2013-03-29 02:36:44 +00:00
|
|
|
|
2013-04-17 23:59:03 +00:00
|
|
|
ui = new UI();
|
2013-04-25 02:49:26 +00:00
|
|
|
|
|
|
|
// Setup serial IO on an interrupt timer
|
|
|
|
// ***THIS MUST BE DONE AFTER new Config()***
|
|
|
|
Timer3.initialize(100); // initialize timer3, value in micro seconds
|
|
|
|
Timer3.pwm(timerThreePin, 512); // setup pwm on appropriate pin, 50% duty cycle
|
|
|
|
Timer3.attachInterrupt(processSerial); // attaches method as a timer overflow interrupt
|
2013-03-10 18:26:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
2013-04-25 02:49:26 +00:00
|
|
|
// Serial data is processed via an interrupt so isn't needed in the main loop
|
2013-04-07 05:32:42 +00:00
|
|
|
ui->processInputEvents();
|
2013-04-09 21:56:19 +00:00
|
|
|
ui->processTimeoutEvents();
|
2013-03-10 18:26:41 +00:00
|
|
|
}
|
2013-04-06 22:44:34 +00:00
|
|
|
|