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
|
|
|
|
|
|
|
#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-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-07 03:20:17 +00:00
|
|
|
UILCD* lcd;
|
|
|
|
Config* config;
|
|
|
|
|
2013-04-06 20:31:44 +00:00
|
|
|
UIButton* okButton;
|
|
|
|
UIButton* cancelButton;
|
2013-04-06 21:01:46 +00:00
|
|
|
UIJoystickPSP* pspJoystick;
|
2013-04-06 22:44:34 +00:00
|
|
|
|
2013-04-07 00:42:58 +00:00
|
|
|
joyDirection joyStickEvent;
|
|
|
|
|
2013-04-07 03:20:17 +00:00
|
|
|
|
2013-03-10 18:26:41 +00:00
|
|
|
|
|
|
|
void setup() {
|
2013-04-06 20:31:44 +00:00
|
|
|
Serial.begin(9600);
|
|
|
|
Serial.println("Setup!");
|
2013-03-27 01:38:14 +00:00
|
|
|
|
2013-04-07 03:20:17 +00:00
|
|
|
config = new Config();
|
|
|
|
config->setDefaults();
|
2013-03-29 02:36:44 +00:00
|
|
|
|
2013-04-06 20:31:44 +00:00
|
|
|
okButton = new UIButton(okButtonPin, okButtonLed);
|
|
|
|
cancelButton = new UIButton(cancelButtonPin, cancelButtonLed);
|
2013-04-06 21:01:46 +00:00
|
|
|
pspJoystick = new UIJoystickPSP(pspXPin, pspYPin);
|
2013-04-06 22:44:34 +00:00
|
|
|
|
2013-04-07 03:20:17 +00:00
|
|
|
lcd = new UILCD(config);
|
2013-04-07 00:42:58 +00:00
|
|
|
lcd->startUI();
|
2013-03-10 18:26:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
2013-04-07 00:42:58 +00:00
|
|
|
joyStickEvent = pspJoystick->direction();
|
|
|
|
if (joyStickEvent != joyNone) {
|
2013-04-07 00:44:27 +00:00
|
|
|
if (DEBUG) {
|
|
|
|
Serial.print("Joystick Event: ");
|
|
|
|
Serial.println(joyStickEvent);
|
|
|
|
}
|
2013-04-07 00:42:58 +00:00
|
|
|
lcd->handleJoystickEvent(joyStickEvent);
|
|
|
|
}
|
2013-04-07 02:24:15 +00:00
|
|
|
|
|
|
|
if (okButton->isPressed()) {
|
|
|
|
lcd->handleOkButtonEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cancelButton->isPressed()) {
|
|
|
|
lcd->handleCancelButtonEvent();
|
|
|
|
}
|
2013-03-10 18:26:41 +00:00
|
|
|
}
|
2013-04-06 22:44:34 +00:00
|
|
|
|