Hans55
15.02.2008, 21:39
Hallo!
Ich möchte einen Spannungsbalken am LCD darstellen.
Dazu hab ich mir mit dem LCD Designer ein Zeichen generiert, das komplett ausgefüllt ist. 10 Stück dieser Zeichen stelle ich in einer Zeile dar.
Wenn nur eines erscheint, ist die Batterie fast leer, wenn 10 nebeneinander stehen ist sie voll.
Das funktioniert zwar, aber der Balken blinkt manchmal, was ich nicht haben will. Kann das an der Laufzeit liegen? Oder an meiner Abfrageart?
Gibts da eine andere Möglichkeit wie man das machen könnte?
Das Programm ist so:
Balken:
If U1_mes >= 14.1 Then
Gosub Balken_ladung 'Ladung
End If
If U1_mes >= 12.69 And U1_mes <= 14.00 Then
Gosub Balken100
End If
If U1_mes >= 12.64 And U1_mes <= 12.67 Then
Gosub Balken_loeschen
Gosub Balken90
End If
If U1_mes >= 12.58 And U1_mes <= 12.62 Then
Gosub Balken_loeschen
Gosub Balken80
End If
If U1_mes >= 12.46 And U1_mes <= 12.56 Then
Gosub Balken_loeschen
Gosub Balken70
End If
If U1_mes >= 12.38 And U1_mes <= 12.42 Then
Gosub Balken_loeschen
Gosub Balken60
End If
If U1_mes >= 12.34 And U1_mes <= 12.36 Then
Gosub Balken_loeschen
Gosub Balken50
End If
If U1_mes >= 12.28 And U1_mes <= 12.31 Then
Gosub Balken_loeschen
Gosub Balken40
End If
If U1_mes >= 12.23 And U1_mes <= 12.25 Then
Gosub Balken_loeschen
Gosub Balken30
End If
If U1_mes >= 12.17 And U1_mes <= 12.22 Then
Gosub Balken_loeschen
Gosub Balken20 '=> Laden
End If
If U1_mes >= 11.9 And U1_mes <= 12.12 Then
Gosub Balken_loeschen
Gosub Balken10 '=> Laden
End If
If U1_mes >= 10.5 And U1_mes <= 11.6 Then
Gosub Balken_loeschen
Gosub Balken0 '=> sofort laden ausgeben !
End If
If U1_mes < 10.6 Then
Gosub Balken_loeschen
Gosub Balken0 '=> LEER, sofort laden!
End If
Return
'============================================
'Das sind die LCD Anzeigen:
'-------------------------------------------------------------------------------
'/// LCD Balken für Batteriespannung löschen /////////////////
'-------------------------------------------------------------------------------
'Zeigt Striche "----------"
Balken_loeschen:
Deflcdchar 1 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32
Locate 3 , 1
Lcd Chr(1);
Locate 3 , 2
Lcd Chr(1);
Locate 3 , 3
Lcd Chr(1);
Locate 3 , 4
Lcd Chr(1);
Locate 3 , 5
Lcd Chr(1);
Locate 3 , 6
Lcd Chr(1);
Locate 3 , 7
Lcd Chr(1);
Locate 3 , 8
Lcd Chr(1);
Locate 3 , 9
Lcd Chr(1);
Locate 3 , 10
Lcd Chr(1);
Waitms 150
Return
'-------------------------------------------------------------------------------
'/// LCD Balken für Batteriespannung ///////////////////////////////////
'-------------------------------------------------------------------------------
'Das Zeichen mit dem LCD Designer entwerfen dann an der richtigen Stelle auf OK 'drücken => der Code "Deflcdchar ?,..." wird eingefügt.
'Anschließend an Stelle des ? eine Nummer vergeben und die dann mit LCD chr(0)
' anzeigen lagen
'============================================
Balken100:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Locate 3 , 7
Lcd Chr(0);
Locate 3 , 8
Lcd Chr(0);
Locate 3 , 9
Lcd Chr(0);
Locate 3 , 10
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// LCD Balken für Batteriespannung ///////////////////////////////////
'-------------------------------------------------------------------------------
Balken90:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Locate 3 , 7
Lcd Chr(0);
Locate 3 , 8
Lcd Chr(0);
Locate 3 , 9
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 80% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken80:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Locate 3 , 7
Lcd Chr(0);
Locate 3 , 8
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 70% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken70:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Locate 3 , 7
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 60% LCD Balken für Batteriespannung //////////////////////////////
'-------------------------------------------------------------------------------
Balken60:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 50% LCD Balken für Batteriespannung //////////////////////////////
'-------------------------------------------------------------------------------
Balken50:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 40% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken40:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 30% LCD Balken für Batteriespannung //////////////////////////////
'-------------------------------------------------------------------------------
Balken30:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 20% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken20:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 10% LCD Balken für Batteriespannung //////////////////////////////
'-------------------------------------------------------------------------------
Balken10:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 0% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken0:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 1
Lcd " LEER "
Waitms 50
Return
Ich möchte einen Spannungsbalken am LCD darstellen.
Dazu hab ich mir mit dem LCD Designer ein Zeichen generiert, das komplett ausgefüllt ist. 10 Stück dieser Zeichen stelle ich in einer Zeile dar.
Wenn nur eines erscheint, ist die Batterie fast leer, wenn 10 nebeneinander stehen ist sie voll.
Das funktioniert zwar, aber der Balken blinkt manchmal, was ich nicht haben will. Kann das an der Laufzeit liegen? Oder an meiner Abfrageart?
Gibts da eine andere Möglichkeit wie man das machen könnte?
Das Programm ist so:
Balken:
If U1_mes >= 14.1 Then
Gosub Balken_ladung 'Ladung
End If
If U1_mes >= 12.69 And U1_mes <= 14.00 Then
Gosub Balken100
End If
If U1_mes >= 12.64 And U1_mes <= 12.67 Then
Gosub Balken_loeschen
Gosub Balken90
End If
If U1_mes >= 12.58 And U1_mes <= 12.62 Then
Gosub Balken_loeschen
Gosub Balken80
End If
If U1_mes >= 12.46 And U1_mes <= 12.56 Then
Gosub Balken_loeschen
Gosub Balken70
End If
If U1_mes >= 12.38 And U1_mes <= 12.42 Then
Gosub Balken_loeschen
Gosub Balken60
End If
If U1_mes >= 12.34 And U1_mes <= 12.36 Then
Gosub Balken_loeschen
Gosub Balken50
End If
If U1_mes >= 12.28 And U1_mes <= 12.31 Then
Gosub Balken_loeschen
Gosub Balken40
End If
If U1_mes >= 12.23 And U1_mes <= 12.25 Then
Gosub Balken_loeschen
Gosub Balken30
End If
If U1_mes >= 12.17 And U1_mes <= 12.22 Then
Gosub Balken_loeschen
Gosub Balken20 '=> Laden
End If
If U1_mes >= 11.9 And U1_mes <= 12.12 Then
Gosub Balken_loeschen
Gosub Balken10 '=> Laden
End If
If U1_mes >= 10.5 And U1_mes <= 11.6 Then
Gosub Balken_loeschen
Gosub Balken0 '=> sofort laden ausgeben !
End If
If U1_mes < 10.6 Then
Gosub Balken_loeschen
Gosub Balken0 '=> LEER, sofort laden!
End If
Return
'============================================
'Das sind die LCD Anzeigen:
'-------------------------------------------------------------------------------
'/// LCD Balken für Batteriespannung löschen /////////////////
'-------------------------------------------------------------------------------
'Zeigt Striche "----------"
Balken_loeschen:
Deflcdchar 1 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32
Locate 3 , 1
Lcd Chr(1);
Locate 3 , 2
Lcd Chr(1);
Locate 3 , 3
Lcd Chr(1);
Locate 3 , 4
Lcd Chr(1);
Locate 3 , 5
Lcd Chr(1);
Locate 3 , 6
Lcd Chr(1);
Locate 3 , 7
Lcd Chr(1);
Locate 3 , 8
Lcd Chr(1);
Locate 3 , 9
Lcd Chr(1);
Locate 3 , 10
Lcd Chr(1);
Waitms 150
Return
'-------------------------------------------------------------------------------
'/// LCD Balken für Batteriespannung ///////////////////////////////////
'-------------------------------------------------------------------------------
'Das Zeichen mit dem LCD Designer entwerfen dann an der richtigen Stelle auf OK 'drücken => der Code "Deflcdchar ?,..." wird eingefügt.
'Anschließend an Stelle des ? eine Nummer vergeben und die dann mit LCD chr(0)
' anzeigen lagen
'============================================
Balken100:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Locate 3 , 7
Lcd Chr(0);
Locate 3 , 8
Lcd Chr(0);
Locate 3 , 9
Lcd Chr(0);
Locate 3 , 10
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// LCD Balken für Batteriespannung ///////////////////////////////////
'-------------------------------------------------------------------------------
Balken90:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Locate 3 , 7
Lcd Chr(0);
Locate 3 , 8
Lcd Chr(0);
Locate 3 , 9
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 80% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken80:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Locate 3 , 7
Lcd Chr(0);
Locate 3 , 8
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 70% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken70:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Locate 3 , 7
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 60% LCD Balken für Batteriespannung //////////////////////////////
'-------------------------------------------------------------------------------
Balken60:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Locate 3 , 6
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 50% LCD Balken für Batteriespannung //////////////////////////////
'-------------------------------------------------------------------------------
Balken50:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Locate 3 , 5
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 40% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken40:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Locate 3 , 4
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 30% LCD Balken für Batteriespannung //////////////////////////////
'-------------------------------------------------------------------------------
Balken30:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Locate 3 , 3
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 20% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken20:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 2
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 10% LCD Balken für Batteriespannung //////////////////////////////
'-------------------------------------------------------------------------------
Balken10:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Waitms 50
Return
'-------------------------------------------------------------------------------
'/// 0% LCD Balken für Batteriespannung /////////////////////////////
'-------------------------------------------------------------------------------
Balken0:
Deflcdchar 0 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31
Locate 3 , 1
Lcd Chr(0);
Locate 3 , 1
Lcd " LEER "
Waitms 50
Return