Rampz
Well-known member
Thank you Alan, I have read several examples of tables but can't get my head around how to implement it in my code? I would say increasing the volume by an amount of steps above the volume set is the best way for what I'm doing. My master volume if you like is written to eeprom I wouldn't want each table change to get written to eeprom too, just changes as they do at the moment.Or of course you could create a simple PICaxe lookup table to relate a volume control level to each track.
Code:
#picaxe 14m2
#no_data
#terminal 4800
Symbol TX = B.4
Symbol RX = C.3
Symbol BUSY_PIN = pinC.2
Symbol BAUD_FREQ = M8
Symbol BAUD = T9600_8
Symbol cmd = b0
Symbol arg = w1 ; b3:b2
Symbol arg.lsb = b2
Symbol arg.msb = b3
Symbol varA = w2
symbol varB = w3
Symbol BTN = PinB.5 'volume up
Symbol BTN1 = PinB.3 'volume down
Symbol BTN2 = PinB.2 'next song
Symbol AXE134pin = C.1 'connected to screen input
Symbol Pressed = 1
init:
High TX ; set TX pin high for idle high serial
SerTxd("Get ready to Rock", CR, LF )
Pause 3000
'varB = 8 'initial volume setting
'cmd = 0x06 : arg = varB : Gosub Send
'SerTxd("init volume set to ", #varB, CR, LF ) ' added to display its value at this time
'pause 2000 ' added pause to see if it helped
read 0,WORD varB 'added to read previous volume from eeprom position 0
'SerTxd("eeprom volume set to ", #varB, CR, LF )
SEROUT AXE134pin , N2400_4 , ( 254 , 128 ); Position the cursor (at start of top line)128 top line
SEROUT AXE134pin , N2400_4 , ( "Programming by Rampz") ; Send to AXE134
SerTxd("Selected USB", CR, LF )
cmd = $09 : arg = $0001 : Gosub Send '0001 for usb, 0002 for sd card
pause 4000
cmd = 0x07 : arg = 0002 : Gosub Send ' EQ rock
SerTxd("Equlizer set to rock", CR, LF )
pause 1000
SEROUT AXE134pin , N2400_4 , ( 254 , 192 ); Position the cursor (at start of top line)128 top line
SEROUT AXE134pin , N2400_4 , ( "Equ to Rock, Set USB") ; Send to AXE134
cmd = 0x06 : arg = varB : Gosub Send 'Volume set at 8 of 30, altered to read varB
SerTxd("volume set to ", #varB, CR, LF ) 'display volume setting from eeprom hopefully
SEROUT AXE134pin , N2400_4 , ( 254 , 154 ); Position the cursor (at start of top line)128 top line
SEROUT AXE134pin , N2400_4 , ( "Volume=" , #VarB ," " ) ; Send to AXE134
Pause 1000
Gosub playsong
playsong:
For varA = 1 To 114
SerTxd("Playing song 000", #varA, CR, LF )
SEROUT AXE134pin , N2400_4 , ( 254 , 215 ); Position the cursor (at start of top line)128 top line
SEROUT AXE134pin , N2400_4 , ( "Playing Song " , #VarA ," " ) ; Send to AXE134
cmd = $12 : arg = varA : Gosub Send
Pause 1000
Do While BUSY_PIN = 0
Pause 100
IF BTN = Pressed then
pause 50
Gosub volumeup
endif
IF BTN1 = Pressed then
pause 50
Gosub volumedown
endif
IF BTN2 = Pressed then
pause 50
Gosub playnext
endif
Loop
next
Pause 1000
do: Gosub playsong: loop 'altered was (return)
Send:
SetFreq BAUD_FREQ
Pause 10
SerOut TX, BAUD, ( $7E, $FF, $06, cmd, $00, arg.msb, arg.lsb, $EF )
SetFreq MDEFAULT
Return
volumeup:
varB = VarB + 1 max 30
write 0,WORD varB 'write value to eeprom positiom 0
SEROUT AXE134pin , N2400_4 , ( 254 , 154 ) ; Position the cursor (at start of top line)128 top line
SEROUT AXE134pin , N2400_4 , ( "Volume=" , #VarB ," " ) ; Send to AXE134
SerTxd("volume ", #varB, CR, LF )
cmd = $04 : arg = $0000 : Gosub Send
return
Volumedown:
varB = VarB min 1 - 1
write 0,WORD varB 'write value to eeprom position 0
SEROUT AXE134pin , N2400_4 , ( 254 , 154 ); Position the cursor (at start of top line)128 top line
SEROUT AXE134pin , N2400_4 , ( "Volume=" , #VarB ," " ) ; Send to AXE134
SerTxd("volume ", #varB, CR, LF )
cmd = $05 : arg = $0000 : Gosub Send
return
playnext:
varA = varA + 1
SEROUT AXE134pin , N2400_4 , ( 254 , 215 ); Position the cursor (at start of top line)128 top line
SEROUT AXE134pin , N2400_4 , ( "Playing Song " , #VarA ," " ) ; Send to AXE134
SerTxd("Playing song 000", #varA, CR, LF )
cmd = $01 : arg = $0000 : Gosub Send
pause 500 ;;;;; added to stop double song issue, but slowed skipping song down
return
'cmd = 0x08 : arg = 0001 : Gosub Send 'repeatably play song 0001
'cmd = $12 : arg = 0001 : Gosub Send 'play song 0001
Last edited: