November 21, 2024, 11:39:48 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


ShiftBrite Programming for prop-1

Started by gadget-evilusions, October 15, 2009, 09:28:58 AM

Previous topic - Next topic

gadget-evilusions

I just ordered the shiftbrite and megabrite from http://www.macetech.com/store/ .

I saw the program posted that will control the shiftbrite using a prop-2 here http://www.efx-tek.com/php/smf/index.php?topic=620.0 , but was wondering if it is possible to control a shiftbright using a prop-1? I didn't completely understand the code so I wasn't sure. If so, would it be possible to get a starter program that I could play with?

thank you.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Here's one to play with but I don't recommend it.  The problem is that device requires four pieces of data sent using an SPI-type interface.  The Prop-2 can easily handle this with SHIFTOUT, but this isn't built into the Prop-1 so you have to synthesize it in code.  Another problem is variable space -- the Prop-1 doesn't have much....  Use a Prop-2.

Note: Compiles fine but not tested as I don't have one of those devices.

' =========================================================================
'
'   File...... ShiftBright.bs1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 15 OCT 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Enable          = PIN3
SYMBOL  Latch           = 2
SYMBOL  SData           = PIN1
SYMBOL  Clock           = 0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  work            = W0                    ' do not re-assign this var

SYMBOL  idx             = B2
SYMBOL  idx2            = B3

SYMBOL  red             = B4
SYMBOL  green           = B5
SYMBOL  blue            = B6



' -----[ Initialization ]--------------------------------------------------

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00001111                              ' set output pins

  work = %01
  GOSUB SB_Command

  FOR idx2 = 1 TO 3
    work = 127
    GOSUB SB_Color
  NEXT

  PULSOUT Latch, 1                              ' latch data


' -----[ Program Code ]----------------------------------------------------

Main:
  FOR red = 0 TO 255
    work = %00
    GOSUB SB_Command
    work = red * 4                              ' shift left by 2 bits
    GOSUB SB_Command
    work = 0
    GOSUB SB_Command
    GOSUB SB_Command
    PULSOUT Latch, 1
    PAUSE 5
  NEXT

  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

' load command into "work" before calling

SB_Command:
  FOR idx = 1 TO 2
    SData = BIT1
    PULSOUT Clock, 1
    work = work * 2
  NEXT
  RETURN

' -------------------------------------------------------------------------

' load color into "work" before calling

SB_Color:
  FOR idx = 1 TO 10
    SData = BIT9
    PULSOUT Clock, 1
    work = work * 2
  NEXT
  RETURN

' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

Thanks Jon, I will play with this, but will use a prop-2 in my final prop as per your recommendation.

Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Here's another version of that program -- it uses more space in the subroutine but is easier to call, and should make porting the the BS2 version easier.

' =========================================================================
'
'   File...... ShiftBright.bs1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 15 OCT 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Enable          = PIN3
SYMBOL  Latch           = 2
SYMBOL  SData           = PIN1
SYMBOL  Clock           = 0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  work            = W0                    ' do not re-assign this var

SYMBOL  idx             = B2

SYMBOL  cmd             = B3
SYMBOL  red             = B4
SYMBOL  green           = B5
SYMBOL  blue            = B6



' -----[ Initialization ]--------------------------------------------------

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00001111                              ' set output pins

  cmd = %01
  red = 127
  green = 127
  blue = 127
  GOSUB ShiftBright

  cmd = %00


' -----[ Program Code ]----------------------------------------------------

Main:
  green = 0
  blue = 0

  FOR red = 0 TO 255
    GOSUB ShiftBright
    PAUSE 5
  NEXT

  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

ShiftBright:
  work = cmd
  FOR idx = 1 TO 2
    SData = BIT1
    PULSOUT Clock, 1
    work = work * 2
  NEXT

  work = red * 4
  FOR idx = 1 TO 10
    SData = BIT9
    PULSOUT Clock, 1
    work = work * 2
  NEXT

  work = green * 4
  FOR idx = 1 TO 10
    SData = BIT9
    PULSOUT Clock, 1
    work = work * 2
  NEXT

  work = blue * 4
  FOR idx = 1 TO 10
    SData = BIT9
    PULSOUT Clock, 1
    work = work * 2
  NEXT

  PULSOUT Latch, 1

  RETURN

' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office