BS2P to Propeller
El Paisa
Posts: 375
I need some help to convert the folowing BS2P code to SPIN:
'define constants
Set_xhy CON $85
Set_colorh CON $84
Print_string CON $2D
'define variables
X VAR Word
Y VAR Byte
Xl VAR xs.LOWBYTE
Xh VAR xs.HIGHBYTE
Color VAR Word
Colorl VAR color.LOWBYTE
Colorh VAR color.HIGHBYTE
Color = 65535
x=100
y=100
main:
SEROUT pin,baud,[noparse][[/noparse]Set_colorh , Colorl , Colorh , Set_xhy , Xh , Xl , Y ,print_string,"Parallax Propeller rocks!!",0]
·
'define constants
Set_xhy CON $85
Set_colorh CON $84
Print_string CON $2D
'define variables
X VAR Word
Y VAR Byte
Xl VAR xs.LOWBYTE
Xh VAR xs.HIGHBYTE
Color VAR Word
Colorl VAR color.LOWBYTE
Colorh VAR color.HIGHBYTE
Color = 65535
x=100
y=100
main:
SEROUT pin,baud,[noparse][[/noparse]Set_colorh , Colorl , Colorh , Set_xhy , Xh , Xl , Y ,print_string,"Parallax Propeller rocks!!",0]
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 5/6/2006 9:29:59 PM GMT
It was a simplified part.
the complete is as Follows:
' {$STAMP BS2p}
' {$PBASIC 2.5}
' {$PORT COM4}
'color_palette.bsp
'displays at random the 16 bit color palette
'ver 1.0
'Albert Catano
'January 18 , 2006
'
' ezLCD-004 RX/TX terminals connected to pin 15 and pin 14 terminals of the BS2P
'Color table
Green_lsb CON %1110000
Green_msb CON %00000111
Red_lsb CON %00000000
Red_msb CON %11111000
White_lsb CON %11111111
White_msb CON %11111111
Black_lsb CON %00000000
Black_msb CON %00000000
'Drawing commands
· Arch CON $8F
· Boxh CON $A2
· Boxh_fill CON $A3
· Circle_rh CON $89
· Circle_rh_fill CON $99
· Ezcls CON $21
· H_lineh CON $A0
· Light_off CON $23
· Light_on CON $22
· Light_bright CON $80
· Line_to_xhy CON $88
· Plot CON $26
· Plot_xhy CON $87
· Print_string CON $2D
· Text_north CON $60···································· '- default (landscape)
· Text_east CON $61····································· '- portrait
· Text_south CON $62···································· '- landscape upside down
· Text_west CON $63······································· '- portrait upside down
· Select_font CON $2B
· Set_colorh CON $84
· Set_xhy CON $85
· Put_sf_icon CON $58
· Set_xy CON $25
· Set_color CON $24
'define constants
NULL CON 0
Dx CON 23
Dy CON 22
Dwx CON 21
Dwy CON 20
'define variables
Xs VAR Word
Xe VAR Word
Ys VAR Byte
Ye VAR Byte
Xsl VAR xs.LOWBYTE
Xsh VAR xs.HIGHBYTE
Xel VAR xe.LOWBYTE
Xeh VAR xe.HIGHBYTE
Color VAR Word
Colorl VAR color.LOWBYTE
Colorh VAR color.HIGHBYTE
'Initialize display
SEROUT 15,240,[noparse][[/noparse]Light_bright,100,Set_colorh,White_lsb,White_msb,ezCLS,Set_colorh,Black_lsb,Black_msb]
PAUSE 500
Color = 65535
SEROUT 15,240,[noparse][[/noparse]select_font,0]
'banner
SEROUT 15,240,[noparse][[/noparse]set_xhy,0,70,0,Text_north,print_string,"ezLCD-004 Random Color Palette",null]
'
[noparse][[/noparse]Main Program starts here]
main:
FOR Xs = 12 TO 297 STEP Dx································· '130 squares
FOR Ys = 13 TO 212 STEP Dy································· 'to fill with random colors
Xe = Xs + Dwx
Ye = Ys + Dwy
RANDOM color························ ' generate random number
SEROUT 15,240,[noparse][[/noparse]Set_colorh , Colorl , Colorh , Set_xhy , Xsh , Xsl , Ys , Boxh_fill , Xeh , Xel , Ye]
NEXT
NEXT
PAUSE 500
'
[noparse][[/noparse]ends here]
GOTO main······················································· ' loop forever
END
I really appreciate if you can help me on this.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Where I can get FullDuplexServo.spin?
I search this forum without any results.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1+1=10
But, he attaches the object "FullDuplexSerial.spin" in the actual code and it's the FullDuplexSerial.spin that is in the IDE object library. So, I suspect the "FullDuplexServo" in the comment is a typo
Many happy spinnings !!.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Your program works just fine.
Now my question is:
How you change colors?
I have color table 16 bits wide
Navy_lsb· = %00010000
Navy_msb =·%00000000
Yellow_lsb·= %11100000
Yellow_msb·= %11111111
Green_lsb·= %1110000
Green_msb·= %00000111
Red_lsb·= %00000000
Red_msb·= %11111000
Blue_lsb·= %00011111
Blue_msb·= %00000000
White_lsb·= %11111111
White_msb·= %11111111
Black_lsb·= %00000000
Black_msb·= %00000000
Purple_lsb·= %00010000
Purple_msb·= %10000000
or a value from 0 to 65536000
I do not see any provisions to insert the color value
Your help is really appreciated.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
You are indeed my hero.
I got the ezLCD-004 well under control.
I can do all kind of things with it.
It surpass lcds, video monitors any time.
Also can display human faces.
Thanks again.
My previous comments refer to the display functions.
My next assignment is to implement the touch screen control.
One more question and promise to be quite for a while at least.
I need to receive some characters from the touch screen.
In the BS2P is like:
portout CON 15
portin CON 14
baudrate CON 240
Button_def CON $B0
Button_state CON $B1·············
Touch_protocol CON $B2·
k VAR Byte
Btn VAR Byte
Touchread:
SERIN portin,baudrate,[noparse][[/noparse]K]················································· ' **
btn = k & $3f
k = k & $C0
IF k = $40 THEN ON btn GOTO Btn0,Btn1,Btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,reset,enter,s1,s2,s3,s4
IF k = $80 THEN GOTO Btn_away
GOTO Btn_up
Btn_away:
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 0 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 1 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 2 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 3 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 4 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 5 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 6 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 7 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 8 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 9 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 10 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 11 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 12 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 13 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 14 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 15 , 1]
GOTO Touchread
Btn_up:······················································ 'else button UP both b7, b6 high
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 0 , 1]··················· 'set button state
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 1 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 2 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 3 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 4 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 5 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 6 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 7 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 8 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 9 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 10 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 11 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 12 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 13 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 14 , 1]
·· SEROUT portout,baudrate,[noparse][[/noparse]$b1 , 15 , 1]
GOTO Touchread
btn0:
· SEROUT portout,baudrate,[noparse][[/noparse]$b1 ,·0 , 2]
.
.
.goto Touchread
.
.
s4:
· SEROUT portout,baudrate,[noparse][[/noparse]$b1 ,·15 , 2]
.
.
goto Touchread