Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Visual Countdown Days Until [a date]

During the holidays, I embarked on a fun project to create a visual countdown for important dates. Inspired by howmanysleeps and hometime from veebch, I wanted to build a countdown that didn't rely on Google Calendar. Instead, I used a Raspberry Pi Pico and some custom code to achieve this.

💾 You can find the full code on GitHub


Raspberry Pi pico and the light using custom colors

What It Is

This project consists of two main parts:

  • Python code for the Raspberry Pi Pico
  • A .NET website to update the configuration, allowing you to set:
    • The important date
    • Two custom colors or random ones
    • The RGB values for the custom colors


screenshot of the configuration website

What You Need

How to Deploy the Configuration Website

After cloning the repo, navigate to the src/NextEvent/ folder and use the Azure Developer CLI to initialize the project:

azd init

Enter a meaningful name for your resource group in Azure. To deploy, use the deployment command:

azd up

Specify the Azure subscription and location when prompted. After a few minutes, everything should be deployed. You can access the URL from the output in the terminal or retrieve it from the Azure Portal.

How to Set Up the Raspberry Pi Pico

Edit the config.py file to add your Wi-Fi information and update the number of lights on your light strip.

You can use Thonny to copy the Python code to the device. Copy both main.py and config.py to the Raspberry Pi Pico.

How It Works

  • The website creates a JSON file and saves it in a publicly accessible Azure storage.
  • When the Pi is powered on, it will:
    • Turn green one by one all the lights of the strip
    • Change the color of the entire light strip a few times, then turn it off
    • Try to connect to the Wi-Fi
    • Retrieve the timezone, current date, and settings from the JSON file
    • If the important date is within 24 days, the countdown will be displayed using random colors or the specified colors.
    • If the date has passed, the light strip will display a breathing effect with a random color of the day.

The Code on the Raspberry Pi Pico

The main code for the Raspberry Pi Pico is written in Python. Here's a brief overview of what it does:

  1. Connect to Wi-Fi: The connect_to_wifi function connects the Raspberry Pi Pico to the specified Wi-Fi network.
  2. Get Timezone and Local Time: The get_timezone and get_local_time functions fetch the current timezone and local time using online APIs.
  3. Fetch Light Settings: The get_light_settings function retrieves the important date and RGB colors from the JSON file stored in Azure.
  4. Calculate Sleeps Until Special Day: The sleeps_until_special_day function calculates the number of days until the important date.
  5. Control the LED Strip: The progress function controls the LED strip, displaying the countdown or a breathing effect based on the current date and settings.

The Configuration Website

The configuration website is built in C#. It's a Blazor server webapp, and I used .NET Aspire to make it easy to run it locally. The UI uses FluentUI-Blazor so it looks pretty, without effort. 

The website allows you to update the settings for the Raspberry Pi Pico. You can set the important date, choose custom colors, and save these settings to a JSON file in Azure storage.

Little Extra

The website is deployed in Azure Container App with a minimum scaling to zero to save on costs. This may cause a slight delay when loading the site for the first time, but it will work just fine and return to "dormant" mode after a while.

I hope you enjoyed reading about my holiday project! It was a fun and educational experience, and I look forward to working on more projects like this in the future.

What's Next?

Currently the project does a 24 days countdown (inspired from the advent calendar). I would like to add a feature to allow the user to set the number of days for the countdown. I would also like to add the possibility to set the color for the breathing effect (or keep it random) when the important date has passed. And lastly, I would like to add the time of the day when the light strip should turn on and off, because we all have different schedule 😉 .

Last thoughts

