Skip to content

Commit bfea4db

Browse files
authored
Add files via upload
1 parent d3b05fc commit bfea4db

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

src/Force.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ void Force::run() {
4444
// TaskFunctions
4545
/////////////////////////////////////////////////////////////////////////
4646
void Force::Dispense() {
47+
dispensing = true;
4748
trial++;
48-
// Tone();
49+
Tone();
4950
float successTime = millis();
5051
while ((millis() - successTime) < (dispense_delay * 1000)){
5152
tft.setCursor(85, 44);
5253
tft.setTextColor(ST7735_WHITE);
5354
tft.print("Delay:");
5455
tft.setTextColor(ST7735_WHITE);
5556
tft.print((-(millis() - successTime - (dispense_delay*1000))/ 1000),1);
56-
tft.print("s");
5757
run();
5858
tft.fillRect(84, 43, 80, 12, ST7735_BLACK); // remove Delay text when timeout is over
5959
if (grams > 1 or grams2 >1){ //only clear F1 ans F2 values if levers are being pushed
@@ -71,7 +71,7 @@ void Force::Dispense() {
7171
digitalWrite(13, LOW); // RED LED
7272
pressTime = millis();
7373
pressLength = 0;
74-
Timeout(timeout_length);
74+
dispensing = false;
7575
}
7676

7777
void Force::Timeout(int timeout_length) {
@@ -81,9 +81,8 @@ void Force::Timeout(int timeout_length) {
8181
tft.setTextColor(ST7735_WHITE);
8282
tft.print("Timeout:");
8383
tft.print((-(millis() - dispense_time - (timeout_length*1000))/ 1000),1);
84-
tft.print("s");
8584
run();
86-
tft.fillRect(84, 43, 80, 12, ST7735_BLACK);
85+
tft.fillRect(84, 43, 80, 12, ST7735_BLACK);
8786
if ((grams > 1.5) or (grams2 > 1.5)) { //reset timeout if either lever pushed
8887
Timeout(timeout_length);
8988
tft.fillRect(12, 0, 38, 24, ST7735_BLACK); // clear the text after F1 F2 labels
@@ -479,7 +478,13 @@ void Force::graphLegend() {
479478
DateTime now = rtc.now();
480479
lickTime = now.unixtime();
481480
}
482-
digitalWrite(A3, LOW);
481+
482+
if (lick == false) {
483+
484+
digitalWrite(A3, LOW);
485+
486+
}
487+
483488
if (calibrated == false){
484489
tft.setCursor(85, 56);
485490
tft.print ("Uncalibrated");
@@ -511,7 +516,7 @@ void Force::CreateDataFile() {
511516

512517
// Write data header to file of uSD.
513518
void Force::writeHeader() {
514-
logfile.println("MM:DD:YYYY hh:mm:ss, Seconds, Device_Number, ProgressiveRatio, Grams_req, Hold_time, Ratio, Dispense_amount, Dispense_delay, Timeout, Trials_per_block, Max_force, Trial, Lever1_Grams, Lever2_Grams, Licks");
519+
logfile.println("MM:DD:YYYY hh:mm:ss, Seconds, Device_Number, ProgressiveRatio, Grams_req, Hold_time, Ratio, Dispense_amount, Dispense_delay, Timeout, Trials_per_block, Max_force, Trial, Press, Lever1_Grams, Lever2_Grams, Licks, Dispense, Random_Num, Shock_trial");
515520
}
516521

517522
// Print data and time followed by pellet count and motorturns to SD card
@@ -571,13 +576,25 @@ void Force::WriteToSD() {
571576
logfile.print(trial);
572577
logfile.print(",");
573578

579+
logfile.print(presses);
580+
logfile.print(",");
581+
574582
logfile.print(grams);
575583
logfile.print(",");
576584

577585
logfile.print(grams2);
578586
logfile.print(",");
579587

580-
logfile.println(lick);
588+
logfile.print(lick);
589+
logfile.print(",");
590+
591+
logfile.print(dispensing);
592+
logfile.print(",");
593+
594+
logfile.print(random_number);
595+
logfile.print(",");
596+
597+
logfile.println(shock);
581598

582599
logfile.flush();
583600

@@ -670,7 +687,7 @@ void Force::Sense() {
670687
pixels.setPixelColor(0, pixels.Color(0, outputValue / 100, outputValue2 / 100));
671688
pixels.show();
672689

673-
lick = digitalRead(18) == LOW;
690+
lick = digitalRead(18) == HIGH;
674691
Tare();
675692
check_buttons();
676693
}

0 commit comments

Comments
 (0)