; iPod controller
; Using AXE117 Project board and Podbreakout board
; Note on v1 of the AXE117 PCB the bottom 10K and 22k are reverse marked!
; 22k should be above WWW. text
; 10k should be above .CO.UK text
; Connections
; iPod Podbreakout PICAXE-14M on AXE117
; Txd 12 Input0
; Rxd 13 Output5 (via 10k/22k divider to give 3.3V)
; Gnd 1 0V
; Also link pin 11 to pin 21 of Podbreakout with 470k resistor
; - this puts iPod into serial mode
; Serial baud rate - normally 19200,n,8,1
; However iPod 'learns' baudrate from the header $FF $55
; Therefore most baudrates can be used - we will use 9600
; by running 14M at double speed on 4800.
; Remember all pauses will now be half as long!
; Format
; Header $FF $55
; Length $xx = ? bytes = size of mode + command + parameter
; Mode $xx = 1 byte
; Command $xx $xx = 2 bytes
; Parameter variable = ? bytes = 0 - 250 extra bytes
; Checksum $xx = 1 byte = $100 - (sum of all bytes & $FF)
; Modes
; $00 mode switching
; $01 voice recorder
; $02 simple remote
; $03 request mode
; $04 advanced Remore Mode (AiR)
;Mode switching
; $01 $01 Switch to Voice Recorder Mode
; $01 $02 Switch to Remote Mode
; $01 $04 Switch to AiR Mode
; $03 Get current mode status
; $04 $xx Get current mode number
; example, to switch to mode AiR
; $FF $55 $03 $00 $01 $04 $F8
; For AiR commands google 'iPod Serial Protocol'
; We will just use Mode 2, simple iPod remote mode
; Mode 2, iPod Remote
; Protocol - send cmd with 12ms delay
; then send button released
;
; $00 $00 Button Released $FF $55 $03 $02 $00 $00 $FB
; $00 $01 Play /Pause $FF $55 $03 $02 $00 $01 $FA
; $00 $02 Vol+ $FF $55 $03 $02 $00 $02 $F9
; $00 $04 Vol- $FF $55 $03 $02 $00 $04 $F7
; $00 $08 Skip > $FF $55 $03 $02 $00 $08 $F3
; $00 $10 Skip < $FF $55 $03 $02 $00 $10 $EB
; $00 $20 Next Album $FF $55 $03 $02 $00 $20 $DB
; $00 $40 Previous Album $FF $55 $03 $02 $00 $40 $BB
; $00 $80 Stop $FF $55 $03 $02 $00 $80 $7B
; Simple maths test routine, ok so we are lazy!
; Get the PICAXE to work out the checksums above for us!
; Add all bytes apart from checksum
; The answer will be in b1
#rem
maths:
b0 = $03 + $02 + $00 + $80
b1 = 0 - b0
debug
pause 1000
goto maths
#endrem
; Additional commands found on internet - not tested, checksum not calculated yet.
; may not work with all iPods
; $00 $00 $01 Play $FF $55 $04 $02 $00 $00 $01 $xx
; $00 $00 $02 Pause $FF $55 $04 $02 $00 $00 $02 $xx
; $00 $00 $04 Toggle Mute $FF $55 $04 $02 $00 $00 $04 $xx
; $00 $00 $20 Next Playlist $FF $55 $04 $02 $00 $00 $20 $xx
; $00 $00 $40 Previous Playlist $FF $55 $04 $02 $00 $00 $40 $xx
; $00 $00 $80 Toggle Shuffle $FF $55 $04 $02 $00 $00 $80 $xx
; $00 $00 $00 $01 Toggle Repeat $FF $55 $05 $02 $00 $00 $00 $01 $xx
; $00 $00 $00 $04 iPod Off $FF $55 $05 $02 $00 $00 $00 $04 $xx
; $00 $00 $00 $08 iPod On $FF $55 $05 $02 $00 $00 $00 $08 $xx
; $00 $00 $00 $40 menu button $FF $55 $05 $02 $00 $00 $00 $40 $xx
; $00 $00 $00 $80 OK/Select $FF $55 $05 $02 $00 $00 $00 $80 $xx
; $00 $00 $00 $00 $01 Scroll up $FF $55 $07 $02 $00 $00 $00 $00 $01 $xx
; $00 $00 $00 $00 $02 Scroll down $FF $55 $07 $02 $00 $00 $00 $00 $02 $xx
#rem
; Simple test routine shoudl switch between play and pause every 2 seconds
#picaxe 14m
init:
setfreq m8
main:
serout 5,t4800,($FF,$55,$03,$02,$00,$01,$FA) ' send play/pause
pause 24 ' wait 12 ms
serout 5,t4800,($FF,$55,$03,$02,$00,$00,$FB) ' send button up
pause 4000 ' wait 2 seconds
serout 5,t4800,($FF,$55,$03,$02,$00,$01,$FA) ' send play/pause
pause 24 ' wait 12 ms
serout 5,t4800,($FF,$55,$03,$02,$00,$00,$FB) ' send button up
pause 4000 ' wait 2 seconds
goto main
#endrem
; Simple Controller Program
; Input 1 - play / pause
; Input 2 - stop
; Input 3 - skip >
; Input 4 - skip <
#picaxe 14m
symbol cmd = b0
symbol sum = b1
init2:
setfreq m8
main2:
if pin1 = 1 then do_play
if pin2 = 1 then do_stop
if pin3 = 1 then do_skip1
if pin4 = 1 then do_skip2
goto main2
do_play:
cmd = $01
sum = $FA
goto btn_up
do_stop:
cmd = $80
sum = $7B
goto btn_up
do_skip1:
cmd = $08
sum = $F3
goto btn_up
do_skip2:
cmd = $10
sum = $EB
goto btn_up
btn_up:
serout 5,t4800,($FF,$55,$03,$02,$00,cmd,sum) ' send command
pause 24 ' wait 12 ms
serout 5,t4800,($FF,$55,$03,$02,$00,$00,$FB) ' send button up
pause 2000 ' wait 1 second
goto main2