|
my last button implementation works okay, but it can sometimes report events out of order because it doesn't actually queue events. In the case of a click followed by a long click, the long click will be reported first if they're close enough together. This may work for simple UI scenarios, but nothing polished.
so what i did was i made the button (optionally) interrupt based. on the interrupt it logs a timestamp and whether the button was pressed or depressed into a circular buffer.
the idea then is when you call update() next (the cooperatively threaded "pump" method) it will parse the contents of that circular buffer and fire callbacks as necessary.
It seems simple, but long clicks, and multi-clicks, plus the case where you hold the button down on startup complicate things.
parsing button clicks reminds me of parsing the contents of [] brackets in regex, esp since you could do stuff like [[[:alpha:]]-a-z]
all this for a button. seems simple, right?
To err is human. Fortune favors the monsters.
|
|
|
|
|
Like Morse code with an always live button.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Input buffers can be bears. The regex comparison is interesting.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
The actual buffering part is pretty easy. The trick is parsing what I put in there. Basically each event (button down, or button up) has a timestamp associated with it, and the idea is to compute deltas between them for multi-click events or long presses. That's part of it, but there also the corner cases I alluded to.
To err is human. Fortune favors the monsters.
|
|
|
|
|
Understood.
Buttons and switches can be tricky for the user.
Once we did a UI study on the states of a switch or button. Physical toggle switches with labels are preferred (old style used in aircraft). But they are expensive and heavy so many control panels use lights and labels. Red light ON means OFF, green light ON means ON. But when they are both on confuses folks. If one does not have colored lights, OFF labeled light ON means OFF? ON labeled light ON means ON. Stuff like that. You would be surprised how many people get these things reversed. Anyway, I digress.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
honey the codewitch wrote: whether the button was pressed or depressed I think your rants are pressing it, making it depressed, or at least burnt out
|
|
|
|
|
I have a MS Outlook email address which I use for non-CodeProject stuff. Today when I logged in to my account I noticed there was a message in the junk folder. Wondering what spam was in there, I took a look, and discovered it was from Microsoft themselves. 
|
|
|
|
|
Well, it was the right place to put it!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
So, I am diabetic and I recently started using the Omnipod 5 Insulin pump (automated delivery system) with the Dexcom G6 sensor. The Dexcom sensor app is on my iPhone. However the Omnipod 5 controller is its own cellphone device, dedicated, runs on Android (no iPhone apps yet). - both my sensor and pump communicate with their associated apps via Bluetooth.
Yesterday my insulin pump controller updated its running software and started acting really weird. Screens were not showing correctly, lots of delays between user actions, and generally it was bonkers. I started to freak out a little, because if the controller fails then I would need to go back to making manual injections which is a hassle.
Then, I thought, reboot. Just reboot. Sure enough, after the reboot, all is well.
modified 8-Dec-22 9:17am.
|
|
|
|
|
Perhaps the cure for all our performance problems is also a reboot.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
That would be so nice if humans could some how reboot, possibly even get system upgrades from time to time.
Every now and then I even feel like a good system wipe and re-install would be in order. 
|
|
|
|
|
It takes a person of the opposite sex and nine months of waiting time.
|
|
|
|
|
That's not a reboot, that's a new version
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Slacker007 wrote: possibly even get system upgrades from time to time We're like the iPhone updates, getting slower every year
|
|
|
|
|
On a side note, I'm also diabetic, aged 57 years. In March 2021, got diagnosed with diabetes, where my HbA1C was 12.4 and post prandial glucose level was 504. Severely diabetic (Type 2), such that my wife got me admitted to a hospital for a week. After discharge, had to take three insulin injections per day. At that time, started a yoga regimen, daily for about 45 minutes, with yogic postures specifically targeted towards pancreas activation; and also strict diet control. Consulted with a diabetes clinic, who recommended some other medicines, and asked me to monitor my glucose levels daily. In three months, my HbA1C got reduced to 6.9, so the doctor stopped the insulin injections, and put me on oral medicine.
Now, I continue my daily yoga regimen, along with the doctor's medicine, and my HbA1C levels hover around 6.9 - 7.2. Sometimes, I eat some sweets served in functions like marriages, etc., so the diet control is not strictly as the dietician says.
As a fellow-diabetes-patient, I recommend a yoga regimen under a qualified instructor, along with regular oral medication, so as to eliminate the necessity of an insulin pump within about 3 months, or max 6 months.
|
|
|
|
|
So, glad to hear you get your glucose levels under control.
I'm glad yoga is working for you and your diabetes situation. I am going to stick with my gadget; for now, they seem so much more fun then exercise. 
|
|
|
|
|
Amarnath S wrote: As a fellow-diabetes-patient, I recommend a yoga regimen under a qualified instructor, along with regular oral medication, so as to eliminate the necessity of an insulin pump within about 3 months, or max 6 months. Decent advice for Type 2 diabetes, less so for Type 1.
*I have Type 2 diabetes as well. Diagnosed about 14 years ago with an A1C of 8.7 and fasting BG of 220+. Drastically reduced my carb intake and added some moderate exercise to lose almost 90lbs (~40kg / 6.5 stone). A1C is now routinely ~6.2 with fasting BG of 130.
|
|
|
|
|
Weight loss is key - I was diagnosed as early type II diabetic. I crash-dieted down from 96kgs to 72kgs. It went away, and now I maintain my weight between 70 and 72kgs, with A1C between 5.4 and 5.9.
As you say, carbs are the killer, and the more refined they are, the worse they are. I now bake my own 100% whole wheat bread, leavened and unleavened, as pretty much my only carb. As a side note, it is also the lowest carbon footprint carb you can eat, with rice as the highest.
|
|
|
|
|
Another wordle spin-off for those that like movies...
Cine2Nerdle
Just a heads up, you have a limited number of swaps you can do. Caught me out on the first day of playing.
|
|
|
|
|
Some of you may know the gory details of how Windows goes about doing it's update thing. My new laptop has decided it wants 22H2. So, I'm working on the older laptop, and I told it to go ahead. 30 minutes later, it's been downloaded, but it's been sitting at 100% for the past 20 minutes. No CPU or network processing is going on.
So, is it doing some sort of integrity check? Just curious.
Charlie Gilley
“Life is short, and it's uncertain." --Brian Schull, Sled driver
modified 8-Dec-22 7:35am.
|
|
|
|
|
Microsoft seems to like to stick their progress bars at 99% or 100% for forever and a day, in my experience. It's probably summoning demons.
To err is human. Fortune favors the monsters.
|
|
|
|
|
<rant>
Considering Microsoft's rigorous quality assurance, I am certain that their code causes nasal demons to appear even on ordinary computers, to say nothing of the DeathStation 9000.
</rant>
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
I'm pretty sure that the DS9K is just a normal PC running Linux.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Not a rant: I suggest YAAR.
Yet another almost rant.
Anyhow, this is superstition terrain, anyhow testing your stability and rationality to the utmost.
First advice: Don't keep looking at it, go do something else. I usually find that I have a chore left or need coffee.
Did it finish yet? Did you shake it a bit, stroke it with the mouse? Hit the control key a few times?
I generally take updates up front, which gives me a weird sense of control.
With the obvious weekly backup I feel like when I stow a small umbrella going when it's not even raining.
Will surely prevent rain from happening to me! (Does most of the time, too)
Cheers,
Jan
|
|
|
|
|
|