Inkplate-micropython icon indicating copy to clipboard operation
Inkplate-micropython copied to clipboard

How to schedule functions at defined times like Cron-Jobs

Open mfasold opened this issue 1 year ago • 3 comments

I would like to run some functions at defined times and dates. Example:

  • on Monday to Friday at 7:00 and 8:00 run function A
  • on Saturday and Sunday at 10 run function B

I understand that the RTC allows me to get the time. How can I use this to run the functions at the defined times and sleep in between? Can this be done using available libraries (preferred), or can you recommend external libraries?

mfasold avatar Oct 04 '24 10:10 mfasold

Hi @mfasold ,

I'll have to check regarding your other opened issue regarding the RTC on Inkplate 6COLOR. Could you please take a picture of the back side of your board so I can verify the version which you have? This will help me resolve the issue faster.

As a side note, we mainly maintain and update the Arduino library, this one was done originally as a user contribution and does have the key features but I would personally recommend using the Arduino one.

-Rob

rsoric avatar Oct 07 '24 13:10 rsoric

Thank you for the reply. I was having the same impression regarding Arduino vs Micropython. Maybe I'll switch. But if the RTC works, this might be enough for me. I found the micropython-mcron library, which might be the solution to the CRON question.

Please find the image here. image

mfasold avatar Oct 07 '24 14:10 mfasold

Hi @mfasold ,

thanks, just to confirm I saw your reply and I'll be back in office on Monday where I'll test the micropython code again and reply with the details.

rsoric avatar Oct 11 '24 07:10 rsoric

Hi @mfasold ,

I've corrected some things in the code and was able to load from the RTC: image

Long story short, it's due to the fact there is a different implementation of the display with this Inkplate compared to the others so the Python class structure is different, and as we've had the RTC implemented in others, this one required some corrections in the implementation. Thanks for pointing it out to us. Try the dev branch now please and if it's correct on your device as well, I'll push it to the main branch.

-Rob

rsoric avatar Oct 14 '24 09:10 rsoric

Thank you! I tried out the updated implementation and can confirm that the RTC example works on my device.

mfasold avatar Oct 14 '24 15:10 mfasold

Great to hear, thanks for letting us know about this, It will be pushed to main soon. So, from here, you can use the RTC's data to get the time and then periodically check it, and run a task if a time condition has been met. Gonna close this issue now.

rsoric avatar Oct 15 '24 05:10 rsoric