// Library Inclusion
#include <TM1637.h>
#include <Stepper.h>
//Pin Layout
const int CLK = 2;
const int DIO = 3;
const int homeButton = 4;
const int upButton = 5;
const int downButton = 6;
const int goButton = 7;
const int programSwitch = 12;
//Stepper Setup
const int stepsPerRev = 2048;
Stepper myStepper(stepsPerRev, 8, 9, 10, 11);
int stepCount = 0; //Stepper Pos tracker
const int stepHome = 0; //Stepper home position
int stepPosition = 1; //Positions to jump prior to home
//Angle and Count Settings
const int rows = 2;
int columns = 0;
int **posArray = nullptr;
//Testing
int positivePress = 0;
TM1637 tm(CLK, DIO);
//Flash rate and timing
unsigned long prevMillis = 0;
const int interval = 1000;
unsigned int counter = 0;
void setup() {
//Display settings
tm.init();
tm.set(BRIGHT_TYPICAL);
//Pin Allocation
pinMode(upButton, INPUT_PULLUP);
pinMode(downButton, INPUT_PULLUP);
pinMode(goButton, INPUT_PULLUP);
pinMode(programSwitch, INPUT_PULLUP);
//Timer
}
void loop() {
boolean devState = digitalRead(programSwitch);
if (devState == HIGH) {
setMode();
} else {
runMode();
}
}
void setMode() { //If switch is on then go into set mode of angle and position
tm.displayStr((char *)"P");
}
void runMode() {
unsigned long currentMillis = millis();
boolean devState = digitalRead(programSwitch);
while (devState == LOW) {
if (currentMillis - prevMillis >= interval) {
tm.displayStr((char *)"P1");
}
else {
tm.clearDisplay();
}
if (devState == HIGH) {
break;
}
}
}
void angleSet() {
}
void rotationCount() {
}
void rotatePart() {
}
void timer() {
while (true) {
tm.display(0, (counter / 1000) % 10);
tm.display(1, (counter / 100) % 10);
tm.display(2, (counter / 10) % 10);
tm.display(3, counter % 10);
counter++;
if (counter == 10000) {
counter = 0;
}
delay(100);
}
}