(deleted)
Also (oddly) here
@histy_olfhas - your duplicate topic has been deleted
Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting will result in a timeout from the forum.
In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
How are the buttons wired to the inputs ?
Hi.
Ask your questions in the appropriate section to get to the point answers sooner.
Now i had to compose this message twice, because while doing that the 1st time, the thread was erased.
static int hourRec; //hour
void ajusteHour()
{
...
...
hourRec=hourRec+1;
...
}
Static does not create a global variable (click !)
Reading information like that multiple times might help you grasp the information it is trying to convey (you seem to be a francophone, so a non native English speaking person, which makes the need to read at least twice more likely (i'm a non native English speaking person too)).
Either way, they work, only inside the function they don't.
In which function don't they work?
Is P3 already LOW while you enter that function ?
The function only notes the state of P3 once and the only delay between entering the function and making note of the state of P3, is the time for the LCD to get cleared (which is significant to CPU timing, but goes unnoticed to the human's eye and / or brain).
- Function changes hourRec value and in the end it will be passed to the RTC module.
No, that is not what happens in that function.
The function checks whether P3 is LOW, and only under that condition it will change hourRec.
So if you want the change to happen every time you enter that function, you'd have to make sure P3 is LOW.
Or make the action unconditional.
histy_olfhas:
P3 is not low when the function is called, the operation is as follows:
Program starts menu == 0, shows time and next alarm (not implemented yet).
P1 is pressed, enter the menu, menu now == 1.
P3 increases the menu and P4 decreases the menu, so menu = menu+1 ou menu=menu-1.
P2 is pressed, checks the menu value and enters the switch, menu == 1 then case1, calls the function.
Sounds reasonable
- Function changes hourRec value and in the end it will be passed to the RTC module.
No, I don't think so, because P3 is not current pressed, P2 is, so it doesn't change hourRec.
If P3 was pressed and held down for 0.3s or more and then you press P2 it might change the
variable, but that seems unlikely to be the intended function.
BTW static at top-level means the variable is global extent, file-local scope. static inside a function
means the variable is global in extent, function-local in scope.
top level variables that aren't static are global in both scope and extent. So static variables are all
global in some sense, though not all senses. Scope v. extent is an important distinction for variables
as they are not necessarily coupled.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.