diff --git a/LeonardoProMicro/AutomatedGearShifter/AutomatedGearShifter.ino b/LeonardoProMicro/AutomatedGearShifter/AutomatedGearShifter.ino index 1cf77c7..4a58775 100644 --- a/LeonardoProMicro/AutomatedGearShifter/AutomatedGearShifter.ino +++ b/LeonardoProMicro/AutomatedGearShifter/AutomatedGearShifter.ino @@ -7,7 +7,7 @@ #include #include -#define Version "1.13.17" +#define Version "1.13.19" ////2DO: //pomiar napięcia na baterii // menu do zmiany zakresu predkosci biegów @@ -100,8 +100,8 @@ float voltageDividerRatio = 3.0; int adcBattVoltValue = 0; float inputVoltage = 0.0; float measuredVoltage = 0.0; - - +int voltBarHeight = 0; +int voltBarPosition = 0; void setup() { //SERVO digitalWrite(ServoSwitch, HIGH); @@ -169,7 +169,8 @@ void setup() { totalDist = totalDistReaded; } - +//########################################### LOOP ############################################################ +//########################################### LOOP ############################################################ void loop() { loopTime = millis(); @@ -212,7 +213,7 @@ void loop() { //duzy font //GEAR - display.setCursor(0, 0); + display.setCursor(3, 0); display.println("G:"); display.setCursor(35, 0); display.print(currentGear); @@ -228,8 +229,8 @@ void loop() { } } //SPEED - display.setCursor(0, 40); - display.println("S"); + display.setCursor(3, 40); + display.println("S:"); display.setCursor(35, 40); display.println(speed, 1); //GearBar @@ -251,7 +252,10 @@ void loop() { adcBattVoltValue = analogRead(VoltInptPin); measuredVoltage = (adcBattVoltValue * referenceVoltage) / maxADCValue; inputVoltage = measuredVoltage * voltageDividerRatio; - display.fillRect(0, 63, ((inputVoltage-9)/3.6)*124, 1 , SSD1306_WHITE); + + voltBarHeight = int(((inputVoltage-9)/3.6)*64); + voltBarPosition = 64 - voltBarHeight; + display.fillRect(0, voltBarPosition, 1, voltBarHeight, SSD1306_WHITE); //########################################## ZAPIS DO WYŚWIETLACZA ###################################################### display.display(); loopTime = millis(); @@ -283,7 +287,8 @@ void loop() { loop_cnt = 0; } } - +//########################################### LOOP ############################################################ +//########################################### LOOP ############################################################ void calcSpeed() { lastLastMillisSpd = lastMillisSpd; lastMillisSpd = millissSpd; @@ -430,7 +435,7 @@ void prepareTurnOff() { totalDistWrited = totalDist; loop_cnt = 0; - for (; 500 < (millis() - lastMillisSpd);) { // zmiana z 1000 na 500 w 1.13.X + for (; 1500 < (millis() - lastMillisSpd);) { // zmiana z 1000 na 1500 w 1.13.X digitalWrite(ServoSwitch, LOW); digitalWrite(ServoPin, LOW); //INFO