In loop I have following code;
I like to stay inside muFunction as long as ON (button_Set_Up_State=0;)
and exit from muFunction when is OFF ( button_Set_Up_State = 1;)
Can I do that with no interrupts?
Thx in advance
Your snipped does not show that function, so who can tell how to help you? Change the function to do the same test and not return until the conditions are right.
I'm pretty sure that you don't want to stay inside function myFunction()
because then you are locked and you will have to add extra-code to leave myFunction() again.
and additionally no other code will be executed. Sooner or later you want other code be executed in parallel to myFunction().
Making a code execute a part of the code and still be able to react on any kind of userinput or whatever sensor signals can be done by using a software-technique called state-machine with using the switch-case-break-statement. Especcially the "break" is important
So far you have just posted some detail but not your final purpose that you use the
"stay inside myFunction()-thing"
As soon as you post this final purpose much better suited suggestions can be made.
Thx to all for respond.
Bellow is myFunction code called rottaryDays();
This function is used to change output1FrequencyInDays. I like to stay in this function as long as I finish set up output1FrequencyInDays. I use rotary encoder with switch. When I press the switch
I like to live this function and execute rest of main loop code. So I use in main loop code switch
and when button_Set_Up_State = 1 I will be inside myFunction, and when pressed again button_Set_Up_State = 0 I like to exit from myfunction.
My problem is that I can see changes of button_Set_Up_State from inside myFunction.
I hope it was clear to undertstand.
Thx in advance again
The programming technique of state-machines enables both:
giving a functionality like "staying inside a certain function"
and
at the same time
reacting on whatever might be nescessary
Best thing would be if you would give an overview about the complete project and posting your complete sketch.
No I do not understand why seeing a change of a variable is a problem.
If your english-knowledge is limited
write a very detailed description in your native language and let do google -translate the translation.
If you have doubts if this works make this experiment:
translate your native language into finish
translate the finish into chinese
translate the chinese to english
translate the english back into your native language
My personal experience with such experiments is:
Some words have changed but the sense is still clear understandable
Thank Stefan, very much, for your tip. I will try it. But from my experience, translation from polish - my native language - to any language, with not west slavic language roots, is very problematic. BTW - base on your name, I guess that you have polish background also.
As an excuse, I have to add, that I'm 74 years old and arduino, and programming, is my hobby for less than three years, but I'm in Canada since 1990 and I'm retired mechanical engineer.
Best Regards
Adam
So here is the test:
I have written a text in german then translated it to urdu!
click to open
میں اب اسے آزمانے جا رہا ہوں۔ میں یہ تحریر پہلے جرمن زبان میں لکھ رہا ہوں۔
ایک پروگرامنگ تکنیک ہے جسے نان بلاکنگ ٹائمنگ کہتے ہیں۔
غیر مسدود کرنے کا وقت تاخیر () سے بہت مختلف طریقے سے کام کرتا ہے۔
تاخیر کے ساتھ، مائیکرو پروسیسر انتظار کے وقت کے لیے منجمد ہو جاتا ہے۔ لہذا دوسرے کوڈ پر عمل درآمد ممکن نہیں ہے۔
نان بلاکنگ ٹائمنگ شروع کے وقت اور موجودہ وقت کے درمیان بار بار وقت کا موازنہ کرتی ہے۔ ایک عمل صرف اس صورت میں شروع ہوتا ہے جب آغاز کے وقت سے ایک مخصوص وقت کا وقفہ گزر چکا ہو۔
کسی پروگرام کو صرف مخصوص حالات میں پروگرام کے ایک مخصوص حصے پر عمل کرنے کے لیے، آپ نام نہاد سٹیٹ مشین استعمال کر سکتے ہیں۔
یہ آپ کو دو چیزیں حاصل کرنے کی اجازت دیتا ہے:
جو کام ہمیشہ کرنے چاہئیں وہ ہمیشہ ہو جاتے ہیں۔ مثال کے طور پر، کسی سوئچ یا بٹن سے استفسار کرنا۔ اور دوسری چیزیں جو صرف مخصوص شرائط کے تحت کی جانی چاہئیں وہ صرف ان شرائط کے تحت کی جائیں گی۔
then I translated the urdu to islandic
click to open
Ég ætla að prófa það núna. Ég skrifa þessa grein fyrst á þýsku.
Það er til forritunartækni sem kallast óblokkandi tímasetning.
Opnunartíminn virkar allt öðruvísi en delay().
Með töf frýs örgjörvinn í biðtíma. Svo önnur kóðaframkvæmd er ekki möguleg.
Tímasetning án lokunar ber endurtekið saman tímann á milli upphafstíma og núverandi tíma. Ferli hefst aðeins ef tiltekið tímabil er liðið frá upphafstíma.
Til að láta forrit keyra aðeins ákveðinn hluta af forritinu við ákveðnar aðstæður er hægt að nota svokallaða ástandsvél.
Þetta gerir þér kleift að ná tvennu:
Hlutir sem alltaf ætti að gera verða alltaf gerðir. Til dæmis að spyrja um rofa eða hnapp. Og annað sem aðeins ætti að gera við ákveðnar aðstæður skal aðeins gert við þær aðstæður.
then I translated the islandic to english
click to open
I'm going to try it now. I am writing this article first in German.
There is a programming technique called non-blocking scheduling.
The open timer works very differently than delay().
With a delay, the processor freezes during the waiting period. So another code execution is not possible.
Non-blocking timing iteratively compares the time between the start time and the current time. A process starts only if a certain period of time has passed since the start time.
To make a program run only a certain part of the program under certain conditions, a so-called state machine can be used.
This allows you to achieve two things:
Things that should always be done will always be done. For example asking about a switch or a button. And other things that should only be done under certain circumstances should only be done under those circumstances.
and finally I translated to englisch to polish
I don't know a single word in polish
I only like Kinga Glyk which is a fantastic jazz funk bass-player
but this is the translattion to polish
Spróbuję teraz. Piszę ten artykuł najpierw w języku niemieckim.
Istnieje technika programowania zwana planowaniem nieblokującym.
Zegar otwarcia działa zupełnie inaczej niż funkcja opóźnienia().
Z opóźnieniem procesor zawiesza się w okresie oczekiwania. Zatem wykonanie innego kodu nie jest możliwe.
Pomiar czasu nieblokującego iteracyjnie porównuje czas pomiędzy czasem rozpoczęcia a czasem bieżącym. Proces rozpoczyna się tylko wtedy, gdy od czasu rozpoczęcia minął określony czas.
Aby program uruchamiał tylko określoną jego część w określonych warunkach, można zastosować tak zwaną maszynę stanów.
Dzięki temu możesz osiągnąć dwie rzeczy:
Rzeczy, które zawsze powinny być zrobione, zawsze zostaną zrobione. Na przykład pytanie o przełącznik lub przycisk. Inne rzeczy, które należy robić tylko w określonych okolicznościach, należy robić tylko w tych okolicznościach.
I'm very sure that it is easy for you to understand what has gone through four google-translations
Kinga Glyk live and funkyyyy