Welcome to Town Clock’s documentation!

Readme


Town Clock

Tests pre-commit.ci status Documentation Status


Documentation

Current main: GitHub Pages

All versions: Read The Docs


Installation

Install Dev

pip install poetry
poetry install --with=dev

Install Docs

pip install poetry
poetry install --with=docs

Install for use

pip install . -e

Licence

town_clock

Subpackages

town_clock.clock package

Submodules
town_clock.clock.clock module

clock.py

class Clock(name: CLOCK, relay: ClockRelay, time_on_clock: int, slow: int = 0, cutoff: int = 30, sleep_time: float = 0.5)[source]

Bases: object

Class Clock

Parameters:
  • name (CLOCK) – The name of the clock in enum form.

  • relay (ClockRelay) – The relay that this Clock controls.

  • time_on_clock (int) – minutes past 12 AM/PM (0-719)

  • slow (int) – Minutes slow, fast is negative.

  • cutoff (int) – Value is used to work out how long the clock will sleep for. Default is 30.

compare(clock_time: int) Clock[source]

Compares the time on the clock with the given time and works out how slow or fast it is.

The ‘self.cutoff’ value is used to work out how long the clock will sleep for.

Parameters:

clock_time – int: Time.clock_time, minutes after 12 AM/PM.

Returns:

self

cutoff: int = 30
name: CLOCK
pulse(num_pulses: int = 1) Clock[source]

Pulse the clock

relay: ClockRelay
sleep_time: float = 0.5
slow: int = 0
time_on_clock: int
class ClockRelay(*args, **kwargs)[source]

Bases: Protocol

Relay Protocol

pulse()[source]

pulse method

town_clock.clock.clock_tower module
town_clock.clock.pulses module
town_clock.clock.relay module
Module contents

town_clock.ui package

Submodules
town_clock.ui.lcd_screen module
Module contents

town_clock.util package

Submodules
town_clock.util.clock_exceptions module
town_clock.util.clock_logging module
town_clock.util.location_sunrise_sunset module

Calculates sun position.

find_sunrise_sunset_times(latitude: float, longitude: float, altitude: float) dict[int, float][source]
timezone_finder(latitude: float, longitude: float)[source]
town_clock.util.utils module
class CLOCK(value)[source]

Bases: Enum

CLOCK Names A enum used for controlling and altering the clock times independently. todo: Use enum with objects..

ALL = 0
ONE = 1
TWO = 2
classmethod values() tuple[Literal[0], Literal[1], Literal[2]][source]
class Log_Level(value)[source]

Bases: Enum

Log Levels: CRITICAL: 50 EXCEPTION = 40 ERROR: 40 WARNING: 30 INFO: 20 DEBUG: 10 NOTSET: 0

CRITICAL = 50
DEBUG = 10
ERROR = 40
EXCEPTION = 40
INFO = 20
NOTSET = 0
PULSE = 45
SUCCESS = 25
WARNING = 30
class Mode(value)[source]

Bases: Enum

Either Test or Active

DEV = ‘dev’ TEST = ‘test’ ACTIVE = ‘active’

ACTIVE = 'active'
DEV = 'dev'
TEST = 'test'
convert_position_string_to_number(position_str: str) float[source]

Converts a position string to a number.

Parameters:

position_str – str: Position in the form of a string. eg “30.3402W”

Module contents

Utility package for town-clock

All modules can use these utility functions and classes.

Author: Zack Hankin Started: 27/01/2023

class CLOCK(value)[source]

Bases: Enum

CLOCK Names A enum used for controlling and altering the clock times independently. todo: Use enum with objects..

ALL = 0
ONE = 1
TWO = 2
classmethod values() tuple[Literal[0], Literal[1], Literal[2]][source]
class Log_Level(value)[source]

Bases: Enum

Log Levels: CRITICAL: 50 EXCEPTION = 40 ERROR: 40 WARNING: 30 INFO: 20 DEBUG: 10 NOTSET: 0

CRITICAL = 50
DEBUG = 10
ERROR = 40
EXCEPTION = 40
INFO = 20
NOTSET = 0
PULSE = 45
SUCCESS = 25
WARNING = 30
class Mode(value)[source]

Bases: Enum

Either Test or Active

DEV = ‘dev’ TEST = ‘test’ ACTIVE = ‘active’

ACTIVE = 'active'
DEV = 'dev'
TEST = 'test'
convert_position_string_to_number(position_str: str) float[source]

Converts a position string to a number.

Parameters:

position_str – str: Position in the form of a string. eg “30.3402W”

find_sunrise_sunset_times(latitude: float, longitude: float, altitude: float) dict[int, float][source]
timezone_finder(latitude: float, longitude: float)[source]

Modules

town_clock.controller module

Module contents

Indices and tables