[TriEmbed] ESP8266 Programming tip

Michael Monaghan mike at chipworks.net
Tue Jan 26 12:52:57 CST 2021


My cat feeder is based on this concept.  All the time critical tasks (as
defined by cats) are handled in Timer Callbacks (micropython's version).
They are much more accurate than the RTC since they are based on processor
ticks.  As a bonus, the web server runs on the main thread and I can ^C out
to Repl without harm.  The feeder keeps running. even while I'm debugging.

The cats appreciate this implementation.

Mike

On Tue, Jan 26, 2021 at 1:35 PM Carl Nobile via TriEmbed <
triembed at triembed.org> wrote:

> John,
>
> So I assume you need a delay there, so what you can do is use an interrupt
> in your delay. Then the delay is managed between all other interrupts.
>
> I found this simple example of using an interrupt as a delay. It' uses an
> Arduino, but the concept may help.
> https://thekurks.net/blog/2016/4/25/using-interrupts
>
> ~Carl
>
> On Tue, Jan 26, 2021 at 1:22 PM John Vaughters via TriEmbed <
> triembed at triembed.org> wrote:
>
>> Carl,
>>
>> Right, makes sense, I really use delays sparingly and go for millis() But
>> this was a copy-paste task. and it was only 25ms of delay, so I let it
>> slide. And considering I am probably only using like 10% of computing power
>> I thought I could let it slide. And I could have if it wasn't for you
>> meddling programmers. `,~)
>>
>> Normally I only use a short delay at the end of the loop if the loop is
>> moving to fast, or for comm purposes. so definitely out of norm for me. I
>> still like the original work around though. I would use it again if in a
>> pinch.
>>
>> Good discussion in any case and now I have a better grasp on Ticker.
>>
>> Makes one of my Dad's best advice quotes ring true:
>>
>> When all else fails, read the instructions ~ Dad
>>
>> Good Stuff,
>>
>> John Vaughters
>>
>>
>>
>>
>>
>>
>> On Tuesday, January 26, 2021, 12:51:13 PM EST, Carl Nobile <
>> carl.nobile at gmail.com> wrote:
>>
>>
>>
>>
>>
>> Yeah, delays could mess with interrupts even if they are not in the
>> interrupt itself. Actually what happens is the interrupt messes with the
>> delay. If the interrupt happens in the middle of the delay the delay will
>> be longer than what you set it at.
>> Almost all processors will be running interrupts even if you're not using
>> any.
>> There are other people in the group that have more experience with this
>> than I, so just my two cents.
>>
>> ~Carl
>>
>> _______________________________________________
>> Triangle, NC Embedded Computing mailing list
>>
>> To post message: TriEmbed at triembed.org
>> List info:
>> http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
>> TriEmbed web site: http://TriEmbed.org
>> To unsubscribe, click link and send a blank message: mailto:
>> unsubscribe-TriEmbed at bitser.net?subject=unsubscribe
>>
>>
>
> --
>
> -------------------------------------------------------------------------------
> Carl J. Nobile (Software Engineer)
> carl.nobile at gmail.com
>
> -------------------------------------------------------------------------------
> _______________________________________________
> Triangle, NC Embedded Computing mailing list
>
> To post message: TriEmbed at triembed.org
> List info: http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
> TriEmbed web site: http://TriEmbed.org
> To unsubscribe, click link and send a blank message: mailto:
> unsubscribe-TriEmbed at bitser.net?subject=unsubscribe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20210126/a1963402/attachment.htm>


More information about the TriEmbed mailing list