-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ColoradoStateFSAE/jonathan-work
Added flat shift
- Loading branch information
Showing
19 changed files
with
363 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.pio | ||
.vscode |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[env:teensy41] | ||
platform = teensy | ||
board = teensy41 | ||
framework = arduino | ||
lib_deps = | ||
luni64/TeensyTimerTool@^1.4.1 | ||
adafruit/Adafruit SSD1306@^2.5.7 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "Controls.h" | ||
|
||
Controls::Controls(int pin) { | ||
buttonPin = pin; | ||
pinMode(buttonPin, INPUT_PULLUP); | ||
} | ||
|
||
// button_pressed takes a button and returns true if it was pressed | ||
void Controls::update() { | ||
bool pressed = false; | ||
bool released = false; | ||
|
||
int state = digitalRead(buttonPin); | ||
|
||
if (state != lastButtonState) { | ||
lastDebounceTime = millis(); | ||
} | ||
|
||
if ((millis() - lastDebounceTime) >= DEBOUNCE_TIME) { | ||
if (state != buttonState) { | ||
buttonState = state; | ||
if (buttonState == LOW) { | ||
pressed = true; | ||
} | ||
} | ||
} | ||
|
||
lastButtonState = state; | ||
|
||
buttonPressed = pressed; | ||
buttonReleased = released; | ||
} | ||
|
||
bool Controls::pressed() { | ||
return buttonPressed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef CONTROLS_H | ||
#define CONTROLS_H | ||
|
||
#include <Arduino.h> | ||
#include "Transmission.h" | ||
|
||
enum { | ||
NEUTRAL = -1, | ||
UP = 0, | ||
DOWN = 1 | ||
}; | ||
|
||
class Controls { | ||
public: | ||
Controls() = delete; | ||
Controls(int pin); | ||
void update(); | ||
bool pressed(); | ||
|
||
private: | ||
const unsigned int DEBOUNCE_TIME = 5; // Debounce delay in milliseconds | ||
|
||
int buttonPin; | ||
int buttonState = HIGH; | ||
int lastButtonState = HIGH; | ||
unsigned long lastDebounceTime = 0; | ||
|
||
bool buttonPressed = false; | ||
bool buttonReleased = false; | ||
bool buttonHeld = false; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.