I really enjoyed doing this project. It was a fun way to learn more about the Raspberry Pi Pico, micro-Python (I didn't even know it was a thing), and FluentUI Blazor. I hope you enjoyed reading about it and that it inspired you to create your own fun projects. If you have any questions or suggestions, feel free to reach out, I'm fboucheros on most socials.

~Frank

Reading Notes #623

Ready for another round of intriguing reads and insightful listens? This week's edition of Reading Notes dives into the seamless blending of Python and .NET, fresh monetisation strategies in open source, AI innovations, and thought-provoking podcast discussions. 

Get comfy and let's dive in!

path in a forest surround by large trees



Programming

AI

Podcast

Sharing my Reading Notes is a habit I started a long time ago, where I share a list of all the articles, blog posts, and books that catch my interest during the week.

If you have interesting content, share it!

~ Frank

Reading Notes #501


Another Monday, another Reading Notes. 😀

It's been five hundred weeks, this is more than nine years! Who knew I will keep doing that for so long... 

If you are new around here, welcome, The Reading Notes are a curated list of all the articles, blog posts, podcast episodes, and books that catch my interest during the week and that I found interesting. It's a mix of the actuality and what I consumed.

If you think you may have interesting content, share it!

Cloud

Programming

Miscellaneous

Miscellaneous


~Frank


Reading Notes #465


Every Monday, I share my "reading notes". Those are a curated list of all the articles, blog posts, podcast episodes, and books that catch my interest during the week and that I found interesting. It's a mix of the actuality and what I consumed.

You think you may have interesting content, share it!

Cloud

Programming

Miscellaneous


~Frank

Reading Notes #461

Every Monday, I share my "reading notes". This is a curated list of all the articles, blog posts, and books that catch my interest during the week and that I found interesting. It's a mix of the actuality and what I consumed.

The suggestions of the week

Cloud

  • What Is Azure Functions (Mahesh Chand) - The great simple post that explains what is an Azure Function and how to create/ debug/ deploy one

Programming

Podcast

  • Épisode 11 - La famine en Ukraine (Les Pires Moments de l'Histoire) - OMG! I have nothing else to say. I knew that part of the history was dark and complex... but I knew nothing. Great episode.
  • 633 - How to Use Rejection to Your Advantage (Modern Mentor) - In our lives, we will encounter many nos or rejection. This episode talks about how you could use those detours to learn more, and transform them in opportunities.

Miscellaneous


You think you may have interesting content, share it!

~Frank


Summary of Week 34

Every beginning weekend, I will share a recap of the week and at the same time a summary of my streams. Those videos are at least two hours longs, so I thought a short summary to know if the topic interest you could be useful. Watch only the summary or relax and enjoy the longer version that up to you!

   




~

Recap/ Summary week #33

 Every beginning of weekend, I will share a recap of the week and at the same time a summary of my streams. Those videos are at least two hour longs, so I thought a short summary to know if topic interest you could be useful. Watch only the summary or relax and enjoy the longer version that up to you!

   

  • Coding Python: Deploy Django and Postgres Apps to Azure with VS Code - c5m.ca/aaa-ep25
  • Stream 119 - How easy can we make the deployment of TinyBlazorAdmin -  c5m.ca/stream-ep119
  • Stream120 - Celebrating 500 followers and working on the Chat bot -  c5m.ca/stream-ep120

~

Reading Notes #429

Suggestion of the week


Cloud


Programming

  • Remote Debugging .NET Containers (Karol Deland) - A nice tutorial that explains clearly first the difference between remote and local debugging and then explains how to do it.

Podcast


Miscellaneous

  • Screen Sharing with an Ultrawide Monitor (Kenny Lowe) - Really interesting post.As I think about getting a new screen and heard bad experiences sharing ultrawide screens this look like a nice solution.

Book


Vlog Like a Boss - How to Kill It Online with Video Blogging

Author: Amy Schmittauer Landino

An interesting book that shares the best practices about making videos today. How to plan, record, edit... What to do and not do. A quick, direct to the point and complete tutorial to get started. This book was done like today's videos.







~enjoy.

Reading Notes #420




Every Monday, I share my "reading notes". Those are the articles, blog posts, podcast episodes, and books that catch my interest during the week and that I found interesting.

It's a mix of the actuality and what I consumed. This week I was less in a reading mode...

Programming


Miscellaneous

Reading Notes #415


Every Monday, I share my "reading notes". Those are the articles, blog posts, podcast episodes, and books that catch my interest during the week and that I found interesting. It's a mix of the actuality and what I consumed.



Cloud

Programming

Miscellaneous

  • What are Azure CLI Extensions? (Michael Crump) - An interesting first article of a series. This one introduces us to the extension... Hmmm. I think I have an idea.
~


Reading Notes #399

Cloud

  • Azure DevOps Roadmap update for 2019 Q4 (Gloridel Morales) - Since the multi-stage pipeline launch in May, the team as been listening to his community. In this post learn more about what they have been working on and what is their roadmap.

Programming

  • Code Comments (Donn Felker) - Very smart idea! I'm staring using that rule right away.
  • Microservices Fundamentals (Mark Heath) - New course on Pluralsight about an indeed challenging topic. This post shares the plan of that Microservices course.
  • Stop Waiting! Start using Async and Await! (Simon Hawe) - Learn the power of async in this excellent post. The example may be in Python the idea is the same however language we are using.

Miscellaneous


Books

Superfans: The Easy Way to Stand Out, Grow Your Tribe, And Build a Successful Business

Author: Pat Flynn

I really like this book, and planning to read it again soon. I like the way things are simply explained. Like if you deconstructed a situation and then re-building it. It felt authentic and true. It's nothing transcending, but the way it is explained is great.




~


Reading Notes #381

Suggestion of the week


Cloud


Programming


Miscellaneous


Books

Author: Eric Barker

Nice book. There is always a good story to make a correlation with his current point. Then it could go in a different direction with another story. All the stories are complementary and are adding layer by layer to the more complex message that is delivered to us. Easy to read, enjoyable from the beginning until the last word.

Reading Notes #370

Cloud


Programming


Databases


Miscellaneous



Reading Notes #359

DockerDesktopCloud


Programming


Databases


Miscellaneous


Books

How to Be a Bawse_cover
How to Be a Bawse A Guide to Conquering Life
Lilly Singh
Not only the message is strong, but the way she delivers it is awesome. Many times I laugh and nod of the head... Definitely a great book to read at the end of the year when resolution time is not far...









~

Reading Notes #54

Web Sites or Cloud Apps
Cloud
Programming
Miscellaneous
  • Defend Your Sweet Spot (Peter) - Interesting post by Peter Bregman, the author of 18 minutes, that explains why finding and keeping your sweet spot is important.
[…] time management isn’t primarily about using minutes well, it’s about using yourself well.[…]

~Frank