Can someone PLEASE HELP??!
Its supposed to count how many times a button has been pressed and do stuff based off it but i cant figure out how exactly it does that based on this code.
My retard teacher totally skimmed the question and gave a non answer and im only seeing him live next thursday i cant not know this till then
My hypothesis:
1.Squared red runs first, stores previousSwitchState = switchState(0 or 1)
2.Squared blue runs when you press the switch again and 1. is no longer true
3.When it does the x condition it equalizes previousSwitchState = switchState and red can thusly no longer run so it just keeps looping blue until condition failure at which point it resets x?
Down to brass tacks; red squared only runs once and it serves to start the looping of blue?
Thanks in advance for your time
>inb4 reddit spacing
its easier to read there i said it
Im white guys please help
>slovenska tipkovnica
ajajaj
How did you figure that from a tiny snippet?
Because it is the only keyboard layout that maps {} to alt gr + BN
Test
post feet
if you're white then you can figure it out yourself. Havent you been keeping up? whiteness is about more than your skin
>some underage gopnik showing its manourished hand is all it took for LULZ to become a homework board
grim
Oooooh yess I like how you are comparing a tiny country with 2 million people to glorious empire of RuZZia which is a superpower running on GaZprom to unite the world against american imperialism, following Xi Jinping thought for socialism with Chinese characteristics for a new era
that's brown
you should clean that keyboard, it's disgusting
go ask chatGPT you retarded slav
> uses memeshit
> it's still wrong
amazing
....chatGPT actually is pretty useful. No longer have to explain things to retards or even respond to them. You can just redirect them to the bot.
What
TEACH ME THIS POWER? Thats gotta be a paid version or sth?
FPBP
Im 24
Its like the 10th post... why are you homosexuals so bitter
Not sure i understand but it works like
When i try it out so if you could tell me how to access that specific AI?
try reading the thread
>Im 24
official documentation or underage b&
I misclicked. this was for
>Already made it in chemistry im trying to major engineering
made it like what? at 24? I bet you only got a degree and feel like you made it in life kek
meanwhile, I don't even have a degree and I got a tech job :^)
anyway, stop spoonfeeding retards, you retards
Youre bitter. Idk where its coming from but its there.
Heres the deal, my chemistry premajor is worth more than your entire life, i have a job that paid for a very nice car and when i major im gonna go into microprocessors and cash in on the race.
You are gonna continue to be a bitter loser, see the difference?
Im in croatia you retard stop trying to be a detective it takes IQ
Never once asked for help debouncing it, only asked for exactly how it works on a fundamental level since its my first touch with coding after i premajored chemistry
>Im in croatia you retard stop trying to be a detective it takes IQ
No you are not. You are a pakistani from university of Manchester and you know it
showed that im white already so uhh try again?
yoo just like me
No, under that lighting the only thing you proved is that you were not black black.
You ... could still be brown. Let alone light brown like somewhere from bangladesh
samo ako je na boci čep
He is lying. He is trying to make himself older online to be taken more seriously, lol.
Trust me, University ends when you are 22, or 23 if you fail. After that there are masters degrees, but UK doesn't have them for example. And surely if he is in masters, he should not have embedded systems only now. These usually come much earlier. Except if his university is utter shit like the one in Manchester
Yes, it is the paid version
the red box is there because the first iteration is a false-positive state change, so when previous is set to the magic value -1 it skips that false-positive. The other way to do it is to set the two values to be equal before the loop starts but then you have to do two reads on the first iteration and maybe you don't want that.
The more intelligent way to do that would be
uint16_t switch_state = readpin(...)
uint16_t pre_state =switch_state
uint 16_t x = 0;
for(;;){
if(pre_state != switch_state) {
...
} else {
...
}
pre_state = switch_state;
switch_state = readpin(...);
This way you don't introduce invalid values and you don't have to run a check for that invalid value for every iteration of the loop.
It is more intelligent. Can you explain what the ; ; in the for mean?
please to to reddit homosexual
Same thing as while(1), but prevents GCC from throwing a warning.
You are very helpful, thank you.
No problem. I remember when I did the physical hardware programming it was a lot of fun.
for (;;) {} is while (1) {}
>for(;;)
Truly the most retarded way to make endless loop. I get physically ill when I see it. Same way when I see someone declaring pointers like "int * x"
>ignorant whining
while(true) char count 11
for(;;) char count 7
K&R literally tells you flat out for(;;) is the correct way.
>muh char count
>muh book
I don't care. it is ugly and naggerclious
>some nobodies opinion
That book was written by the authors of C. I think I'll take their thoughts over some LULZ shitposter.
>Doesn't matter
For is the most explicit. This declares nothing, depends on nothing and increments nothing.
I don't care even if pope wrote it. it is *ugly*. Objectively ugly
>I don't care even if pope wrote it. it is *ugly*. Objectively ugly
LULZ nobody proves he is ignorant by not being able to understand the definition of objective.
>actually, that is not the dictionary definition of "objective"
>barely understands English language
>wants to be an authority of programming languages
>Thinks they know more than the guys who made C, Unix, and who's influence is still felt on the entire industry
>thinks posting a shitty pic will cover up their knowledge gaps
Yeah still sticking with for(;;) as K&R intended.
>If the author writes ugly shit, then it's not ugly!
Would you drink your piss if Ritchie told you so?
>Apples and oranges
You personally view it as ugly. I find the syntax quite pleasant. Trusting someone who is an expert in a certain field on matters of that field is not the same thing as trusting them on everything.
>(;;){{{@@@())(()()()())(
>it's not ugly
>For nothing, until nothing, add nothing
>While true is true do
I don't nigga, you tell me which one makes more sense, you for(;;) fucks should get hanged.
>while(true)
>implying there is a condition
For also implies theres a condition, not only that but an assignment and an increment too. For is worse.
For doesn't imply that because nothing is inside each block.
it does retard because there are still ; inside the (), and it's worse because not only is implying that's, it's also implying that is operating on nothing since there's nothing between the ;. At least the while implicitly tells you infinity, the for just tells you for nothing until nothing do nothing and then do
If you prefer see it this way then
While 1 is 1 do
Which one will always be one
while (true), while(1), for (;;) are all the same it doesn't fucking matter
I don't give a shit what K&R says.
You do "for(;;)" and I think you are a retard of sorts. It's ugly and I have only seen morons use it.
>Can someone PLEASE HELP??!
see
>Tech support threads should be posted to
there are other threads where you could have asked for help...
Kill yourself.
Lmao smart nigga
I have fungi
We had this explained its called bouncing, i knew that but i didnt realize how the code actually worked. Its not 50 tho its about 2 3
>I have fungi
delicious
>I have fungi
I believe you.
calcium defficiency on my fingers tells you i have fungus on my toes?
Yes, you have to deal with that somehow. I forgot how, it's been years since I had that
Probably somehow have it recognize everything from 1.65 to 3.3V as high and everything from 0 to 1.65V as low instead of having that area of ambiguity so that bouncing doesnt affect high/low state detection
Afaik, you have to sleep every time you check a pin or something. So use that HAL_Delay()
Whites also help each other. Meanwhile pajeets such as yourself are highly selfish and only think about how helping will hurt them in the rat race
BASE
Cringe
pajeets go to someone for help, hope they do all the work, and answer like this
when they don't have a clue what the other guy is talking about.
Whites are able to ask clear and concise questions, and know the exact information they want in response. Which one are you?
>rat race
PLEASE go back
Have i not posted my skin color..
whites answer and help, pajeets whine. Simple as.
>>rat race
>PLEASE go back
yes, anti antisemitism is not tolerated here
Who is making you do this? Highschool? University? FAMNIT, FRI, FERI, SCNG, FE?
Do what? Im studying for university
Nigga code is not something whites inherently get, its politics, art, social stuff AND techincal stuff equally. Were supposed to know a bit of everything.
Your university is shit if they use eclipse and teach C. What is this, 2005?
in STM32 which is what you have, the button press doesn't work like you think it works due to electromagnetic properties on low level. When you press a button, and hold it, it's state will vary between 0 and 1 for about 5 miliseconds before ending up on 1. so your code will, from one button press assume that 50 button presses happened
>people still respond in a literal tech support thread to a tech illiterate retard that wants to be spoonfed
sad state of this sub
shut the fuck up redditor fag. This isn't reddit where you could downvote a question to get it out of the front page. Here we answer!
>tech illiterate
Youre being an uppity nagger and a homosexual and should kill yourself.
>doesn't know what for (;;) does
>noo I'm not tech illiterate!
HAHAHAHAHAHAHA
go back, you retarded zoomer
Hey everybody this homosexual
Never heard of a begginer getting his first coding lessons with embedded systems
then ask your teacher homosexual
Read the thread
Already made it in chemistry im trying to major engineering
Im hooking shit up and trying it every single day for 2 weeks now.
>24 years old
1. this is not a tech support forum
2. you are not gonna make it anyway
3. I WILL gatekeep technology, and there is nothing you can do about it
Actually, he is in university, so probably he is 20
yeah yeah you think you can learn embedded systems but you are probably only working on thursdays from 2 to 4 pm and think that's enough. I bet you it's exactly like that, we get a lot of students like this. Completely bewildered when they see a real problem. Completely. Bewildered.
apparently im a pajeet israelite for claiming this. the naggers gotta congregate somewhere I guess.
>apparently im a pajeet israelite for claiming this
Yes.
>real thread happens
>REEEEE
you would honestly rather have 15 AI slop threads, 10 coombait threads, and 10 variations of "should I X or Y"
two wrongs don't make a right, retard.
you could always tell them to google shit.
this is how tech is supposed to be: you get taught basic concepts at uni (if that), then as a job you google shit you don't understand, and ask other people only if you couldn't find shit
the retarded OP has a teacher who is being paid. it's not our problem that his teacher was useless
You should install an interrupt handler. Busylooping is more fragile, wastes energy, and is for homosexuals and low IQs
No, I am his _____, he has to do busylooping for his first practicum, because we haven't taken interrupts. You have to know, these retards have only ever learned Java, if he took C course, he probably failed it, it has 80% fail rate
my god. a 24 year old CS university student needs help debouncing a button. what the fuck happened, man.
Actually, you don't know how to do it either
learn how to use a code formatter ffs
Are you still here OP? has it been answered already?
I get it and its pretty simple actually.
I stopped reading the code when there was no indentation on lines inside if/else blocks and there was one if with no brackets and no intonation to make it confusing to read.
Yeah thats true, wtf with his teacher call him a nagger next time you see him op
Once you start reading code made by chinks you get used to that kind of programming style, its a god forsaken sin but once you get used to it becomes somewhat clear
I figured it out at the chatGPT answer
saving this.. thanks a lot friendo
save this one instead, there's a correction
I did but care to tell me how the hell you deleted your post?
phone or desktop?
On desktop theres literally a button that says delete at the bottom of the page, dont ask the first thing that comes to mind bro
>that ad
LMAOO click it
I did and I regret it.
God I love it lmaooo
Once I get home ill search it and post results just to have a laugh
ty
If youre using the browser should be the same, on an apk it depends on your client but it should be part of the post's options.
For instance on kuroba dev you hold the post and tap on the remove option from the popup menu
Fucking amazing.
You can delete posts on LULZ? Literally learnt this today ive been here since 2020
>since 2020
id tell you to go back but since youre chill ill call you a fag instead, newfag
Get used to exploring every tiny bit of an UI or else youll get fucked in life, not because you cant use an UI but because learning on your own to use a tool teaches you how to learn, one of the most important skills in life. Answers from everyone else are neat but you cant always ask someone for those
Genuinely thanks man
> while (1)
> read pin 8
> if pin8 changed
> x++
> if x<20
> write pin 6
> write pin 7
> else
> write pin 7
> write pin 6
> x = 0
red square is kind of unnecessary, and it keeps writing the same values to pins 19 or 20 times so you wont see any leds blinking per press
button states also change twice per press, low->high and high->low again
It can also just increment x on switch state and do a seperate if for x count (or not)
> lol, it already does
readSwitch();
if (switchstate){
x++;
if (x==20){
writepin 7,6
x=0;
}
if (x==1){
writepin 6,7
}
}
Yeah i asked him this and he said
"Respectfully
My code records the amount of times a switch changes state, what you wrote only checks if its currently in a high state
Regards"
actually i think it writes to pins every loop
3 second delay will probably do
>3 second delay will probably do
why not just do what the slav suggest?
you won't need a delay thanks to cap or is this strictly a software solution?
debouncing is just going to use a delay anyway
>debouncing is just going to use a delay anyway
>what the fuck is a capacitor
Yes sir, 3 sec is more than enough now that I think about it
i guess it should debounce more than just the 20th press though
Delay is 50 miliseconds retard. 3 sec is waaaay too much
>anons using delay in debouncing
do it right and use a timer, you degenerates.
>use a timer so your single-function program can do other useful stuff while it's waiting
If we are talking about the proper way, you should use an interrupt anyway but we are not
it is a debouncer state machine.
It is a way to discriminate electrical noise from a real button. That code is the most retarded way to implement it.
you need an enum with 4 states:
UP, FALLING, DOWN and RISING
and you need a timed event in the FALLING and RISING states (20ms),
typedef enum ButtonState {UP, FALLING, DOWN, RISING } ButtonState_t;
typedef struct Button {
uint pin;
ButtonState_t state;
} Button_t
void Button_update(Button_t *button) {
switch(button->state) {
case UP:
// read the pin and update FSM
break;
case FALLING:
// read the pin and update FSM
// if transition to DOWN, the button was pressed
// do something
break;
// ... do your homework homosexual
}
}
int main() {
Button_t button = {.pin=1, .state=UP};
while(true) {
Button_update(&button);
someWaitFunction(20); //ms
}
}
This is the most complicated thing ive ever seen for just some LEDs blinking based on the amount a butzon was pressed. Bouncing is solved in the STM32 project settings so you can keep this atrocity for yourself.
nagger JUST USE A CAPACITOR ACROSS THE SWITCH
>t. superior pole
>t. no one here knows shit about even the simplest stuff like denouncing
kek I feel for OP
I am denouncing you mispelling of debouncing.
Fuck I wrote you instead of your.
Well I guess I'll go kms.
Have you ever heard of debouncing?
> tfw x++ not indented properly
If you don't understand this and youre a CS major its unironically over
why would a gpio state be -1
i'm not even a programmer but i can see immediately that it constantly checks the state of the button, and when the state changes, it increments the variable "x", which there's an if statement that checks if x is below 20, and an else when it isn't (so when it hits 20), where x is reset back to 0
i literally can't write a X hello world without looking up the syntax and i can understand what this does just from the basic shell scripting knowledge i have
C* hello world
I can immediately see youre a midwit and likely a virgin but like in the OP i posted im interested in the specifics of it and not whats immediately apparent