April 18, 2024, 10:53:14 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.


Prop-1 Control of VMUSIC MP3 Player

Started by JonnyMac, May 24, 2008, 12:26:59 AM

Previous topic - Next topic

JonnyMac

May 24, 2008, 12:26:59 AM Last Edit: April 14, 2009, 02:24:35 PM by JonnyMac
This is my Prop-1 program for controlling the VMUSIC player.  My connections differ slightly from Scary Terry's -- by using P7 and P6 the SETUP jumpers can be moved to UP which allows the VMUSIC player to keep going, even if the program hits an END statement.  You can use any of the other pins as active-high trigger inputs as the ULN acts as a pull-down on the pin (which is why we have to clip pins that use True mode comms).

Be sure to download the firmware file from Terry's page: http://www.scary-terry.com/vm2/vm2_bs1.htm

You need to rename the file ftrfb.ftd and put it onto your memory stick; this will update the player to work at 2400 baud.

Updated: 14 APR 2009

' =========================================================================
'
'   File...... VMusic.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 14 APR 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Demo for VMUSIC2 player; based on work by "Scary" Terry Simmons
' -- P7 and P6 SETUP jumpers need to be in the UP position
' -- clip pins 1 and 2 from ULN2803, or pin 1 from the ULN2003
' -- trigger on P5 must be active-high; ULN acts as pull-down


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


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

SYMBOL  RX              = 7                     ' SETUP = UP, no ULN
SYMBOL  TX              = 6                     ' SETUP = UP, no ULN
SYMBOL  Trigger         = PIN5                  ' active-high input


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

SYMBOL  Baud            = OT2400

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  theMP3          = B2                    ' MP3 file pointer
SYMBOL  char            = B3                    ' character value
SYMBOL  eePntr          = B4                    ' EEPROM memory pointer
SYMBOL  volume          = B5

SYMBOL  idx             = B6                    ' loop controller


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

Reset:
  PAUSE 2250                                    ' let VMUSIC power up
  GOSUB VM_Stop                                 ' stop if playing
  GOSUB VM_Wait_Prompt


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

Main:
  DEBUG CLS, "Playing FIREFLY.MP3", CR
  theMP3 = 0
  GOSUB VM_Play
  GOSUB VM_Wait_Start
  DEBUG "-- file started", CR

  PAUSE 5000
  volume = 25
  GOSUB VM_Volume
  GOSUB VM_Wait_Prompt
  DEBUG "-- volume reduced", CR

  GOSUB VM_Wait_Prompt
  DEBUG "-- ready for new song", CR

  volume = 0
  GOSUB VM_Volume
  GOSUB VM_Wait_Prompt
  DEBUG "-- volume reset to max", CR, CR

  DEBUG "Playing SERENITY.MP3", CR
  theMP3 = 1
  GOSUB VM_Play
  GOSUB VM_Wait_Start
  DEBUG "-- file started", CR, CR

  GOSUB VM_Wait_Prompt
  DEBUG "VMUSIC demo done", CR, CR

  PAUSE 5000
  GOTO Main


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

' Pass file # (index in EEPROM table) to play in "theMP3"

VM_Play:
  SEROUT TX, Baud, ("VPF ")                     ' start of commands
  eePntr = theMP3 * 8                           ' calc address of name

Send_Name:                                      ' send file title
  FOR idx = 1 TO 8                              ' max is 8 characters
    READ eePntr, char                           ' get a character
    IF char = 0 THEN Finish_Cmd                 ' if 0, we're at end
    SEROUT TX, Baud, (char)
    eePntr = eePntr + 1
  NEXT

Finish_Cmd:
  SEROUT TX, Baud, (".MP3", 13)                 ' send extention + CR
  RETURN

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

VM_Wait_Start :
  SERIN RX, Baud, ("T $")
  RETURN

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

VM_Stop:
  SEROUT TX, Baud, ("VST", 13)
  RETURN

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

VM_Pause:
  SEROUT TX, Baud, ("VP", 13)
  RETURN

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

VM_Resume:
  GOTO VM_Pause

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

' Pass volume (0 = loudest, 254 = muted) in "volume"

VM_Volume:
  volume = volume MAX $FE                       ' limit per spec
  SEROUT TX, Baud, ("VSV ", #volume, 13)
  RETURN

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

VM_Wait_Prompt:
  SERIN RX, Baud, (">")
  RETURN

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


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


' -----[ User Data ]-------------------------------------------------------

' File names are stored on 8-byte boundaries - be sure to add 0 (zero) to
' EEPROM statement to ensure end-of-string indicated when name is less than
' eight characters.
'
' This strategy uses a little more EE space but is easier to maintain

Song_List:
  EEPROM $00, ("firefly", 0)                    ' file 0
  EEPROM $08, ("serenity", 0)
  EEPROM $10, ("spalding", 0)
  EEPROM $18, ("file3", 0)
  EEPROM $20, ("file4", 0)
  EEPROM $28, ("file5", 0)
  EEPROM $30, ("file6", 0)
  EEPROM $38, ("file7", 0)
Jon McPhalen
EFX-TEK Hollywood Office