Hacker Public Radio

The Hacker Public Radio Old Microphone Logo

https://hackerpublicradio.org/about.html

subscribe
share






HPR4075: Making a Pomodoro Timer


Making a Pomodoro Timer Slacking Off at work

  • I get distracted Easy
  • My mind drifts if I try to focus on a single task For more than 20-30 Minutes.
  • If I try to fight the urge to just keep working my productivity goes way down.
  • I end up working for a bit, then slacking off for half an hour.
  • I can get more work done If I embrace my limitation and force myself to take a break.
Pomodoro Technique

From Wikipedia https://en.wikipedia.org/wiki/Pomodoro_Technique

The Pomodoro Technique is a time management method developed by Francesco Cirillo in the late 1980s. It uses a kitchen timer to break work into intervals, typically 25 minutes in length, separated by short breaks. Each interval is known as a Pomodoro, from the Italian word for tomato, after the tomato-shaped kitchen timer Cirillo used as a university student.

The Timer
  • There are plenty of Pomodoro Apps I've tried using an app, but I would often forget.
  • I wanted a physical device that was always on by desk and could grab my attention.
  • I looked for a dedicated physical Pomodoro timer, but only found the kitchen timers
  • I decided to make myself a timer using a Circuit Playground Express
Circuit Playground Express
  • In my past episode about using a Pi pico to type passwords I mentioned I owned a playground express.
  • The playground express is a micro controller with a lot of built ins
    • 2 buttons
    • 10 multi color LED
    • ...
  • Runs circuit python with lots of libraries so it is easy to program.
TDD
  • About once every other year I decided to start a project with as much TDD as I can.
  • TDD Basics
    • Write a test BEFORE you write the code
    • Run the test - It will fail
    • Write the simplest code that will pass the test
    • Run the test and make sure it passes
    • Refactor/improve the code if needed.
  • TDD advantages
    • Code is easy to separate into discrete functions
    • Parts of the code can be rewritten without affecting the rest
    • confidence in rewrites
pomodoro.py
  • Circuit python looks for and runs a file named code.py
  • A lot of the circuit Python code has to be run on the micro controller
  • My Developers workstation does not have the LED's or buttons
  • I split the some code into a separate file based on if it could run in "regular" python.
  • I used TDD as much as possible to test the functions in pomodoro.py
code.py BREAK_MINUTES = 5 WORK_MINUTES = 25
  • Functions that require hardware
  • No tests.
  • counts down and changes color of led
  • minutes divided by number of LED
Using the timer
  • Ready
    • Green Light next to button to start work Period
    • Blue Light next to button to start break Period
  • Working
    • White Background
    • Green progress pixels
  • Break
    • White Background
    • Blue progress pixels
  • Button A
    • Start working
  • Button B
    • Start Break
Links
  • https://gitlab.com/norrist/circuit_playground_pomodoro
  • https://circuitpython.org/downloads
  • https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-neopixel


fyyd: Podcast Search Engine
share








 March 15, 2024  n/a