From 2d5425a959c5f98c6089b90acaf23f5c0d336285 Mon Sep 17 00:00:00 2001 From: ed8g20 <ed8g20@soton.ac.uk> Date: Sat, 13 May 2023 18:00:40 +0000 Subject: [PATCH] Update 3 files - /synchronised_time.py - /main.py - /base32.py --- base32.py | 27 +++------------------------ main.py | 3 +-- synchronised_time.py | 5 +---- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/base32.py b/base32.py index de51912..8db23c6 100644 --- a/base32.py +++ b/base32.py @@ -1,5 +1,6 @@ def base32_decode(message): + """ Decodes the supplied encoded Base32 message into a byte string @@ -13,29 +14,7 @@ def base32_decode(message): chunks = [padded_message[i:i+8] for i in range(0, len(padded_message), 8)] decoded = [] - - for chunk in chunks: - bits = 0 - bitbuff = 0 - - for c in chunk: - if 'A' <= c <= 'Z': - n = ord(c) - ord('A') - elif '2' <= c <= '7': - n = ord(c) - ord('2') + 26 - elif c == '=': - continue - else: - raise ValueError("Not Base32") - - bits += 5 - bitbuff <<= 5 - bitbuff |= n - - if bits >= 8: - bits -= 8 - byte = bitbuff >> bits - bitbuff &= ~(0xFF << bits) - decoded.append(byte) + + #TODO: impliment method return bytes(decoded) diff --git a/main.py b/main.py index c619550..5ddf26d 100644 --- a/main.py +++ b/main.py @@ -29,8 +29,7 @@ selected_idx = 0 synchronised_time = create_synchronised_time(display, button_a, button_b, button_x, button_y) while True: - if button_a.read() : - selected_idx = (selected_idx + 1) % len(codes) + #TODO: change selected when user presses a button code = codes[selected_idx] diff --git a/synchronised_time.py b/synchronised_time.py index bb326ee..4cb9121 100644 --- a/synchronised_time.py +++ b/synchronised_time.py @@ -40,9 +40,6 @@ def create_synchronised_time(display, button_a, button_b, button_x, button_y): display.update() time.sleep(0.3) - delta = time.mktime(datetime + [0, 0]) - int(time.time()) - - def synchronised_time(): - return int(time.time()) + delta + # TODO: Create a function that returns the epoch time when then function is run, called synchronised_time return synchronised_time -- GitLab