I hit a limit aparently. Tells me the limit of 255 GOSUBs was exceeded. Is this a language limitation or a BS2 limitation? I also have a BS2sx if maybe it will allow more GOSUBs.
Yes, I am trying to write a program that will basically do a LED light sequence that is about 1000 steps long. I got like 25% of the way through programming the squence and hit the limit. I'm not sure this is going to be possible anymore. I was doing something like this:
This is just kind of how the code was working, but then I hit the 255 max. I was doing it this way because I guess I dont have enough variable or eeprom memory to store the order of light flashes.
Anyone know how I can do this? There is going to be potentially 800-1200 light flashes that need to happen. The time between the flashes may change as well, if you look in my example sometimes it waits 150ms and sometimes 100ms
Also worth mentioning is that the subroutines such as blink_light_A also have other stuff inside them, so I can't simply replace the GOSUB call with the LEDS = %00000001 line without getting extremely messy.
Without seeing all the code its hard to give a full answer but from what we have I can see ways of trimming it down some.
The Leds don't have to be in a subroutine just give them a variable in your main loop
x=some_number
LEDS=x
do the same with the pause you might even use the same variable if you don't need to retain it
x=another_number
PAUSE x
If the subroutines are doing similar functions try and do it all with one subroutine but pass it different paramaters
DATA 100, $01, 150, $02, 'etc -- you'll have to input the pattern of LED blinks,
' but it will be WAY shorter than typing in 800 "LED = xxx: PAUSE 100" statements.
Post Edited (allanlane5) : 4/14/2007 7:54:35 PM GMT
Comments
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
This is just kind of how the code was working, but then I hit the 255 max. I was doing it this way because I guess I dont have enough variable or eeprom memory to store the order of light flashes.
Anyone know how I can do this? There is going to be potentially 800-1200 light flashes that need to happen. The time between the flashes may change as well, if you look in my example sometimes it waits 150ms and sometimes 100ms
The Leds don't have to be in a subroutine just give them a variable in your main loop
x=some_number
LEDS=x
do the same with the pause you might even use the same variable if you don't need to retain it
x=another_number
PAUSE x
If the subroutines are doing similar functions try and do it all with one subroutine but pass it different paramaters
my_output=1
GOSUB whatever
my_output=4
GOSUB whatever
whatever :
HIGH my_output
RETURN
Jeff T
MAIN:
MyTemp = 1
GOSUB DoSomething
MyTemp = 2
GOSUB DoSomething
GOTO MAIN ' Also known as, "the main loop"
DoSomething:
IF MyTemp = 1 THEN
Do Stuff
ENDIF
IF MyTemp = 2 THEN
DoOtherStuff
ENDIF
RETURN
This is the 'classic' way to begin 'parameterizing' subroutine calls. It makes life MUCH easier if "DoStuff" and "DoOtherStuff" are quite similar.
Looking at your code, you could have two calls -- long blink and short blink, and set a number of which LED to blink as a 'parameter'.
Another way to do this would be with DATA statements -- a duration, and the LED pattern.· Then your program becomes very simple.
MaxPat = 800
LEDPat = 0
MAIN:
··READ LEDPat, TimeVal
· READ LEDPat + 1, LEDVal
· GOSUB BlinkLED· ' (TimeVal, LEDVal)
· LEDPat = LEDPat + 2
· IF LEDPat > MAXPat THEN
··· LEDPat = 0
· END IF
· GOTO MAIN
BlinkLED:
· LEDS = LEDVal
· PAUSE TimeVal
· RETURN
DATA 100, $01, 150, $02, 'etc -- you'll have to input the pattern of LED blinks,
' but it will be WAY shorter than typing in 800 "LED = xxx: PAUSE 100" statements.
Post Edited (allanlane5) : 4/14/2007 7:54:35 PM GMT