10000 Fixed AutoBroghtnessSwitchOff · astrosander/arduino-speedometer@a323549 · GitHub
[go: up one dir, main page]

Skip to content

Commit a323549

Browse files
committed
Fixed AutoBroghtnessSwitchOff
1 parent dba0c6c commit a323549

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

firmware/Speedometr/Speedometr.ino

+13-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ byte mode = 0;
1919
unsigned long num, numC, TimeDur, lastturn;
2020
const float len = 2.125;
2121
float vel, MaxSpeed, MaxAcceleration;
22-
bool SpeedFormat = true;
22+
bool SpeedFormat = false;
2323

2424
struct Data {
2525
unsigned long num = 0;
@@ -58,7 +58,8 @@ void loop()
5858

5959
int val = abs(mean-analogRead(A0));
6060

61-
if(val > 2){
61+
if(val > 4){
62+
Serial.println(val);
6263
lcd.setBacklight(HIGH);
6364
int delta = millis() - lastturn;
6465
lastturn = millis();
@@ -68,7 +69,9 @@ void loop()
6869

6970
float PrevVel = vel;
7071
vel = len / (delta) * 1000;
71-
//
72+
73+
if(PrevVel < 0.3 && vel > 4) {vel = 0; return;}
74+
7275
Serial.print(vel);
7376
Serial.print(" ");
7477
Serial.println(delta);
@@ -83,14 +86,20 @@ void loop()
8386
}
8487
else
8588
{
86-
if(millis() - lastturn > 4000) {vel = 0;lcd.setBacklight(LOW);}
89+
if(millis() - lastturn > 4000) {
90+
if(millis() - lastturn > 15000) lcd.setBacklight(LOW);
91+
else lcd.setBacklight(HIGH);
92+
vel = 0;
93+
}
8794
f=0;
8895
}
8996

9097
if(enc.clicks == 2) mode = 0;
9198
if(enc.clicks == 5) MaxSpeed=0;
9299
if(enc.clicks == 10) {BackReset();resetFunc();}
93100
if (enc.click()) {
101+
lastturn = millis();
102+
lcd.setBacklight(HIGH);
94103
lcd.clear();
95104
mode = (mode + 1) % NumMode;
96105
// if(mode == 4){lcd.setCursor(0,0); lcd.print("secondly Plot"); delay(500);}

0 commit comments

Comments
 (0)
0