I have added more checks to the code now if the string ends up less than 4 characters it gets padded out to 4 so that the unused displays are blanked I use character 64 "@" which is all 0s in EEPROM this means you can chose the character you want by replacing the one in EEPROM
Note even thought I am using a module with a M328 on it the code is only at 6580 so will still work on a standard display I will put up the full code to date when I tidy up a bit
Regards Paul
[code:1:7406000d50]
'--------------------------------
'--this gets the string (text value)
'--of a number finds a decimal point & negative sign & plus sign
'--removes it from the string then
'--displays it where it should be on the
'--display while it gets and displays the 4 digits
'--plus decimal point and or negative sign
'--to do this the numerical characters in EEPROM
'--have been moved 3 dot colums to the right to make
'--space for these special characters
Sub Disply_num
Local V As Byte
Local W As Byte
Local X As Byte
Local Y As Byte
Local Z As Byte
Local Dpoint As Byte 'decimal point "."
Local Negtiv As Byte 'negative sign "-"
Local Plus As Byte 'the plus sign "+"
Local Divid As Byte
Local Hfn As Byte
Local Ecl As Byte
'--Notice that a LOCAL variable is not initialized.
'--It will contain a value that will depend on the value of the FRAME data.
'--So you can not assume the variable is 0. If you like it to be 0,
'--you need to assign it.
Dpoint = 0
Negtiv = 0
Plus = 0
Divid = 0
Hfn = 0
Ecl = 0
X = 0
Z = 1
Do
W = 0
Kar = Mid(adcprn , Z , 1) 'get one character from the string
X = Asc(kar)
'--here we see if its a special character for the 3 columns
Select Case X
Case 32 'space
Kar = Chr(64) 'is blank in EEPROM
Case 33 '"!"
W = 1
Ecl = Z
Case 43 ' "+"
W = 1
Plus = Z
Case 39 ' "'"
W = 1
Hfn = Z
Case 45 ' "-"
W = 1
Negtiv = Z
Case 46 ' "."
W = 1
Dpoint = Z
Case 47 ' "/"
W = 1
Divid = Z
End Select
If W = 1 Then 'special character was found
Delchar Adcprn , Z 'remove character
Y = Len(adcprn) 'how long is the string
If Y < 4 Then 'need to blank some digits
For X = Y To 4
Adcprn = Adcprn + Chr(64) 'add blanks to end of string to get to 4
'Note I have used @ as my location for a blank
Next X
End If
Else
Dignum = Z 'display it at digit Z
Call Display_chr
Dig(z) = Ana
Incr Z 'Ana contains the character from eeprom rotated
End If
'ready to display
Loop Until Z = 5
'what we do here is combine a digit with the
'decimal point and or the negative sign
If Plus > 0 Then 'put back plus sign
Dig(plus).17 = 1
Dig(plus).24 = 1
Dig(plus).25 = 1
Dig(plus).26 = 1
Dig(plus).33 = 1
End If
If Dpoint > 0 Then 'put back decimal point
Dig(dpoint).25 = 1
Dig(dpoint).33 = 1
End If
If Negtiv > 0 Then 'put back negative sign
Dig(negtiv).24 = 1
Dig(negtiv).25 = 1
Dig(negtiv).26 = 1
End If
If Hfn > 0 Then 'put back single quotation mark
Dig(hfn).1 = 1
Dig(hfn).9 = 1
End If
If Divid > 0 Then 'put back division sign
Dig(divid).32 = 1
Dig(divid).25 = 1
Dig(divid).18 = 1
End If
If Ecl > 0 Then 'put back exclamation mark
Dig(ecl).1 = 1
Dig(ecl).9 = 1
Dig(ecl).17 = 1
Dig(ecl).25 = 1
Dig(ecl).33 = 1
Dig(ecl).49 = 1
End If
Z = Y - X
End Sub
[/code:1:7406000d50]
↧