Close

Time perception

A project log for MagiClick S3 - Mechanical Macro Keyboard with Disp

A single-button keyboard, based on circuitpython

makerm0MakerM0 08/10/2024 at 07:580 Comments

I've developed a small game designed to assess an individual's temporal perception skills, specifically focusing on the precision of second estimations and their awareness of the passage of time. The programming required for this game is quite straightforward. Upon pressing a key, a timer begins. The objective is to release the key when you believe the pre-determined time interval has passed. By analyzing the outcomes, we can evaluate a person's aptitude in perceiving time accurately.

The primary programming used for development is CircuitPython.

CircuitPython is an open-source firmware for microcontrollers that makes it easy to program hardware with Python. It's particularly popular for educational purposes and hobbyist projects because of its simplicity and the large community supporting it. 

The image demonstrates an attempt at gauging 4 seconds of time passage. Ha!

from magiclick import MagiClick
import os,displayio,supervisor,gc,terminalio
import rtc
import time
from adafruit_display_text import label
import board,microcontroller


mc = MagiClick()

from adafruit_bitmap_font import bitmap_font
font_file = "fonts/LeagueSpartan-Bold-16.bdf"
font = bitmap_font.load_font(font_file)
# font = terminalio.FONT


main_group = displayio.Group()
mc.display.root_group=main_group


t_label = label.Label(terminalio.FONT, color=0x2f88ff, scale=3)
t_label.anchor_point = (0.5, 0.5)
t_label.anchored_position = (mc.display.width//2, mc.display.height//2)
t_label.text = "Press"

main_group.append(t_label)

mc.display.auto_refresh=False
mc.display.refresh()
microcontroller.cpu.frequency=160000000

mc.display.brightness = 1.0
now = 0
while True:
    time.sleep(0.001)
    key_event = mc.keys.events.get()
    if key_event:
        if key_event.pressed:
            key = key_event.key_number
        elif key_event.released:
            key = key_event.key_number+10
        
    else:
         key=-1
         
    if key==0:
        now = time.monotonic()
        t_label.text="Timing"
        print("Timing")
        mc.display.refresh()
    elif key == 10:
        t = time.monotonic()-now
        t_label.text= f'{t:.3f}'
        print("end")
        print(t)
        mc.display.refresh()
        
    elif key==2:
        print('exit')
        microcontroller.cpu.frequency=240000000
        mc.exit()

Discussions