[chronojump/FS-LCD-Menu: 9/17] Creation of the menus
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/FS-LCD-Menu: 9/17] Creation of the menus
- Date: Wed, 1 Dec 2021 15:28:19 +0000 (UTC)
commit d0a78c67b8fb411742c8435d005824af1051ebf2
Author: Xavier Padullés <x padulles gmail com>
Date: Fri Nov 26 09:40:12 2021 +0100
Creation of the menus
arduino/ForceSensorLCD/ForceSensorLCD.ino | 200 +++++++++++++++++++++++++-----
1 file changed, 171 insertions(+), 29 deletions(-)
---
diff --git a/arduino/ForceSensorLCD/ForceSensorLCD.ino b/arduino/ForceSensorLCD/ForceSensorLCD.ino
index 0bb88b12d..2ac00c4e1 100644
--- a/arduino/ForceSensorLCD/ForceSensorLCD.ino
+++ b/arduino/ForceSensorLCD/ForceSensorLCD.ino
@@ -115,6 +115,17 @@ unsigned long triggerTime = 0;
bool rcaState = digitalRead(rcaPin);
bool lastRcaState = rcaState;
+unsigned short menu = 0;
+unsigned short submenu = 0;
+
+const String menuList [] = {
+ "Record",
+ "Tare + Record",
+ "Tare",
+ "Calibrate",
+ "System"
+};
+
void setup() {
pinMode(redButtonPin, INPUT);
pinMode(blueButtonPin, INPUT);
@@ -154,38 +165,173 @@ void setup() {
} else {
scale.set_scale(calibration_factor);
}
+
+ lcd.clear();
+ lcd.setCursor(2, 0);
+ lcd.print(menuList[menu]);
+ lcd.setCursor(2, 1);
+ lcd.print("Red to start");
}
void loop()
{
blueButtonState = digitalRead(blueButtonPin);
- if (blueButtonState == 1) {
+ redButtonState = digitalRead(redButtonPin);
+ if (blueButtonState) {
+ menu++;
+ menu = menu % 5;
lcd.clear();
+ lcd.setCursor(1, 0);
+ lcd.print(menu);
lcd.setCursor(3, 0);
- lcd.print("Taring...");
- tare();
- lcd.setCursor(3, 0);
- lcd.print("Taring OK");
- delay(1000);
- lcd.setCursor(2, 0);
- lcd.print("CHRONOJUMP");
+ lcd.print(menuList[menu]);
lcd.setCursor(2, 1);
- lcd.print("Boscosystem");
- // lcd.setCursor(2,1);
- // lcd.print("Press Start");
-
+ if (menu == 0)
+ {
+ lcd.print("Red: start");
+ } else if (menu == 1)
+ {
+ lcd.print("Red: tare+start");
+ } else if (menu == 2)
+ {
+ lcd.print("Red: tare");
+ } else if (menu == 3)
+ {
+ lcd.print("Red: calibrate");
+ } else if (menu == 4)
+ {
+ lcd.print("Red: system info");
+ }
}
- redButtonState = digitalRead(redButtonPin); //Red button
+ delay(200);
- if(sendSyncTime) {
- Serial.print("sync:");
- Serial.println(syncTime);
- sendSyncTime = false;
+ if (redButtonState)
+ {
+ lcd.clear();
+ lcd.setCursor(1, 0);
+ lcd.print(menu);
+ lcd.setCursor(3, 0);
+ lcd.print(menuList[menu]);
+ lcd.setCursor(2, 1);
+
+ if (menu == 0)
+ {
+ lcd.print("Capturing");
+ start_capture();
+ capture();
+ } else if (menu == 1)
+ {
+ lcd.print("tarin+starting");
+ } else if (menu == 2)
+ {
+ lcd.print("taring");
+ } else if (menu == 3)
+ {
+ lcd.print("calibrating");
+ } else if (menu == 4)
+ {
+ lcd.print("system info");
+ }
}
+}
+//void loop()
+//{
+// blueButtonState = digitalRead(blueButtonPin);
+// if (blueButtonState == 1) {
+// lcd.clear();
+// lcd.setCursor(3, 0);
+// lcd.print("Taring...");
+// tare();
+// lcd.setCursor(3, 0);
+// lcd.print("Taring OK");
+// delay(1000);
+// lcd.setCursor(2, 0);
+// lcd.print("CHRONOJUMP");
+// lcd.setCursor(2, 1);
+// lcd.print("Boscosystem");
+// // lcd.setCursor(2,1);
+// // lcd.print("Press Start");
+//
+// }
+// redButtonState = digitalRead(redButtonPin); //Red button
+//
+// if(sendSyncTime) {
+// Serial.print("sync:");
+// Serial.println(syncTime);
+// sendSyncTime = false;
+// }
+//
+// if (capturing)
+// {
+//
+// //Checking the RCA state
+// if (rcaState != lastRcaState) { //Event generated by the RCA
+// checkTimeOverflow();
+// Serial.print(totalTime);
+// Serial.print(";");
+//
+// if (rcaState) {
+// Serial.println("R");
+// } else {
+// Serial.println("r");
+// }
+// lastRcaState = rcaState;
+//
+// } else { //If no RCA event, read the force as usual
+//
+// currentTime = micros();
+// checkTimeOverflow();
+// float measured = scale.get_units();
+//
+// //RFD stuff start ------>
+// if (rfdDataPre2Ok) {
+// float rfdValue = (measured - rfdMeasuredPre2) / ((elapsedTime + rfdTimePre) / 1000000.0);
+// rfdCalculed = true;
+// if (rfdValue > rfdValueMax) {
+// rfdValueMax = rfdValue;
+// }
+// }
+//
+// if (rfdDataPreOk) {
+// rfdTimePre2 = rfdTimePre;
+// rfdMeasuredPre2 = rfdMeasuredPre;
+// rfdDataPre2Ok = true;
+// }
+//
+// rfdTimePre = elapsedTime;
+// rfdMeasuredPre = measured;
+// rfdDataPreOk = true;
+// //<------- RFD stuff end
+//
+// if (abs(measured) > abs(measuredLcdDelayMax)) {
+// measuredLcdDelayMax = measured;
+// }
+// if (abs(measured) > abs(measuredMax)) {
+// measuredMax = measured;
+// }
+//
+// Serial.print(totalTime); Serial.print(";");
+// Serial.println(measured, 2); //scale.get_units() returns a float
+//
+// printOnLcd();
+//// if (rcaState) {
+//// end_capture();
+//// }
+// }
+// if (redButtonState) {
+// end_capture();
+// }
+// } else if (!capturing) {
+// if (redButtonState) {
+// start_capture();
+// }
+// }
+//}
+void capture(void)
+{
if (capturing)
{
-
//Checking the RCA state
if (rcaState != lastRcaState) { //Event generated by the RCA
checkTimeOverflow();
@@ -236,17 +382,13 @@ void loop()
Serial.println(measured, 2); //scale.get_units() returns a float
printOnLcd();
-// if (rcaState) {
-// end_capture();
-// }
+ // if (rcaState) {
+ // end_capture();
+ // }
}
if (redButtonState) {
end_capture();
}
- } else if (!capturing) {
- if (redButtonState) {
- start_capture();
- }
}
}
@@ -292,7 +434,7 @@ void printOnLcd() {
lcd.setCursor(0, 0);
lcd.write(byte (0));
showRecordChar = false;
- } else if (!showRecordChar) {
+ } else if (!showRecordChar) {
lcd.setCursor(0, 0);
lcd.print(" ");
showRecordChar = true;
@@ -436,7 +578,7 @@ void end_capture()
capturing = false;
Serial.print("Capture ended:");
Serial.println(scale.get_offset());
- lcd.setCursor(0,0);
+ lcd.setCursor(0, 0);
lcd.write(" ");
delay(500);
}
@@ -551,7 +693,7 @@ void sendSyncSignal() {
pinMode(rcaPin, OUTPUT);
syncTime = micros();
-
+
digitalWrite(rcaPin, HIGH);
delay(200);
digitalWrite(rcaPin, LOW);
@@ -569,7 +711,7 @@ void listenSyncSignal() {
void getSyncTime() {
syncTime = micros();
- sendSyncTime = true;
+ sendSyncTime = true;
//detachInterrupt(digitalPinToInterrupt(rcaPin));
attachInterrupt(digitalPinToInterrupt(rcaPin), changingRCA, FALLING);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]