Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1584

Python • 7. segment clock python script not looping on fresh Bookworm install

$
0
0
I have a 7 segment LED on a RPi3 (Buster install) that I use as a clock with the clock.py python script from here and it works great:

https://github.com/depklyon/raspberrypi ... ples/clock

I finally upgraded to the latest Bookworm version of Raspbian using a new microsd card today, and although the clock.py script runs, it doesn't seem to loop properly, as it just sets the correct time on the 7 segment LED when it starts, but then never changes it as the minutes tick by.

Here's my version of the script (only the GPIO pins are different than the GIT version):

Code:

#!/usr/bin/env python3from time import sleep, localtimefrom tm1637 import TM1637DIO = 4CLK = 17class Clock:    def __init__(self, tm_instance):        self.tm = tm_instance        self.show_colon = False    def run(self):        while True:            t = localtime()            self.show_colon = not self.show_colon            tm.numbers(t.tm_hour, t.tm_min, self.show_colon)            sleep(1)if __name__ == '__main__':    tm = TM1637(CLK, DIO)    tm.brightness(3)    clock = Clock(tm)    clock.run()
The only library I had to install on the new/fresh Bookworm Raspbian install was the 7 segment LED library using pip:

Code:

pip3 install --break-system-packages raspberrypi-tm1637
The version of python I was using on the old Buster install, where the script ran great, was Python 3.7.3. The version of Python on the new Bookworm install where it's not working is Python 3.11.2.

Statistics: Posted by WanLanMan — Wed Jun 11, 2025 2:39 am



Viewing all articles
Browse latest Browse all 1584

Trending Articles