Restarted UI refactor; Push button class compiles.
This commit is contained in:
parent
82b20bcd03
commit
4bb75e25fc
|
@ -8,6 +8,9 @@
|
|||
attribute.
|
||||
*/
|
||||
|
||||
#ifndef Project_h
|
||||
#define Project_h
|
||||
|
||||
// Pinout / things that need configuration
|
||||
#define okButtonPin 23
|
||||
#define okButtonLed 22
|
||||
|
@ -65,3 +68,4 @@ extern serialmode currentMode;
|
|||
extern serialmode selectedMode;
|
||||
extern linespeed currentLineSpeed;
|
||||
|
||||
#endif
|
||||
|
|
10
Universal_Serial_Adapter/UI.cpp
Normal file
10
Universal_Serial_Adapter/UI.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
Serial Adapter Project: Dynamic serial TTY passthroughs
|
||||
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.
|
||||
*/
|
||||
|
10
Universal_Serial_Adapter/UI.h
Normal file
10
Universal_Serial_Adapter/UI.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
Serial Adapter Project: Dynamic serial TTY passthroughs
|
||||
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.
|
||||
*/
|
||||
|
36
Universal_Serial_Adapter/UIButton.cpp
Normal file
36
Universal_Serial_Adapter/UIButton.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Serial Adapter Project: Dynamic serial TTY passthroughs
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "UIButton.h"
|
||||
|
||||
UIButton::UIButton(int buttonPin, int ledPin) {
|
||||
this->buttonPin = buttonPin;
|
||||
this->ledPin = ledPin;
|
||||
}
|
||||
|
||||
void UIButton::setup() {
|
||||
pinMode(buttonPin, INPUT);
|
||||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
turnOnLed();
|
||||
}
|
||||
|
||||
void UIButton::turnOnLed() {
|
||||
digitalWrite(ledPin, HIGH);
|
||||
}
|
||||
|
||||
void UIButton::turnOffLed() {
|
||||
digitalWrite(ledPin, LOW);
|
||||
}
|
||||
|
||||
bool UIButton::isPressed() {
|
||||
return digitalRead(buttonPin);
|
||||
}
|
27
Universal_Serial_Adapter/UIButton.h
Normal file
27
Universal_Serial_Adapter/UIButton.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Serial Adapter Project: Dynamic serial TTY passthroughs
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef UIButton_h
|
||||
#define UIButton_h
|
||||
|
||||
class UIButton {
|
||||
private:
|
||||
int buttonPin;
|
||||
int ledPin;
|
||||
|
||||
public:
|
||||
UIButton(int buttonPin, int ledPin);
|
||||
void setup();
|
||||
void turnOnLed();
|
||||
void turnOffLed();
|
||||
bool isPressed();
|
||||
};
|
||||
|
||||
#endif
|
10
Universal_Serial_Adapter/UIJoystickPSP.cpp
Normal file
10
Universal_Serial_Adapter/UIJoystickPSP.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
Serial Adapter Project: Dynamic serial TTY passthroughs
|
||||
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.
|
||||
*/
|
||||
|
10
Universal_Serial_Adapter/UIJoystickPSP.h
Normal file
10
Universal_Serial_Adapter/UIJoystickPSP.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
Serial Adapter Project: Dynamic serial TTY passthroughs
|
||||
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.
|
||||
*/
|
||||
|
10
Universal_Serial_Adapter/UILCD.cpp
Normal file
10
Universal_Serial_Adapter/UILCD.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
Serial Adapter Project: Dynamic serial TTY passthroughs
|
||||
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.
|
||||
*/
|
||||
|
10
Universal_Serial_Adapter/UILCD.h
Normal file
10
Universal_Serial_Adapter/UILCD.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
Serial Adapter Project: Dynamic serial TTY passthroughs
|
||||
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.
|
||||
*/
|
||||
|
|
@ -9,12 +9,11 @@
|
|||
*/
|
||||
|
||||
#include "Project.h"
|
||||
#include "UIButton.h"
|
||||
|
||||
// Button state tracking
|
||||
int okButtonState = 0;
|
||||
int prevOkButtonState = okButtonState;
|
||||
int cancelButtonState = 0;
|
||||
int prevCancelButtonState = prevCancelButtonState;
|
||||
// Button's controlling UI
|
||||
UIButton* okButton = new UIButton(22, 23);
|
||||
UIButton* cancelButton = new UIButton(24, 25);
|
||||
|
||||
// PSP joystick tracking
|
||||
long pspUpCount = 0; // Used to slow down how fast we repeat up movement
|
||||
|
@ -36,15 +35,6 @@ void setDefaults() {
|
|||
}
|
||||
|
||||
void setup() {
|
||||
// Buttons
|
||||
pinMode(okButtonPin, INPUT);
|
||||
pinMode(cancelButtonPin, INPUT);
|
||||
|
||||
// Button LEDs
|
||||
pinMode(okButtonLed, OUTPUT);
|
||||
digitalWrite(okButtonLed, HIGH);
|
||||
pinMode(cancelButtonLed, OUTPUT);
|
||||
digitalWrite(cancelButtonLed, HIGH);
|
||||
|
||||
// Setup defaults
|
||||
setDefaults();
|
||||
|
@ -92,7 +82,7 @@ void loop() {
|
|||
|
||||
|
||||
// Select / Enter
|
||||
if (digitalRead(okButtonPin)) {
|
||||
if (okButton->isPressed()) {
|
||||
//FIXME: Re-enable once new LCD is online
|
||||
//setMode(selectedMode);
|
||||
}
|
||||
|
|
Reference in a new issue