W miarę możliwości umieszczę tu też inne bargrafy.
Te dwa poniżej to gotowe funkcje. Wywołuje się je z wartością "Procent" czyli od 0 do 100 i same rysują.
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $regfile = "m32def.dat"
- $crystal = 8000000
- $hwstack = 80
- $swstack = 128
- $framesize = 128
- $sim
- Config Submode = New
- Config Lcd = 20x4
- Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2
- Cursor Off
- Cls
- Sub Set_small_batt
- Deflcdchar 0 , 31 , 32 , 32 , 32 , 32 , 32 , 32 , 31 ' 0
- Deflcdchar 1 , 31 , 32 , 16 , 16 , 16 , 16 , 32 , 31 ' 1
- Deflcdchar 2 , 31 , 32 , 24 , 24 , 24 , 24 , 32 , 31 ' 2
- Deflcdchar 3 , 31 , 32 , 28 , 28 , 28 , 28 , 32 , 31 ' 3
- Deflcdchar 4 , 31 , 32 , 30 , 30 , 30 , 30 , 32 , 31 ' 4
- Deflcdchar 5 , 31 , 32 , 31 , 31 , 31 , 31 , 32 , 31 ' 5
- Deflcdchar 6 , 3 , 2 , 2 , 2 , 2 , 2 , 2 , 3 ' minus
- Deflcdchar 7 , 24 , 8 , 12 , 12 , 12 , 12 , 8 , 24 ' plus
- End Sub
- Sub Draw_batt(byval Procent As Byte)
- Local N As Byte
- Locate 1 , 13
- If Procent < 100 Then Lcd Spc(1)
- If Procent < 10 Then Lcd Spc(1)
- Lcd Procent
- Home : Lcd Chr(6)
- Shift Procent , Right , 1
- For N = 1 To 10
- If Procent > 5 Then Lcd Chr(5) Else Lcd Chr(procent)
- If Procent > 5 Then Procent = Procent - 5 Else Procent = 0
- Next
- Lcd Chr(7)
- End Sub
- Call Set_small_batt()
- Call Draw_batt(100)
- End
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $regfile = "m32def.dat"
- $crystal = 8000000
- $hwstack = 80
- $swstack = 128
- $framesize = 128
- $sim
- Config Submode = New
- Config Lcd = 20x4
- Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2
- Cursor Off
- Cls
- Sub Set_big_batt
- Deflcdchar 0 , 31 , 32 , 28 , 28 , 28 , 28 , 28 , 28 ' gora pol
- Deflcdchar 1 , 31 , 32 , 31 , 31 , 31 , 31 , 31 , 31 ' gora full
- Deflcdchar 2 , 28 , 28 , 28 , 28 , 28 , 28 , 32 , 31 ' dol pol
- Deflcdchar 3 , 31 , 31 , 31 , 31 , 31 , 31 , 32 , 31 ' dol full
- Deflcdchar 4 , 24 , 8 , 8 , 14 , 2 , 2 , 2 , 2 ' gora plusa
- Deflcdchar 5 , 2 , 2 , 2 , 2 , 14 , 8 , 8 , 24 ' dol plusa
- Deflcdchar 6 , 31 , 32 , 32 , 32 , 32 , 32 , 32 , 32 ' pusty gora
- Deflcdchar 7 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 31 ' pusty dol
- End Sub
- Sub Big_batt(byval Procent As Byte)
- Local Copy As Byte , N As Byte
- Locate 1 , 13
- If Procent < 100 Then Lcd Spc(1)
- If Procent < 10 Then Lcd Spc(1)
- Lcd Procent
- Shift Procent , Right , 1
- Copy = Procent
- Home
- For N = 1 To 10
- If Procent >= 5 Then
- Lcd Chr(1)
- Else
- If Procent >= 3 Then Lcd Chr(0) Else Lcd Chr(6)
- End If
- If Procent > 5 Then Procent = Procent - 5 Else Procent = 0
- Next
- Lcd Chr(4)
- Lowerline
- For N = 1 To 10
- If Copy >= 5 Then
- Lcd Chr(3)
- Else
- If Copy >= 3 Then Lcd Chr(2) Else Lcd Chr(7)
- End If
- If Copy > 5 Then Copy = Copy - 5 Else Copy = 0
- Next
- Lcd Chr(5)
- End Sub
- Call Set_big_batt()
- Call Big_batt(100)
- End