Help on button press variable count display routine please

Use this section to discuss your embedded Flowcode projects.
Post Reply
canary_wharfe
Posts: 78
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 11 times

Help on button press variable count display routine please

Post by canary_wharfe »

I’m working on a PIC instrumentation measurement design with Flowcode but I am having difficulty on one aspect where I want the user interface to insert two values (a min and a max) into respective variables using an up button and a down button. The display is a simple 20x2 led panel. As the user presses the up button you see the display counting up with each press of the button from 0 to 100. If the button is held down for more than a second or two it scrolls up faster. The down button does the same except the count on the display is decrementing 100 to 0.

Once the user has the correct value between 0 and 100 in the variable and shown on the display, pressing another button (ENTER) moves the code out of the routine to the next routine in my project. I was toying with the idea instead of using a third button for the ENTER command, to press both of the up and down buttons together. That last bit is really down to whether I have room on the panel for a third button.

The thing is, while I know how to create the rest of the project using Flowcode I am stumped at coming up with a Flowcode algorithm for the button-count-display interface. Does anyone know if something similar has been used as an example on the forum and can they point me to where please? I know the solution will be one of those simple routines where I can't see the wood for the trees.

Alternatively if an advanced user could tell me how they would tackle this I would be grateful. Just the steps they would use would do. But please don’t hit me with any assembler routines or lots of c code examples. I really want to achieve this using flowcode blocks as I am treating the project as a Flowcode learning tutorial.

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Help on button press variable count display routine please

Post by WingNut »

If you put a 3-400ms delay in your switch statement between each option it will slow down the scroll affect and will give you the chance to capture 2 buttons being pressed at the same time instead of having a third button

canary_wharfe
Posts: 78
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 11 times

Re: Help on button press variable count display routine please

Post by canary_wharfe »

WingNut
Thanks for that tip. TBH I'm not too worried about whether to use a third button or not. At this point I just want to solve getting the routine sorted for the up down variable count and display working with both single press increment decrement and holding the buttons for fast incrementing decrementing. If a user needs to enter the value 92 into the max variable they don't want to have to press the up button 92 times. More efficient to hold the button down and fast increment up to say 90, release the button and then just give it 2 more clicks to get it up to 92. The really annoying thing is that 12 years ago I had this routine working brilliantly programmed in PIC Basic Pro. However, due to relocating, the ext. drive with the code went missing in the move so I no longer have the routine I used and I cannot remember how I did it. Sod's law!

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Help on button press variable count display routine please

Post by WingNut »

See the attached as a pointer. I use this to set the hours for a clock. Its limited in the increment to 23 and wont go below 0 so this could be adjusted to 99 easily. The delay in each step can be adjusted to allow a more constant increase/decrease to be readable . Press and hold the relevant button and it will count up or down as fast as the delay allows so you can adjust it to suit. At 100 ms it counts pretty fast
Attachments
3 button menu.fcfx
(13.55 KiB) Downloaded 65 times

canary_wharfe
Posts: 78
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 11 times

Re: Help on button press variable count display routine please

Post by canary_wharfe »

Thanks for that Wingnut. Had a quick look at the chart and I think I might be able to convert that to my application. Looks really promising. Never used the switch icon before so just watched the tutorial on it. Your method looks promising. Much appreciated.

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Help on button press variable count display routine please

Post by WingNut »

No probs. Any questions just ask

Post Reply