Skip to content

Commit 12aee5a

Browse files
committed
fixed button press bug during saving process
1 parent 0b51046 commit 12aee5a

1 file changed

Lines changed: 37 additions & 24 deletions

File tree

ProbeCam_Arduino.ino

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,30 @@ void setup() {
9898
}
9999

100100
void loop() {
101-
if (digitalRead(LEFT) == LOW && !sleeping) {
102-
secondsElapsed = 0;
103-
if (currentQuestion != 0) moveUp();
104-
}
105-
if (digitalRead(RIGHT) == LOW && !sleeping) {
106-
secondsElapsed = 0;
107-
if (currentQuestion != numOfQuestions - 1) moveDown();
108-
}
109-
if (digitalRead(SHUTTER) == LOW) {
110-
if (!sleeping) {
101+
if (!saving && !sleeping) {
102+
if (digitalRead(LEFT) == LOW && !sleeping) {
111103
secondsElapsed = 0;
112-
takePicture();
104+
if (currentQuestion != 0) moveUp();
113105
}
114-
}
115-
if (digitalRead(SLEEP) == LOW) {
116-
if (sleeping) {
117-
sleeping = false;
118-
delay(500);
106+
if (digitalRead(RIGHT) == LOW && !sleeping) {
107+
secondsElapsed = 0;
108+
if (currentQuestion != numOfQuestions - 1) moveDown();
119109
}
120-
else {
121-
if (!saving) {
122-
sleep();
110+
if (digitalRead(SHUTTER) == LOW) {
111+
if (!sleeping) {
112+
secondsElapsed = 0;
113+
takePicture();
114+
}
115+
}
116+
if (digitalRead(SLEEP) == LOW) {
117+
if (sleeping) {
118+
sleeping = false;
119+
delay(500);
120+
}
121+
else {
122+
if (!saving) {
123+
sleep();
124+
}
123125
}
124126
}
125127
}
@@ -160,15 +162,26 @@ void savingScreen(int percent) {
160162
if (savingAnimationCounter > 6) savingAnimationCounter = 0;
161163
// Draw diagonal lines.
162164
for (int i = -32; i < 26; i++) display.drawLine(i * 7 + 32 + savingAnimationCounter, 0, i * 7 + savingAnimationCounter, 32, WHITE);
163-
165+
164166
display.setTextSize(2);
165167
display.setTextColor(WHITE);
166-
display.setCursor(16, 16);
167168
display.setTextWrap(false);
168-
display.print(percent);
169-
display.print("%");
169+
if (percent < 15) {
170+
display.setCursor(28, 10);
171+
display.print("Saving");
172+
}
173+
else if (percent == 100) {
174+
display.setCursor(42, 10);
175+
display.print(percent);
176+
display.print("%");
177+
}
178+
else {
179+
display.setCursor(50, 10);
180+
display.print(percent);
181+
display.print("%");
182+
}
170183
display.display();
171-
184+
172185
savingAnimationCounter++;
173186
//Serial.println(savingAnimationCounter);
174187
prevMillis = currentMillis;

0 commit comments

Comments
 (0)