Skip to main content

A simple countdown timer library for Python or MicroPython

Project description

Countdown Timer

This simple class allows you to simplify project that require a countdown timer. Simply set the duration of the timer either using countdowntimer.duration or countdowntimer.duration_in_seconds and then run countdowntimer.reset(). It will then countdown from the future time - current_time + duration. Once the timer is up the isalarm variable will become True. This can be put into a simple loop such as:

c = CountDownTimer()
c.duration = 1 # minute

c.reset()
while not c.isalarm():
    c.status()
    sleep(0.25)

print("Timer is done")

Functional reference

Below is a description of each of the functions


tick

The countdowntimer class has a tick function that will return the remaining time as a simple printable time string:

countdowntimer.tick()


target_time

Returns the Target time, that is the start_time + the duration in minutes

countdowntimer.target_time


target_str

The countdowntimer class has a target_time_str function that will return the future, or target time as a pretty printable string.

countdowntimer.target_time_str()


start_time_str

The countdowntimer class has a start_time_str function that will return the start time - the time the counter started counting from as a pretty printable string.

countdowntimer.start_time_str()


remaining_str

Returns the remaining time as a pretty printable string.

countdowntimer.remaining_str()


isalarm

Returns True if the countdown timer target time has been reached, and False if the time has yet to be achieved.

countdowntimer.isalarm()


status

If the timer hasn't reached its target time, this function prints out a single line showing:

  • The Start time
  • The Current Time
  • The Remaining Time

countdowntimer.status()


Why this class was created

This library was created for both the AI Assistant Pomodoro skill as well as the Build your own Cute Pomodoro Desk Robot - HeyBot! see video below.

The full BYO Cute Pomodoro Desk Robot code is available here.


YouTube Video

Click the thumbnail below to watch the show all about this build.

YouTube Thumbnail

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple-countdowntimer-0.0.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

simple_countdowntimer-0.0.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file simple-countdowntimer-0.0.2.tar.gz.

File metadata

  • Download URL: simple-countdowntimer-0.0.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for simple-countdowntimer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 67d3331b1e895a64b0b26e4cf08378b771580d8959bcfa583a5934d5aff0453a
MD5 0cac65e4973b4e7b49e91cfbfba2879b
BLAKE2b-256 bf92455cf7e16ac18b85a66df94bc853470e3a2aa8bf851ff26f3abcb6537dd9

See more details on using hashes here.

File details

Details for the file simple_countdowntimer-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_countdowntimer-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8ce9f4bfede9cc954c50fa5404539e1c7d516a0226c15bf43aeaba48b11913b3
MD5 b3339510fc5bccc17a78813bcf4000e2
BLAKE2b-256 7a609b837082b20f6b1f6f436f9b1a6c34b8933ac1bef031a49f35193c9b186f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page