I've attached the project I'm fiddling with. It's Chip's SpatialSoundDemo that I've modified to use a 2-axis joystick instead of a mouse. I think I may be running out of cogs or possible I am doing something else wrong.
if I use cognew like I have here it works, but if I try to check for cogs it doesn't - I've commented out the line the doesn't work.
CON
_xinfreq = 5_000_000 ' External Crystal Frequency
_clkmode = xtal1 + pll16x ' Enabled External Crystal and PLL X16
OBJ
rc : "RCTime"
VAR
long joyStickStack[2]
long UDx, LRy
long cog
PUB start : okay
' stop
cognew(RawUDLR,@joyStickStack)
' return cog := cognew(RawUDLR,@joyStickStack) + 1
PUB stop
'' Stop joystick driver - frees a cog
if cog
cogstop(cog~ - 1)
PUB RawUDLR | UD, LR
repeat
rc.rctime(4, 1, @LR)
rc.rctime(2, 1, @UD)
UDx := UD
LRy := LR
PUB _UD : x
x := UDx
PUB _LR : y
y := LRy
Since cognew returns the newly started COG ID. How about encoding ( |< ) the COG ID in a byte. Then you can use logic operator to keep track of the COGs in use. You could just keep track of the COGs in an array.
@doggiedoc: Be generous and give your joystick stack a few more longs (I stick with 32 during development). Two is definitely too small.
Also, the way you use the RCTime object looks wrong. You're supposed to start it and simply read variables which are updated by its background task. Just realised it's in foreground mode. Apologies.
I think I got it. I didn't need cognew there at all. I should be calling the "start" method in RCTIME instead of the rctime method directly. This fixes the cog assignment problem posted above. I figured it out when I was bring to count manually how many cogs I was using.
{---->replaces mouse.spin for SteroSpatializerDemo
RC time uses 2axis joystick on pins 4 and 2
}
CON
_xinfreq = 5_000_000 ' External Crystal Frequency
_clkmode = xtal1 + pll16x ' Enabled External Crystal and PLL X16
OBJ
UD : "RCTime"
LR : "RCTime"
VAR
long UDx, LRy
PUB start
UD.start(4, 1, @UDx)
LR.start(2, 1, @LRy)
PUB _UD : x
x := UDx
PUB _LR : y
y := LRy
Comments
Rick
I've attached the project I'm fiddling with. It's Chip's SpatialSoundDemo that I've modified to use a 2-axis joystick instead of a mouse. I think I may be running out of cogs or possible I am doing something else wrong.
if I use cognew like I have here it works, but if I try to check for cogs it doesn't - I've commented out the line the doesn't work.
Also, the way you use the RCTime object looks wrong. You're supposed to start it and simply read variables which are updated by its background task. Just realised it's in foreground mode. Apologies.
Paul