Skip to content

Commit

Permalink
Merge pull request #2 from ColoradoStateFSAE/jonathan-work
Browse files Browse the repository at this point in the history
Added flat shift
  • Loading branch information
SpecialMatrix authored Oct 19, 2023
2 parents c24c06b + ea03af7 commit 758ddfb
Show file tree
Hide file tree
Showing 19 changed files with 363 additions and 340 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.pio
.vscode
36 changes: 0 additions & 36 deletions controls.cpp

This file was deleted.

30 changes: 0 additions & 30 deletions controls.h

This file was deleted.

8 changes: 0 additions & 8 deletions engine.cpp

This file was deleted.

13 changes: 0 additions & 13 deletions engine.h

This file was deleted.

9 changes: 0 additions & 9 deletions neopixel.h

This file was deleted.

52 changes: 0 additions & 52 deletions neopixels.cpp

This file was deleted.

27 changes: 0 additions & 27 deletions neopixels.h

This file was deleted.

17 changes: 17 additions & 0 deletions platformio.ini
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
55 changes: 0 additions & 55 deletions shifting_system.ino

This file was deleted.

36 changes: 36 additions & 0 deletions src/Controls.cpp
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;
}
33 changes: 33 additions & 0 deletions src/Controls.h
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
Loading

0 comments on commit 758ddfb

Please sign in to comment.