LCD_Program For PrpBASIC
caskaz
Posts: 957
Hi.
I try to make LCD-driver by PropBASIC.
Display for LCD works.
I translate from spin to BASIC.
Spin file (Decimal display)
pbasic file
If CONV_DEC 0(zero), display for LCD is "0".
Display for 0 - 9 ar OK.
BUT more than 10, they were bad.
10 -> 15 94 -> 95
100 -> 15 900 -> 95
Where are incorrect?
And how can subroutine(CONV_DEC) modify more smart?
Post Edited (caskaz) : 3/23/2010 6:48:27 AM GMT
I try to make LCD-driver by PropBASIC.
Display for LCD works.
I translate from spin to BASIC.
Spin file (Decimal display)
PUB DEC(VALUE) | TEMP IF (VALUE< 0) -VALUE CHAR("-") TEMP := 1_000_000_000 REPEAT 10 IF (VALUE => TEMP) CHARA(VALUE/TEMP + "0") VALUE //= TEMP RESULT~~ ELSEIF (RESULT OR TEMP == 1) CHAR("0") TEMP /= 10
pbasic file
SUB CONV_DEC NUM VAR __param1 n VAR __param2 NNUM VAR __param3 zz VAR __param4 zero VAR Long figure VAR Long figure = 1_000_000_000 zero = 0 IF NUM < 0 THEN NUM = -NUM CHAR "-" ENDIF FOR n = 1 TO 10 IF NUM >= figure THEN NNUM = NUM / figure NNUM = NNUM + "0" CHAR NNUM NUM = NUM // figure zero = 1 ELSE zz = zero | figure IF zz = 1 THEN CHAR "0" ENDIF EMDIF figure = figure / 10 NEXT ENDSUB
If CONV_DEC 0(zero), display for LCD is "0".
Display for 0 - 9 ar OK.
BUT more than 10, they were bad.
10 -> 15 94 -> 95
100 -> 15 900 -> 95
Where are incorrect?
And how can subroutine(CONV_DEC) modify more smart?
Post Edited (caskaz) : 3/23/2010 6:48:27 AM GMT
Comments
Attached is a progam to print decimal numbers on the Parallax Serial Terminal. it may be of some use
Gerry
You sample work fine.
I test below
test_num = 1
STR aaa, test_num,10
CHAR aaa
But "1" don't display on LCD.
CHAR "A" display "A" on LCD.
You need to send each character from aaa.
FOR temp = 0 TO 9
CHAR aaa(temp)
NEXT
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
·
I see.
And where does first pbas_sample I post is wrong?
Post Edited (caskaz) : 3/23/2010 12:35:23 PM GMT
Thanks for your help.
Post Edited (caskaz) : 3/23/2010 1:13:39 PM GMT
Your original program will work if you declare NUM as a cog variable and
if you change the first line in SUB·CONV_DEC
·from ·NUM····VAR···__param1 to· NUM = __param1
I think the problem is that NUM is assigned the value in __param1 but that this value is changed when you call "CHAR" as this also uses __param1
Gerry
I understand for your reply.