[VicPiMakers Projects] Make class out of functions
Michelle Wiboltt
michellewiboltt at outlook.com
Sun Nov 15 20:15:49 PST 2020
“As yet undetermined” meaning for instance, once attributed say to u mark aka space boy with no “slicing” words/intents but rather leap frogging to/for back/forth , again intent wouldn’t this suggest time 🧭 travel? Does this make sense?
Further, re: attached clock with no numbers/arms thereby “opening” rather than closing time...
________________________________
From: Michelle Wiboltt <michellewiboltt at outlook.com>
Sent: Sunday, November 15, 2020 8:11:10 PM
To: Talk about Raspberry Pi / embeded projects <projects at vicpimakers.ca>
Subject: Re: [VicPiMakers Projects] Make class out of functions
Unsigned / shouldn’t it read “as yet unattributed”
________________________________
From: Projects <projects-bounces at vicpimakers.ca> on behalf of Mark G. <vpm at palaceofretention.ca>
Sent: Sunday, November 15, 2020 8:08:53 PM
To: projects at vicpimakers.ca <projects at vicpimakers.ca>
Subject: Re: [VicPiMakers Projects] Make class out of functions
Quick update:
You probably want to add unsigned in front of
all the long ints, or adjust the type as needed
(all over, including the "const" values).
On 2020-11-15 7:13 p.m., Mark G. wrote:
> Hi George,
>
> Here's a quick outline of an ActionTimer class. What
> do you make of it?
>
> Mark
>
>
> On 2020-11-15 6:07 p.m., George Bowden wrote:
>> I have two "identical" functions for time slicing the Arduino loop.
>> One function is called to see if it is time to toggle the LED every
>> second, and the other "identical" function is called to see if it is
>> time to send a post to the website every few minutes. These functions
>> seem good candidates for a single C++ class, and I'm looking for some
>> advice, never having coded a class before. Maybe it's a coding
>> challenge? I'm using Arduinos millis() which increments continuously
>> and the modulus of that, with a different period value passed to the
>> functions, to determine when to act. When the modulus remainder is
>> smaller than the last time through the loop, it is time to take
>> action. (the vertical line in the stairs)
>>
>> image.png
>>
>>
>>
>> Each instance of the class needs its own static variable for the value
>> of mod'ed millis() last time through the loop. I would like to write
>> a class which I instantiate with NEW for each different period, ....
>> I would like to put these in a library that I could include in any of
>> my projects that need time sliced
>>
>> Here is how I have coded it as functions:
>>
>> unsigned long lastPostMillis=0; // the value of the modulus last time
>> through the loop.
>> unsigned long lastBlinkMillis=0;
>>
>> bool isPostTime(unsigned long int period){
>> if(millis() % period > lastPostMillis) {
>> lastPostMillis = millis()% period;
>> return true;
>> }
>> else {
>> lastPostMillis = millis() % period;
>> return false;
>> }
>> }
>> bool isBlinkTime(unsigned long int period){
>> int blinkPeriod = 500;
>> if(millis() % blinkPeriod > lastBlinkMillis) {
>> lastBlinkMillis = millis()% period;
>> return true;
>> }
>> else {
>> lastBlinkMillis = millis()% period;
>> return false;
>> }
>> }
>> void setup() {...
>> }
>> void loop() {
>> if (isPostTime(minutesBetweenPosts*60000)) { //time to send a Post
>> to the website
>> ...
>> if(isBlinkTime(500)){
>> toggle builtin led}
>> } // end loop
>> --
>> George Bowden, 250-893-7423
>> gtbowdeng at gmail.com
>> <mailto:gtbowdeng at gmail.com>
>>
>
--
Projects mailing list
Projects at vicpimakers.ca
https://eur06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvicpimakers.ca%2Fmailman%2Flistinfo%2Fprojects_vicpimakers.ca&data=04%7C01%7C%7C28c17d64771144556b9208d889e57023%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637410965828698810%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=t7JFyoU37YhMIJ7G7vMOMsrs5RK6S3KJwkCPtxEx5hg%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://vicpimakers.ca/pipermail/projects_vicpimakers.ca/attachments/20201116/ba45edbf/attachment.htm>
More information about the Projects
mailing list