<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div>
<div>
<div dir="ltr" style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Bezos clock idea</div>
</div>
<div><br>
</div>
<div class="ms-outlook-ios-signature"></div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Michelle Wiboltt &lt;michellewiboltt@outlook.com&gt;<br>
<b>Sent:</b> Sunday, November 15, 2020 8:15:49 PM<br>
<b>To:</b> Talk about Raspberry Pi / embeded projects &lt;projects@vicpimakers.ca&gt;<br>
<b>Subject:</b> Re: [VicPiMakers Projects] Make class out of functions</font>
<div>&nbsp;</div>
</div>
<div>
<div>
<div>
<div dir="ltr" style="color:rgb(0,0,0); background-color:rgb(255,255,255)">\u201cAs yet undetermined\u201d meaning for instance, once attributed say to u mark aka space boy with no \u201cslicing\u201d words/intents but rather leap frogging to/for back/forth , again intent wouldn\u2019t
 this suggest time \U0001f9ed travel? Does this make sense?&nbsp;</div>
<div dir="ltr" style="color:rgb(0,0,0); background-color:rgb(255,255,255)">Further, re: attached clock with no numbers/arms thereby \u201copening\u201d rather than closing time...</div>
</div>
<div><br>
</div>
<div class="x_ms-outlook-ios-signature"></div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Michelle Wiboltt &lt;michellewiboltt@outlook.com&gt;<br>
<b>Sent:</b> Sunday, November 15, 2020 8:11:10 PM<br>
<b>To:</b> Talk about Raspberry Pi / embeded projects &lt;projects@vicpimakers.ca&gt;<br>
<b>Subject:</b> Re: [VicPiMakers Projects] Make class out of functions</font>
<div>&nbsp;</div>
</div>
<div>
<div>
<div>
<div dir="ltr" style="color:rgb(0,0,0); background-color:rgb(255,255,255)">Unsigned / shouldn\u2019t it read \u201cas yet unattributed\u201d&nbsp;</div>
</div>
<div><br>
</div>
<div class="x_x_ms-outlook-ios-signature"></div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Projects &lt;projects-bounces@vicpimakers.ca&gt; on behalf of Mark G. &lt;vpm@palaceofretention.ca&gt;<br>
<b>Sent:</b> Sunday, November 15, 2020 8:08:53 PM<br>
<b>To:</b> projects@vicpimakers.ca &lt;projects@vicpimakers.ca&gt;<br>
<b>Subject:</b> Re: [VicPiMakers Projects] Make class out of functions</font>
<div>&nbsp;</div>
</div>
<div class="x_x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_x_PlainText">Quick update:<br>
<br>
You probably want to add unsigned in front of<br>
all the long ints, or adjust the type as needed<br>
(all over, including&nbsp; the &quot;const&quot; values).<br>
<br>
<br>
On 2020-11-15 7:13 p.m., Mark G. wrote:<br>
&gt; Hi George,<br>
&gt; <br>
&gt; Here's a quick outline of an ActionTimer class.&nbsp; What<br>
&gt; do you make of it?<br>
&gt; <br>
&gt; Mark<br>
&gt; <br>
&gt; <br>
&gt; On 2020-11-15 6:07 p.m., George Bowden wrote:<br>
&gt;&gt; I have two &quot;identical&quot; functions for time slicing&nbsp;the Arduino loop.&nbsp; <br>
&gt;&gt; One function is called to see if it is time to toggle the LED every <br>
&gt;&gt; second, and the other &quot;identical&quot; function is called to see if it is <br>
&gt;&gt; time to send a post to the website every few minutes.&nbsp; These functions <br>
&gt;&gt; seem good candidates for a single C++ class, and I'm looking for some <br>
&gt;&gt; advice,&nbsp;never having coded a class before.&nbsp; Maybe it's a coding <br>
&gt;&gt; challenge? I'm using Arduinos millis() which increments continuously <br>
&gt;&gt; and the modulus of that, with a different period value passed to the <br>
&gt;&gt; functions, to determine when to act.&nbsp; When the modulus remainder is <br>
&gt;&gt; smaller than the last time through the loop, it is time to take <br>
&gt;&gt; action. (the vertical line in the stairs)<br>
&gt;&gt;<br>
&gt;&gt; image.png<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Each instance&nbsp;of the class needs its own static variable for the value <br>
&gt;&gt; of mod'ed millis() last time through the loop.&nbsp; &nbsp;I would like to write <br>
&gt;&gt; a class which I instantiate with NEW for each different period, ....&nbsp; <br>
&gt;&gt; I would like to put these in a library that I could include in any of <br>
&gt;&gt; my projects that need time sliced<br>
&gt;&gt;<br>
&gt;&gt; &nbsp;&nbsp;Here is how I have coded it as functions:<br>
&gt;&gt;<br>
&gt;&gt; unsigned long lastPostMillis=0;&nbsp; // the value of the modulus last time <br>
&gt;&gt; through the loop.<br>
&gt;&gt; unsigned long lastBlinkMillis=0;<br>
&gt;&gt;<br>
&gt;&gt; bool isPostTime(unsigned long int period){<br>
&gt;&gt; &nbsp;&nbsp; if(millis() % period &gt; lastPostMillis) {<br>
&gt;&gt; &nbsp;&nbsp; &nbsp; lastPostMillis = millis()% period;<br>
&gt;&gt; &nbsp;&nbsp; &nbsp; return true;<br>
&gt;&gt; &nbsp;&nbsp; }<br>
&gt;&gt; &nbsp;&nbsp; else {<br>
&gt;&gt; &nbsp;&nbsp; &nbsp; lastPostMillis = millis() % period;<br>
&gt;&gt; &nbsp;&nbsp; &nbsp; return false;<br>
&gt;&gt; &nbsp;&nbsp; }<br>
&gt;&gt; }<br>
&gt;&gt; bool isBlinkTime(unsigned long int period){<br>
&gt;&gt; &nbsp;&nbsp; int blinkPeriod = 500;<br>
&gt;&gt; &nbsp;&nbsp; if(millis() % blinkPeriod &gt; lastBlinkMillis) {<br>
&gt;&gt; &nbsp;&nbsp; &nbsp; lastBlinkMillis = millis()% period;<br>
&gt;&gt; &nbsp;&nbsp; &nbsp; return true;<br>
&gt;&gt; &nbsp;&nbsp; }<br>
&gt;&gt; &nbsp;&nbsp; else {<br>
&gt;&gt; &nbsp;&nbsp; &nbsp; lastBlinkMillis = millis()% period;<br>
&gt;&gt; &nbsp;&nbsp; &nbsp; return false;<br>
&gt;&gt; &nbsp;&nbsp; }<br>
&gt;&gt; }<br>
&gt;&gt; void setup() {...<br>
&gt;&gt; }<br>
&gt;&gt; void loop() {<br>
&gt;&gt; &nbsp;&nbsp; if (isPostTime(minutesBetweenPosts*60000)) { //time to send a Post <br>
&gt;&gt; to the website<br>
&gt;&gt; &nbsp;&nbsp; ...<br>
&gt;&gt; &nbsp;&nbsp; if(isBlinkTime(500)){<br>
&gt;&gt; &nbsp;&nbsp; &nbsp; toggle builtin led}<br>
&gt;&gt; } // end loop<br>
&gt;&gt; -- <br>
&gt;&gt; George Bowden, 250-893-7423<br>
&gt;&gt; gtbowdeng@gmail.com<br>
&gt;&gt; &lt;<a href="mailto:gtbowdeng@gmail.com">mailto:gtbowdeng@gmail.com</a>&gt;<br>
&gt;&gt;<br>
&gt; <br>
<br>
-- <br>
Projects mailing list<br>
Projects@vicpimakers.ca<br>
<a href="https://eur06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvicpimakers.ca%2Fmailman%2Flistinfo%2Fprojects_vicpimakers.ca&amp;amp;data=04%7C01%7C%7C28c17d64771144556b9208d889e57023%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637410965828698810%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=t7JFyoU37YhMIJ7G7vMOMsrs5RK6S3KJwkCPtxEx5hg%3D&amp;amp;reserved=0">https://eur06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvicpimakers.ca%2Fmailman%2Flistinfo%2Fprojects_vicpimakers.ca&amp;amp;data=04%7C01%7C%7C28c17d64771144556b9208d889e57023%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637410965828698810%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=t7JFyoU37YhMIJ7G7vMOMsrs5RK6S3KJwkCPtxEx5hg%3D&amp;amp;reserved=0</a><br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>