Skip to content

Commit

Permalink
Updated include files for Arduino 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Siegle committed Jun 15, 2012
1 parent 87ba724 commit d0cdce2
Show file tree
Hide file tree
Showing 5 changed files with 420 additions and 0 deletions.
123 changes: 123 additions & 0 deletions LCD.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Tetrode Twister Control Software
// Copyright (C) 2011 Josh Siegle
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

// Functions for writing to the LCD screen

void startupScreen(int a, int b) {

lcd.print(" Tetrode Twister ");

lcd.setCursor(0,1);

lcd.print("for Arduino v");
lcd.print(a);
lcd.print(".");
lcd.print(b);

delay(3000);

}

void showTurns() {

if (inputs.isUpdated || twister.isUpdated) {

lcd.clear();
lcd.print("FWD REV COUNT");
lcd.setCursor(0,1);

printTurns(inputs.fwdTurns);
printTurns(inputs.revTurns);
lcd.print(" ");
printTurns(twister.totalTurns);

inputs.isUpdated = false;
twister.isUpdated = false;
}
}

void allDone() {

lcd.clear();
lcd.print(" Fire up that ");
lcd.setCursor(0,1);
lcd.print(" heat gun! ");

}

void printTurns(int nTurns) {

if (nTurns < 100 && nTurns >= -9) {
lcd.print(" ");
}
if (nTurns < 10 && nTurns >= 0) {
lcd.print(" ");
}
lcd.print(nTurns);
lcd.print(" ");

}

void resumeDialog() { // allow user to cancel restart

boolean resume = true;

int remainingSeconds = 5;

lcd.clear();
lcd.print("Twisting error");
lcd.setCursor(0,1);
lcd.print("CONTINUE in ");
lcd.print(remainingSeconds);

unsigned long theTime = millis();

while (remainingSeconds > 0) {
while (millis() - theTime < 1000) {
inputs.check(twister.isTurning, verPCB);
if (inputs.buttonState == LOW) {
remainingSeconds = 0;
resume = false;
EEPROM.write(0,0);
EEPROM.write(1,0);
delay(500);
break;
}
}
lcd.setCursor(12,1);
remainingSeconds--;
lcd.print(remainingSeconds);
theTime = millis();
}

if (resume) {
twister.totalTurns = remainingTurns;
twister.isTurning = true;
twister.isUpdated = true;

switch (turnDirection) {
case 0:
twister.isTurningFWD = true;
break;
case 1:
twister.isTurningFWD = false;
break;
}
}

}


47 changes: 47 additions & 0 deletions debugCommands.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Tetrode Twister Control Software
// Copyright (C) 2011 Josh Siegle
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.


void printPhotocellInfo() {

for (int p = 0; p < 2; p++) {

Serial.print("Photocell ");
Serial.print(p);
Serial.print(" ");
Serial.print(photocells.values[p]);
Serial.print(" ");
Serial.println(photocells.thresh[p]);

}

}

void printVariables() {

Serial.print(twister.totalTurns);
Serial.print(" ");
Serial.print(inputs.fwdTurns);
Serial.print(" ");
Serial.print(inputs.revTurns);
Serial.print(" ");
Serial.print(inputs.buttonState);
Serial.print(" ");
Serial.print(photocells.counter);
Serial.print(" ");

}

28 changes: 28 additions & 0 deletions memory.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Tetrode Twister Control Software
// Copyright (C) 2011 Josh Siegle
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.


void updateEEPROM() {

if (twister.totalTurns != remainingTurns) {
EEPROM.write(0,twister.totalTurns);
}

if (twister.isTurningFWD != !turnDirection) {
EEPROM.write(1,!twister.isTurningFWD);
}

}
73 changes: 73 additions & 0 deletions servo.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Tetrode Twister Control Software
// Copyright (C) 2011 Josh Siegle
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

void updateServo() {

// settings for rotation speed
const int fwdspeed = 1000;
const int stopped = 1500;
const int revspeed = 2000;

// set rotation status
if (!twister.isTurning) {
myservo.writeMicroseconds(stopped);
}
else {
if (twister.isTurningFWD) {
myservo.writeMicroseconds(fwdspeed);
}
else {
myservo.writeMicroseconds(revspeed);
}
}

// check for threshold crossings
if (twister.totalTurns >= inputs.fwdTurns && twister.isTurningFWD) {
myservo.writeMicroseconds(stopped);

buzzer.high();
delay(500);

twister.isTurningFWD = false;

// This is where it's fucking up!
} else if (twister.totalTurns <= inputs.fwdTurns - inputs.revTurns && twister.isTurning && !twister.isTurningFWD) {

myservo.writeMicroseconds(stopped);

buzzer.low();

twister.isTurning = false;
twister.isTurningFWD = true;

twister.totalTurns = 0;

delay(1000);

allDone();

delay(5000);

inputs.isUpdated = true;

updateEEPROM();

}

}



Loading

0 comments on commit d0cdce2

Please sign in to comment.