Googfan
08-01-2008, 01:02 AM
How do i convert a value to a string in pbasic 2.5
ie:
··· 1·· ·to "1"
··· 258 to "258"
i would like to display it on an lcd by modifying·my·"Sin to LCD"·code:
' {$STAMP BS2}
' {$PBASIC 2.5}
LineChars··· CON 16' === Number of Characters per Line
'----------------------------------------------
DEBUG "Ready..."
LcdHome····· CON $02 ' move cursor home
LcdCrsrL···· CON $10 ' move cursor left
LcdCrsrR···· CON $14 ' move cursor right
LcdDispL···· CON $18 ' shift chars left
LcdDispR···· CON $1C ' shift chars right
ochar······· VAR Byte
crsrPos····· VAR Byte
char········ VAR Byte
lcdone······ VAR Bit
LcdDirs····· VAR DIRB'.................dirs FOr I/O redirection
LcdBusOut··· VAR OUTB
LcdBusIn···· VAR INB
E··· PIN 1'....Adam Munich is· My PuppetmasterAdam Munich is· My Puppetmaster........................LCD Enable (1 = enabled)
RW·· PIN 2'............................Read/WRITe\
RS·· PIN 3'............................Reg SELECt (1 = char)
' LCD Initialization----------------------------------------------------------------------
DIRL = %11111110
· LcdBusOut = %0011'...................8-Bit mode
· PULSOUT E, 3 : PAUSE 5
· PULSOUT E, 3 : PAUSE 0
· PULSOUT E, 3 : PAUSE 0
· LcdBusOut = %0010'...................4-bit mode
· PULSOUT E, 3
· char = %00101000'....................2-line mode
· GOSUB LCD_Command
· char = %00001101'....................on, no crsr, blink
· GOSUB LCD_Command
· char = %00000110'....................inc crsr, no disp shift
· GOSUB LCD_Command
ochar = 0
'routine---------------------------------------------------------------------------
main:
GOSUB LCD_Clear
DO
SERIN 16, 16468, [char]
IF char = "`" THEN GOTO main'..........Clear?
GOSUB LCD_Write_Char
LOOP
'lcd subprograms--------------------------------------------------------------------------
' -- put command byte in 'char'
LCD_Command:
LOW RS
LcdBusOut = char.HIGHNIB'..............output high nibble
PULSOUT E, 3'..........................strobe the Enable line
LcdBusOut = char.LOWNIB'...............output low nibble
PULSOUT E, 3
HIGH RS
RETURN
' -- put byte to write in 'char'
LCD_Write_Char:
LcdBusOut = char.HIGHNIB'..............output high nibble
PULSOUT E, 3'..........................strobe the Enable line
LcdBusOut = char.LOWNIB'...............output low nibble
PULSOUT E, 3
ochar = ochar+1'.......................coutin
IF ochar > (LineChars-1) THEN'.........Word Wrap?
· IF lcdone = 0 THEN'..................yes
··· char = $C0
··· GOSUB LCD_Command
· ENDIF
· lcdone = 1'..........................no
ENDIF
HIGH RS'...............................Char Mode
RETURN
LCD_Clear:
lcdone = 0'............................reset vars
ochar· = 0
char = $01'............................Clear LCD
GOSUB LCD_Command
PAUSE 5
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mixing things...
It can be deadly -- Potassium Carbon Nitrogen [KCN]
It can be fun -----·Potassium Nitrogen Oxogen Carbon Sulfer [KNO3+C+S]
It can be useless - Napkin Butter
wait, what point was I·trying to establish?
·
ie:
··· 1·· ·to "1"
··· 258 to "258"
i would like to display it on an lcd by modifying·my·"Sin to LCD"·code:
' {$STAMP BS2}
' {$PBASIC 2.5}
LineChars··· CON 16' === Number of Characters per Line
'----------------------------------------------
DEBUG "Ready..."
LcdHome····· CON $02 ' move cursor home
LcdCrsrL···· CON $10 ' move cursor left
LcdCrsrR···· CON $14 ' move cursor right
LcdDispL···· CON $18 ' shift chars left
LcdDispR···· CON $1C ' shift chars right
ochar······· VAR Byte
crsrPos····· VAR Byte
char········ VAR Byte
lcdone······ VAR Bit
LcdDirs····· VAR DIRB'.................dirs FOr I/O redirection
LcdBusOut··· VAR OUTB
LcdBusIn···· VAR INB
E··· PIN 1'....Adam Munich is· My PuppetmasterAdam Munich is· My Puppetmaster........................LCD Enable (1 = enabled)
RW·· PIN 2'............................Read/WRITe\
RS·· PIN 3'............................Reg SELECt (1 = char)
' LCD Initialization----------------------------------------------------------------------
DIRL = %11111110
· LcdBusOut = %0011'...................8-Bit mode
· PULSOUT E, 3 : PAUSE 5
· PULSOUT E, 3 : PAUSE 0
· PULSOUT E, 3 : PAUSE 0
· LcdBusOut = %0010'...................4-bit mode
· PULSOUT E, 3
· char = %00101000'....................2-line mode
· GOSUB LCD_Command
· char = %00001101'....................on, no crsr, blink
· GOSUB LCD_Command
· char = %00000110'....................inc crsr, no disp shift
· GOSUB LCD_Command
ochar = 0
'routine---------------------------------------------------------------------------
main:
GOSUB LCD_Clear
DO
SERIN 16, 16468, [char]
IF char = "`" THEN GOTO main'..........Clear?
GOSUB LCD_Write_Char
LOOP
'lcd subprograms--------------------------------------------------------------------------
' -- put command byte in 'char'
LCD_Command:
LOW RS
LcdBusOut = char.HIGHNIB'..............output high nibble
PULSOUT E, 3'..........................strobe the Enable line
LcdBusOut = char.LOWNIB'...............output low nibble
PULSOUT E, 3
HIGH RS
RETURN
' -- put byte to write in 'char'
LCD_Write_Char:
LcdBusOut = char.HIGHNIB'..............output high nibble
PULSOUT E, 3'..........................strobe the Enable line
LcdBusOut = char.LOWNIB'...............output low nibble
PULSOUT E, 3
ochar = ochar+1'.......................coutin
IF ochar > (LineChars-1) THEN'.........Word Wrap?
· IF lcdone = 0 THEN'..................yes
··· char = $C0
··· GOSUB LCD_Command
· ENDIF
· lcdone = 1'..........................no
ENDIF
HIGH RS'...............................Char Mode
RETURN
LCD_Clear:
lcdone = 0'............................reset vars
ochar· = 0
char = $01'............................Clear LCD
GOSUB LCD_Command
PAUSE 5
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mixing things...
It can be deadly -- Potassium Carbon Nitrogen [KCN]
It can be fun -----·Potassium Nitrogen Oxogen Carbon Sulfer [KNO3+C+S]
It can be useless - Napkin Butter
wait, what point was I·trying to establish?
·