Display manager!

For general Flowcode discussion that does not belong in the other sections.
Post Reply
jgu1
Posts: 904
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 797 times
Been thanked: 197 times

Flowcode v11 Display manager!

Post by jgu1 »

Hi!

I am practicing with the "Display Manager" based on the examble´s, and I am starting to understand how it works. :lol:

When I change Scene (DC_Touched), I would like to stay in that scene and “do something” — remain inside a loop, use counters, sensors, etc., and read values. That part works.
However, I would like to be able to exit the loop again when I press “Switch to Scene0" botton (DC_RoundedRect2)”. The way I have made it now, it jumps back immediately without pressing.

I hope someone can tell me which command I should use inside the loop so it exits correctly.

Thank you in advance!
Attachments
DisplayCreatorSelf1.fcfx
(37.76 KiB) Downloaded 69 times

Steve-Matrix
Matrix Staff
Posts: 1774
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 258 times
Been thanked: 414 times

Re: Display manager!

Post by Steve-Matrix »

I've not looked at your project, but the "Switch to Scene0" button should call a macro. In that macro you could change the value of a global variable (e.g. ExitTheLoop = true) and continually check that variable within your loop and react accordingly. That should allow you to leave the loop when that button is pressed.

BenR
Matrix Staff
Posts: 2138
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 577 times
Been thanked: 761 times

Re: Display manager!

Post by BenR »

It looks like you are using the DC_Touched macro to block with a loop but this is probably not ideal as you essentially stop any future touches from being actioned while you are blocking here.

I've added a new macro to the DisplayManager called GetSceneIdx which returns the current scene index. You can call this in your main and then if idx is 1 you can do your incrementing there while still allowing other touches to be detected.

BenR
Matrix Staff
Posts: 2138
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 577 times
Been thanked: 761 times

Re: Display manager!

Post by BenR »

I'm not fully sure what you're trying to do but I have modified your program slightly so that you can start a count, and stop the count again or when the count reaches 20 it will automatically stop and return to scene 0.

Hopefully highlights things a bit better.
DisplayCreatorSelf1.fcfx
(37.34 KiB) Downloaded 40 times

To move things further I would maybe have a prescale counter and use this to count up so you can reduce the main loop delay from 200ms to say 10ms and ensure touch stays nice and responsive. I can change the example to do this if that would help.

jgu1
Posts: 904
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 797 times
Been thanked: 197 times

Flowcode v11 Re: Display manager!

Post by jgu1 »

Hi Steve and Ben!

Thank´s for fast reply.

My English is probably not very good, so my explanation may not be easy to understand :lol: .

What I want is to be able to choose a Scene, for example a voltmeter, and then it should stay in that scene until I select Scene 0 again, go back.

I have a “basic” example (attached) saved that I use as a starting point for a new project, made in my own way, to heavy. If you run the simulation and press voltmeter, it switches to the voltmeter and stays there, showing the variable. In other words, it remains in that loop until I press "Menu" again and can choose another menu.

That is how I would like to implement it using Display Manager. Hope it make sense ;)

** I see many advantages in using Display Manager and would like to use it.**

Thank´s in advance
Attachments
Test_Perfekt_Egen_Old_Fashion_StandardV2.fcfx
(55.77 KiB) Downloaded 39 times

BenR
Matrix Staff
Posts: 2138
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 577 times
Been thanked: 761 times

Re: Display manager!

Post by BenR »

Right I've tweaked the example a bit to have a main menu on scene 0 and a basic voltmeter on scene 1.

All of the button touches are processed by the DC_Touched callback macro.

Any additional scene processing e.g. the volt meter updates are done as part of the main loop.

The display should update every 200ms but the touch should be responded to within 10ms making it nice and responsive.

DisplayCreatorSelf2.fcfx
(41.16 KiB) Downloaded 39 times

jgu1
Posts: 904
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 797 times
Been thanked: 197 times

Flowcode v11 Re: Display manager!

Post by jgu1 »

Hi Ben!
Thank´s.
See what you mean with your examble. Vhen I press "Voltmeter" in main Sceneo It shift to
Scene1, but emediately it jump back to Scene0 again, in simulation and also
in "real world on the display. Just like the IF function don´t care the command?

Br Jorgen

BenR
Matrix Staff
Posts: 2138
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 577 times
Been thanked: 761 times

Re: Display manager!

Post by BenR »

Aha sorry the decisions in the DC_Touched were not checking against the .Handle variable and so were always true.

They should have looked like this.
Screenshot 2026-03-04 104748.png
Screenshot 2026-03-04 104748.png (10.51 KiB) Viewed 122 times
Should be fixed now.
DisplayCreatorSelf2.fcfx
(41.43 KiB) Downloaded 27 times

jgu1
Posts: 904
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 797 times
Been thanked: 197 times

Flowcode v11 Re: Display manager!

Post by jgu1 »

Hi Ben!

No sorry

Perfect :D

Many many thank´s, now it work, why have I overseen this. Now I can take next step and continue. As I mention, there are many advantages with Disp.manager.

Jorgen

Post Reply