Call a macro for time delays

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

User avatar
JLeith
Posts: 519
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 24 times
Contact:

Call a macro for time delays

Postby JLeith » Tue Jun 25, 2019 6:44 pm

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

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4079 times
Contact:

Re: Call a macro for time delays

Postby Benj » Tue Jun 25, 2019 8:15 pm

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.
These users thanked the author Benj for the post:
JLeith (Tue Jun 25, 2019 9:23 pm)
Rating: 5.56%
 

User avatar
JLeith
Posts: 519
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 24 times
Contact:

Re: Call a macro for time delays

Postby JLeith » Tue Jun 25, 2019 9:31 pm

Hello Benj

Not 100% sure how to use the Constant

Constant.png
Constant.png (8.03 KiB) Viewed 413 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
Attachments
Pitcher Master June 19.fcfx
(337.62 KiB) Downloaded 19 times

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4079 times
Contact:

Re: Call a macro for time delays

Postby Benj » Wed Jun 26, 2019 9:51 am

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.
These users thanked the author Benj for the post:
JLeith (Wed Jun 26, 2019 7:23 pm)
Rating: 5.56%
 

User avatar
LeighM
Matrix Staff
Posts: 1844
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 429 times
Been thanked: 612 times
Contact:

Re: Call a macro for time delays

Postby LeighM » Wed Jun 26, 2019 12:53 pm

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.
These users thanked the author LeighM for the post:
JLeith (Wed Jun 26, 2019 7:22 pm)
Rating: 5.56%