Shop OBEX P1 Docs P2 Docs Learn Events
BS2P to Propeller — Parallax Forums

BS2P to Propeller

El PaisaEl Paisa Posts: 375
edited 2006-05-12 01:42 in Propeller 1
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]

·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-06 21:18
    Your program is not complete; there is nothing that indicates the baud rate or mode and that would certainly be a requirement for translating to Spin.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 5/6/2006 9:29:59 PM GMT
  • El PaisaEl Paisa Posts: 375
    edited 2006-05-06 22:00
    Yes Jon:
    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 WilliamsJon Williams Posts: 6,491
    edited 2006-05-06 22:11
    I've attached the conversion of your original code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • El PaisaEl Paisa Posts: 375
    edited 2006-05-07 01:42
    Jon:
    Where I can get FullDuplexServo.spin?
    I search this forum without any results.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-05-07 03:19
    its in the objects dowload section for the propeller, it should also be included in the propeller IDE object library.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1+1=10
  • Jim CJim C Posts: 76
    edited 2006-05-07 07:42
    This question is a little confusing, because in the file from Jon, he has a comment: "see FullDuplexServo.spin for description"

    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
  • El PaisaEl Paisa Posts: 375
    edited 2006-05-07 13:53
    This is the first day I turned on my breadboard and·rocks !!
  • El PaisaEl Paisa Posts: 375
    edited 2006-05-07 13:56
    I forgot to include this.
    Many happy spinnings !!.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-07 17:01
    Indeed, sorry for my typo -- there was a disconnect between my brain and my hands and I had a servo problem with another customer on my mind.· Of course, the file is FullDuplexSerial.spin, and it is included in the standard distribution library.
    Jim C said...
    This question is a little confusing, because in the file from Jon, he has a comment: "see FullDuplexServo.spin for description"

    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
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • El PaisaEl Paisa Posts: 375
    edited 2006-05-08 18:46
    Hi Jon:
    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 WilliamsJon Williams Posts: 6,491
    edited 2006-05-08 19:36
    Look again at the demo -- the updateDisplay method accepts a color parameter and will output it as two bytes; all you have to do is pass the color of your choice.· See the attached update, and note that you don't have to break everything into bytes, the code handles this.· I used your constants in the update, but you may want to check them over.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • El PaisaEl Paisa Posts: 375
    edited 2006-05-11 02:45
    Jon:
    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.
  • El PaisaEl Paisa Posts: 375
    edited 2006-05-11 02:50
    Jon:
    My previous comments refer to the display functions.

    My next assignment is to implement the touch screen control.
  • El PaisaEl Paisa Posts: 375
    edited 2006-05-12 01:42
    Hi Jon:
    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
Sign In or Register to comment.