Counting Cogs
doggiedoc
Posts: 2,249
Anybody know if there is a way to find out how many cogs are in use at any given time in a program? Besides counting manually, that is.
Thanks,
Doc
Thanks,
Doc

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.
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 := LRyAlso, 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.
{---->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 := LRyPaul