Coder Social home page Coder Social logo

jaccuse's Introduction

jaccuse

Image
A simple python script to countdown the number since a thing happened
It makes use of the sense_hat python library for controlling the LEDs

Fun fact: You dont need a physical pi to develop this!
You can run the main.py script in Trinket.io to emulate a raspberry pi with a sense hat :)
If you do emulate, just skip to copying the main.py code into the emulator IDE and hitting run. Otherwise,

Physical Setup:

1. Clone the Repo into home directory (or wherever, im not your mom so do whatever you want)

cd $HOME
git clone https://github.com/444B/jaccuse.git

2. apt update and install sense-hat

sudo apt update && sudo apt install sense-hat -y
  • note, you can make a pip venv for this but it was giving me numpy warnings (???) despite the fact that I wasnt using numpy or pillow so I opted to skip the venv

3. run file

python3 ~/jaccuse/main.py

4. (Optional) - add the python script to start up on physical pi startup

open /etc/rc.local

sudo nano /etc/rc.local

add the following in, right before the bottom line that says "return 0"

python3 $HOME/jaccuse/main.py &

Documentation

1. Orientation.

You should see a "?" displayed. Use the Sense pi button (or arrow keys if emulated on trinket) to face the question make the right way
Press the button in (or Enter if emulated) to select this orientation.

2. Duration Selection

Next, the script needs to know how long you want to set the incremental timer
The options are: Seconds, Minutes, Hours and Days.
Cycle left and right to get the setting you want and then press the physical button IN (if emulated: press enter)
The counter will now begin from zero and count up. Note that after 10, things get spooky so keep that in mind.

3. ???

4. PROFIT

How to contribute

jaccuse's People

Contributors

444b avatar

Watchers

 avatar

Forkers

elie-z

jaccuse's Issues

Fix how double digits are handled

Currently, single digits are shown via sense.show_letter(), which can handle single letters
We can not use this when we use numbers >= 10, so we have a workaround of using sense.show_message()
we need to fix this since sense.show_message() scrolls the value past and this is problematic for any time greater than a second

Direction idea

if event.direction == "up": # Up button

You can make this just a few lines like:

if event.action == "pressed":
    # Check which direction
    if event.direction == "middle":
        flipped = False # exits the loop
   sense.set_rotation(direction_dict[event.direction])
   sense.show_letter(arrow)    

You could also do:
if event.direction in ["up", "down", "left", "right"]:

A way to count in all time periods

An issue is that you have to pick the time periods
A request for a new feature is to start the timer and it automatically changes the time period
if 60s, period = minute
if 60m, period = hour
if 24h, period = day

Function Decorations

def change(canvas, paint):

You can give functions decorations like:
def change(canvas:list, paint:list) -> None:
Then when you hover your mouse over change it'll show you the inputs/output types and the -> is the return type

Duration Dictionary Idea

jaccuse/main.py

Line 196 in 7e10ab5

if duration == "sec":

Instead of this block:

if duration == "sec":
    update_display(counter, duration)
    sleep(1)
    counter += 1
elif duration == "min":
    update_display(counter, duration)
    sleep(60)
    counter += 1
elif duration == "hour":
    update_display(counter, duration)
    sleep(3600)
    counter += 1
elif duration == "day":
    update_display(counter, duration)
    sleep(86400)
    counter += 1
else:
    print("error")
    break

You can have a dictionary like:
duration_dict = {"sec":1, "minute":60, "hour":3600, "day":86400}
And then replace the block with:

if duration:
    update_display(counter, duration)
    sleep(duration_dict[duration])
    counter += 1
else:
    print("error")
    break

Replace if logic with a dictionary

Instead of using if statements, we can use a dictionary
psuedocode: directionDict ={"up" : 0, "down": 180, etc}
we can set it with sense.set_rotation(directionDict[event.direction])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.