Page 1 of 1

Call a macro for time delays

Posted: Tue Jun 25, 2019 6:44 pm
by JLeith
Hello all
I have come it pickle with my Master pitch count. Running into to much code.

I cleaned up old code that was disabled and deleted 2 old macro.

Went from ( -5 ) to (-2), Getting close

I had a old thought if I had several Delays with 10ms I could call say Macro10 that would have the 10ms delay.
Will calling a Macro for Delays save on word count?

Here is my Message
ROM available:16384 words, used:17043 words (102.0%), free:-659 words (-2.0%)

Is there a way in flowcode 6 to see the word count before I send to chip?

John

Re: Call a macro for time delays

Posted: Tue Jun 25, 2019 8:15 pm
by Benj
Hi John,

Maybe try making a new constant, assigning the value 10 and then referencing the constant. If this fails then it's worth a go.

The compile to hex option allows you to compile without programming.

Re: Call a macro for time delays

Posted: Tue Jun 25, 2019 9:31 pm
by JLeith
Hello Benj

Not 100% sure how to use the Constant
Constant.png
(8.03 KiB) Downloaded 1925 times
I can create something that resembles a 2 second timer. But it doesn't look right.

And how to I call it in a 2 second timer ?

In the images the "Macro2s" was a call for 2 second timer.

I have attached my Flowcode 6 design maybe you can spot a cleanup or how to work with Constants. Google doesn't give me much knowledge.

John

Re: Call a macro for time delays

Posted: Wed Jun 26, 2019 9:51 am
by Benj
Hi John,

If you have code like this.

do this
delay_ms(10)
do that
delay_ms(10)
do the other
delay_ms(10)

then you can create a constant with the value 10 e.g. myconst and then the code would look like this.

do this
delay_ms(myconst)
do that
delay_ms(myconst)
do the other
delay_ms(myconst)

I'll have a scan through your program and see if I can spot anything for you.

Some of the variables have initialiser values and then are initialised again in the START macro. Pitch, AlarmH and StopHM to name a few.

Re: Call a macro for time delays

Posted: Wed Jun 26, 2019 12:53 pm
by LeighM
Hi John,
You also have some repeating code that could be replaced with macros,
in particular, in the Keypad macro you have a lot of strings to print on the display that are copies,
maybe you could create PrintHomeMenu and PrintAwayMenu macros.
In fact there is only one string difference between these two, so maybe have a PrintMenu macro that has a menu selection parameter,
then within the macro if selection is 0 print home, or if 1 print away.
I also noticed that in the menu print you have a string print followed by a screen clear.