diff --git a/README.md b/README.md index 93157ea..cd7ed42 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ # Picoth + An OTP enabled macro keyboard based upon a Raspberry Pi Pico and RGB keypad base from Pimoroni. ![Preview](https://pbs.twimg.com/media/ExEwmVaXMAUbIDw?format=png&name=small) Project log on Hackaday.io: [Picoth on HackaDay.io](https://hackaday.io/project/177593-picoth-2fa-auth-with-pi-pico) -**Warning**: In its current state, this device is not safe to use in an adversarial environment: anyone having access to it could steal your config file, hence your OTP keys. -Next versions will include encrypted keys and an option to remove the USB disk drive mount. +**Warning**: In its current state, this device is not safe to use in an adversarial environment: anyone having access to it could steal your config file, hence your OTP keys. +Next versions will include encrypted keys and an option to remove the USB disk drive mount. # Overview @@ -14,42 +15,40 @@ This is a work in progress, feel free to ask and request more info. [Twitter @Angainor15](https://twitter.com/Angainor15) [Discord](https://discord.gg/gy9xpuQK8A) - ## keypad mapping The mapping is a regular keypad instead of the Pimoroni default's one. -||||| -|---|---|---|---| -| 7 | 8 | 9 | L | -| 4 | 5 | 6 | + | -| 1 | 2 | 3 | - | -| P | 0 | N | E | +| | | | | +| --- | --- | --- | --- | +| 7 | 8 | 9 | L | +| 4 | 5 | 6 | + | +| 1 | 2 | 3 | - | +| P | 0 | N | E | L = Sleep/Lock E = Enter P = Previous Page -N = Next Page +N = Next Page # Hardware - 1× Raspberry Pi Pico -https://shop.pimoroni.com/products/raspberry-pi-pico + https://shop.pimoroni.com/products/raspberry-pi-pico - 1× Pimoroni's RGB Keypad -https://shop.pimoroni.com/products/pico-rgb-keypad-base + https://shop.pimoroni.com/products/pico-rgb-keypad-base - 1× Pimoroni's Pico display -https://shop.pimoroni.com/products/pico-display-pack + https://shop.pimoroni.com/products/pico-display-pack - 1× DS3231 Arduino module -https://s.click.aliexpress.com/e/_AZGRXo + https://s.click.aliexpress.com/e/_AZGRXo -*Note:* This is not sponsored by Pimoroni, I was not paid to build this project and bought the hardware myself. +_Note:_ This is not sponsored by Pimoroni, I was not paid to build this project and bought the hardware myself. I just like what the pirates do. # Setup See the wiring and photos on [Hackaday](https://hackaday.io/project/177593-picoth-2fa-auth-with-pi-pico/log/189173-definitive-wiring) - and [Twitter post](https://twitter.com/Angainor15/status/1359431057611882498) - +and [Twitter post](https://twitter.com/Angainor15/status/1359431057611882498) ## Circuit python @@ -61,8 +60,8 @@ I was running on 6.2.0 Beta 3, Beta 4 is now available. All needed libs are duplicated in the src/lib for convenience. Just copy the "src/lib" content on your CIRCUITPY usb drive. -For reference, here are the stock Adafruit libs that were used (they can all be found in the default [Adafruit lib pack](https://github.com/adafruit/Adafruit_CircuitPython_Bundle)) - +For reference, here are the stock Adafruit libs that were used (they can all be found in the default [Adafruit lib pack](https://github.com/adafruit/Adafruit_CircuitPython_Bundle)) + - adafruit_display_text - adafruit_hashlib - adafruit_hid @@ -78,17 +77,18 @@ https://github.com/sandyjmacdonald/keybow2040-circuitpython ## Source code -Just copy the python files from the "src/" folder on your CIRCUITPY usb drive. +Just copy the python files from the "src/" folder on your CIRCUITPY usb drive. -*Note:* Nothing is "clean" yet. It's a working but proof of concept code, iterated from several attempts and migration from MP to CP and libraries changes. -This will be improved over time. +_Note:_ Nothing is "clean" yet. It's a working but proof of concept code, iterated from several attempts and migration from MP to CP and libraries changes. +This will be improved over time. ## Time config The RTC module needs to be setup once. This will eventually be done via the GUI, but in the mean time you can do it manually from the Python repl: -Init a DS3231 instance: +Init a DS3231 instance: + ``` from adafruit_ds3231 import DS3231 import board @@ -101,10 +101,10 @@ ds = DS3231(i2c) From there you can query the current datetime: `ds.datetime` the temp -`ds.temperature` +`ds.temperature` and more importantly setup the date and time: -`rtc.datetime = time.struct_time((2021, 3, 24, 15, 3, 0, 0, -1, -1))` +`ds.datetime = time.struct_time((2021, 3, 24, 15, 3, 0, 0, -1, -1))` params are year, month, day, hour, min, sec, weekday(0-6), yearday(can be -1), isdst(-1 or 0) # Config @@ -113,6 +113,7 @@ Copy params.sample.json to params.json, edit and copy on your device. params.json is a json file. Core params are + ``` { "check": "ff00112233", @@ -122,12 +123,12 @@ Core params are } ``` -- check is reserved for future use when encrypting the keys +- check is reserved for future use when encrypting the keys - layout is the keyboard layout (currently supports "us" and "fr") - time_offset - in seconds - is your timezone: -3600 for GMT+1 - pages is a list of pages (1 page minimum has to be defined) -Every page is defined as: +Every page is defined as: ``` {"type": "TOTP", @@ -152,8 +153,7 @@ Every page is defined as: - keys: a list [0..9] of entries. See layout above, fits a numpad, that is first entry, 0, is on the lower line, and 7, 8, 9 (3 last entries in the list) are the 3 top keys. - Each key is a list as well: ["label", "hexcolor", "totp seed"] - Use ["","000000",""] for an inactive key - - + # Roadmap - Keys encryption, device lock, pincode @@ -164,7 +164,6 @@ Every page is defined as: - 3D Printed case - Alternate screens or no screen? - # Licence Custom code is released under the GNU AFFERO GENERAL PUBLIC LICENSE. diff --git a/src/lib/adafruit_display_shapes/__init__.py b/src/lib/adafruit_display_shapes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/lib/adafruit_display_shapes/circle.mpy b/src/lib/adafruit_display_shapes/circle.mpy index 1371d3d..d5cd7cf 100644 Binary files a/src/lib/adafruit_display_shapes/circle.mpy and b/src/lib/adafruit_display_shapes/circle.mpy differ diff --git a/src/lib/adafruit_display_shapes/line.mpy b/src/lib/adafruit_display_shapes/line.mpy index fbc0bf1..2bc0580 100644 Binary files a/src/lib/adafruit_display_shapes/line.mpy and b/src/lib/adafruit_display_shapes/line.mpy differ diff --git a/src/lib/adafruit_display_shapes/polygon.mpy b/src/lib/adafruit_display_shapes/polygon.mpy index 0ab7602..4257098 100644 Binary files a/src/lib/adafruit_display_shapes/polygon.mpy and b/src/lib/adafruit_display_shapes/polygon.mpy differ diff --git a/src/lib/adafruit_display_shapes/rect.mpy b/src/lib/adafruit_display_shapes/rect.mpy index 972fbe3..ae63133 100644 Binary files a/src/lib/adafruit_display_shapes/rect.mpy and b/src/lib/adafruit_display_shapes/rect.mpy differ diff --git a/src/lib/adafruit_display_shapes/roundrect.mpy b/src/lib/adafruit_display_shapes/roundrect.mpy index 12272ed..c0aa9df 100644 Binary files a/src/lib/adafruit_display_shapes/roundrect.mpy and b/src/lib/adafruit_display_shapes/roundrect.mpy differ diff --git a/src/lib/adafruit_display_shapes/sparkline.mpy b/src/lib/adafruit_display_shapes/sparkline.mpy index aa0c67f..dc0a7a9 100644 Binary files a/src/lib/adafruit_display_shapes/sparkline.mpy and b/src/lib/adafruit_display_shapes/sparkline.mpy differ diff --git a/src/lib/adafruit_display_shapes/triangle.mpy b/src/lib/adafruit_display_shapes/triangle.mpy index 069264e..13c5a26 100644 Binary files a/src/lib/adafruit_display_shapes/triangle.mpy and b/src/lib/adafruit_display_shapes/triangle.mpy differ diff --git a/src/lib/adafruit_display_text/__init__.mpy b/src/lib/adafruit_display_text/__init__.mpy index 8673b5f..e326f58 100644 Binary files a/src/lib/adafruit_display_text/__init__.mpy and b/src/lib/adafruit_display_text/__init__.mpy differ diff --git a/src/lib/adafruit_display_text/bitmap_label.mpy b/src/lib/adafruit_display_text/bitmap_label.mpy index bca4f5b..2e02d85 100644 Binary files a/src/lib/adafruit_display_text/bitmap_label.mpy and b/src/lib/adafruit_display_text/bitmap_label.mpy differ diff --git a/src/lib/adafruit_display_text/label.mpy b/src/lib/adafruit_display_text/label.mpy index 68bd0ca..812a36d 100644 Binary files a/src/lib/adafruit_display_text/label.mpy and b/src/lib/adafruit_display_text/label.mpy differ diff --git a/src/lib/adafruit_display_text/scrolling_label.mpy b/src/lib/adafruit_display_text/scrolling_label.mpy new file mode 100644 index 0000000..373db2a Binary files /dev/null and b/src/lib/adafruit_display_text/scrolling_label.mpy differ diff --git a/src/lib/adafruit_dotstar.mpy b/src/lib/adafruit_dotstar.mpy index 696e977..f2419d6 100644 Binary files a/src/lib/adafruit_dotstar.mpy and b/src/lib/adafruit_dotstar.mpy differ diff --git a/src/lib/adafruit_ds3231.mpy b/src/lib/adafruit_ds3231.mpy index 20bfb1e..f717415 100644 Binary files a/src/lib/adafruit_ds3231.mpy and b/src/lib/adafruit_ds3231.mpy differ diff --git a/src/lib/adafruit_hashlib/__init__.mpy b/src/lib/adafruit_hashlib/__init__.mpy index ed708a4..9f58708 100644 Binary files a/src/lib/adafruit_hashlib/__init__.mpy and b/src/lib/adafruit_hashlib/__init__.mpy differ diff --git a/src/lib/adafruit_hashlib/_md5.mpy b/src/lib/adafruit_hashlib/_md5.mpy index f12c434..8afa267 100644 Binary files a/src/lib/adafruit_hashlib/_md5.mpy and b/src/lib/adafruit_hashlib/_md5.mpy differ diff --git a/src/lib/adafruit_hashlib/_sha1.mpy b/src/lib/adafruit_hashlib/_sha1.mpy index 3671e85..33f58fc 100644 Binary files a/src/lib/adafruit_hashlib/_sha1.mpy and b/src/lib/adafruit_hashlib/_sha1.mpy differ diff --git a/src/lib/adafruit_hashlib/_sha224.mpy b/src/lib/adafruit_hashlib/_sha224.mpy index bdd80b2..7d5829a 100644 Binary files a/src/lib/adafruit_hashlib/_sha224.mpy and b/src/lib/adafruit_hashlib/_sha224.mpy differ diff --git a/src/lib/adafruit_hashlib/_sha256.mpy b/src/lib/adafruit_hashlib/_sha256.mpy index bc78b3c..c55d8a1 100644 Binary files a/src/lib/adafruit_hashlib/_sha256.mpy and b/src/lib/adafruit_hashlib/_sha256.mpy differ diff --git a/src/lib/adafruit_hashlib/_sha384.mpy b/src/lib/adafruit_hashlib/_sha384.mpy index 10d0718..52b2b56 100644 Binary files a/src/lib/adafruit_hashlib/_sha384.mpy and b/src/lib/adafruit_hashlib/_sha384.mpy differ diff --git a/src/lib/adafruit_hashlib/_sha512.mpy b/src/lib/adafruit_hashlib/_sha512.mpy index 38ea5b1..34e333e 100644 Binary files a/src/lib/adafruit_hashlib/_sha512.mpy and b/src/lib/adafruit_hashlib/_sha512.mpy differ diff --git a/src/lib/adafruit_hid/__init__.mpy b/src/lib/adafruit_hid/__init__.mpy index d955aed..1aa298b 100644 Binary files a/src/lib/adafruit_hid/__init__.mpy and b/src/lib/adafruit_hid/__init__.mpy differ diff --git a/src/lib/adafruit_hid/consumer_control.mpy b/src/lib/adafruit_hid/consumer_control.mpy index ff510dc..02cb9dc 100644 Binary files a/src/lib/adafruit_hid/consumer_control.mpy and b/src/lib/adafruit_hid/consumer_control.mpy differ diff --git a/src/lib/adafruit_hid/consumer_control_code.mpy b/src/lib/adafruit_hid/consumer_control_code.mpy index b6fc457..618edca 100644 Binary files a/src/lib/adafruit_hid/consumer_control_code.mpy and b/src/lib/adafruit_hid/consumer_control_code.mpy differ diff --git a/src/lib/adafruit_hid/gamepad.mpy b/src/lib/adafruit_hid/gamepad.mpy deleted file mode 100644 index 54f4a25..0000000 Binary files a/src/lib/adafruit_hid/gamepad.mpy and /dev/null differ diff --git a/src/lib/adafruit_hid/keyboard.mpy b/src/lib/adafruit_hid/keyboard.mpy index 6fe3ace..12b45b9 100644 Binary files a/src/lib/adafruit_hid/keyboard.mpy and b/src/lib/adafruit_hid/keyboard.mpy differ diff --git a/src/lib/adafruit_hid/keyboard_layout.py b/src/lib/adafruit_hid/keyboard_layout.py deleted file mode 100644 index f419adc..0000000 --- a/src/lib/adafruit_hid/keyboard_layout.py +++ /dev/null @@ -1,106 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Dan Halbert for Adafruit Industries -# -# SPDX-License-Identifier: MIT - -""" -`adafruit_hid.keyboard_layout_us.KeyboardLayoutUS` -======================================================= - -* Author(s): Dan Halbert, AngainorDev -""" - -from .keycode import Keycode - - -class KeyboardLayout: - """Map ASCII characters to appropriate keypresses on a standard US PC keyboard. - - Non-ASCII characters and most control characters will raise an exception. - """ - # We use the top bit of each byte (0x80) to indicate - # that the shift key should be pressed, and an extra 9th bit 0x100 for AltGr - SHIFT_FLAG = 0x80 - ALTGR_FLAG = 0x100 - ASCII_TO_KEYCODE = () - NEED_ALTGR = "" - - def __init__(self, keyboard): - """Specify the layout for the given keyboard. - - :param keyboard: a Keyboard object. Write characters to this keyboard when requested. - - Example:: - - kbd = Keyboard(usb_hid.devices) - layout = KeyboardLayoutUS(kbd) - """ - - self.keyboard = keyboard - - def write(self, string): - """Type the string by pressing and releasing keys on my keyboard. - - :param string: A string of ASCII characters. - :raises ValueError: if any of the characters are not ASCII or have no keycode - (such as some control characters). - - Example:: - - # Write abc followed by Enter to the keyboard - layout.write('abc\\n') - """ - for char in string: - keycode = self._char_to_keycode(char) - if char in self.NEED_ALTGR: - # Add altgr modifier - self.keyboard.press(Keycode.RIGHT_ALT) - # If this is a shifted char, clear the SHIFT flag and press the SHIFT key. - if keycode & self.SHIFT_FLAG: - keycode &= ~self.SHIFT_FLAG - self.keyboard.press(Keycode.SHIFT) - self.keyboard.press(keycode) - self.keyboard.release_all() - - def keycodes(self, char): - """Return a tuple of keycodes needed to type the given character. - - :param char: A single ASCII character in a string. - :type char: str of length one. - :returns: tuple of Keycode keycodes. - :raises ValueError: if ``char`` is not ASCII or there is no keycode for it. - - Examples:: - - # Returns (Keycode.TAB,) - keycodes('\t') - # Returns (Keycode.A,) - keycodes('a') - # Returns (Keycode.SHIFT, Keycode.A) - keycodes('A') - # Raises ValueError because it's a accented e and is not ASCII - keycodes('é') - """ - keycode = self._char_to_keycode(char) - if keycode & self.SHIFT_FLAG: - return (Keycode.SHIFT, keycode & ~self.SHIFT_FLAG) - if char in self.NEED_ALTGR: - return (Keycode.RIGHT_ALT, keycode) - - return (keycode,) - - def _above128charval_to_keycode(self, char_val): - raise ValueError("Not an ASCII character.") - - def _char_to_keycode(self, char): - """Return the HID keycode for the given ASCII character, with the SHIFT_FLAG possibly set. - - If the character requires pressing the Shift key, the SHIFT_FLAG bit is set. - You must clear this bit before passing the keycode in a USB report. - """ - char_val = ord(char) - if char_val > 128: - return self._above128charval_to_keycode(char) - keycode = self.ASCII_TO_KEYCODE[char_val] - if keycode == 0: - raise ValueError("No keycode available for character.") - return keycode diff --git a/src/lib/adafruit_hid/keyboard_layout_base.mpy b/src/lib/adafruit_hid/keyboard_layout_base.mpy new file mode 100644 index 0000000..61147d7 Binary files /dev/null and b/src/lib/adafruit_hid/keyboard_layout_base.mpy differ diff --git a/src/lib/adafruit_hid/keyboard_layout_fr.py b/src/lib/adafruit_hid/keyboard_layout_fr.py deleted file mode 100644 index 63fa6a8..0000000 --- a/src/lib/adafruit_hid/keyboard_layout_fr.py +++ /dev/null @@ -1,194 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Dan Halbert for Adafruit Industries -# -# SPDX-License-Identifier: MIT - -""" -`adafruit_hid.keyboard_layout_us.KeyboardLayoutUS` -======================================================= - -* Author(s): Dan Halbert, maditnerd, AngainorDev -""" - -from .keyboard_layout import KeyboardLayout - - -class KeyboardLayoutFR(KeyboardLayout): - """Map ASCII characters to appropriate keypresses on a standard FR PC keyboard. - From https://github.com/adafruit/Adafruit_CircuitPython_HID/pull/54 - Non-ASCII characters and most control characters will raise an exception. - """ - - # The ASCII_TO_KEYCODE bytes object is used as a table to maps ASCII 0-127 - # to the corresponding # keycode on a US 104-key keyboard. - # The user should not normally need to use this table, - # but it is not marked as private. - # - # Because the table only goes to 127, we use the top bit of each byte (ox80) to indicate - # that the shift key should be pressed. So any values 0x{8,9,a,b}* are shifted characters. - # - # The Python compiler will concatenate all these bytes literals into a single bytes object. - # Micropython/CircuitPython will store the resulting bytes constant in flash memory - # if it's in a .mpy file, so it doesn't use up valuable RAM. - # - # \x00 entries have no keyboard key and so won't be sent. - ASCII_TO_KEYCODE = ( - b"\x00" # NUL - b"\x00" # SOH - b"\x00" # STX - b"\x00" # ETX - b"\x00" # EOT - b"\x00" # ENQ - b"\x00" # ACK - b"\x00" # BEL \a - b"\x2a" # BS BACKSPACE \b (called DELETE in the usb.org document) - b"\x2b" # TAB \t - b"\x28" # LF \n (called Return or ENTER in the usb.org document) - b"\x00" # VT \v - b"\x00" # FF \f - b"\x00" # CR \r - b"\x00" # SO - b"\x00" # SI - b"\x00" # DLE - b"\x00" # DC1 - b"\x00" # DC2 - b"\x00" # DC3 - b"\x00" # DC4 - b"\x00" # NAK - b"\x00" # SYN - b"\x00" # ETB - b"\x00" # CAN - b"\x00" # EM - b"\x00" # SUB - b"\x29" # ESC - b"\x00" # FS - b"\x00" # GS - b"\x00" # RS - b"\x00" # US - b"\x2c" # SPACE - b"\x38" # ! x1e|SHIFT_FLAG (shift 1) - b"\x20" # " x34|SHIFT_FLAG (shift ') - b"\xe0" # # x20|SHIFT_FLAG (shift 3) - b"\x30" # $ x21|SHIFT_FLAG (shift 4) - b"\xb4" # % x22|SHIFT_FLAG (shift 5) - b"\x1e" # & x24|SHIFT_FLAG (shift 7) - b"\x21" # ' - b"\x22" # ( x26|SHIFT_FLAG (shift 9) - b"\x2d" # ) x27|SHIFT_FLAG (shift 0) - b"\x31" # * x25|SHIFT_FLAG (shift 8) - b"\xae" # + x2e|SHIFT_FLAG (shift =) - b"\x10" # , - b"\x23" # - - b"\xb6" # . - b"\xb7" # / - b"\xa7" # 0 - b"\x9e" # 1 - b"\x9f" # 2 - b"\xa0" # 3 - b"\xa1" # 4 - b"\xa2" # 5 - b"\xa3" # 6 - b"\xa4" # 7 - b"\xa5" # 8 - b"\xa6" # 9 - b"\x37" # : x33|SHIFT_FLAG (shift ;) - b"\x36" # ; - b"\x64" # < x36|SHIFT_FLAG (shift ,) - b"\x2e" # = - b"\x03" # > x37|SHIFT_FLAG (shift .) - b"\x90" # ? x38|SHIFT_FLAG (shift /) - b"\x27" # @ x1f|SHIFT_FLAG (shift 2) - b"\x94" # A x04|SHIFT_FLAG (shift a) - b"\x85" # B x05|SHIFT_FLAG (etc.) - b"\x86" # C x06|SHIFT_FLAG - b"\x87" # D x07|SHIFT_FLAG - b"\x88" # E x08|SHIFT_FLAG - b"\x89" # F x09|SHIFT_FLAG - b"\x8a" # G x0a|SHIFT_FLAG - b"\x8b" # H x0b|SHIFT_FLAG - b"\x8c" # I x0c|SHIFT_FLAG - b"\x8d" # J x0d|SHIFT_FLAG - b"\x8e" # K x0e|SHIFT_FLAG - b"\x8f" # L x0f|SHIFT_FLAG - b"\xb3" # M x10|SHIFT_FLAG - b"\x91" # N x11|SHIFT_FLAG - b"\x92" # O x12|SHIFT_FLAG - b"\x93" # P x13|SHIFT_FLAG - b"\x84" # Q x14|SHIFT_FLAG - b"\x95" # R x15|SHIFT_FLAG - b"\x96" # S x16|SHIFT_FLAG - b"\x97" # T x17|SHIFT_FLAG - b"\x98" # U x18|SHIFT_FLAG - b"\x99" # V x19|SHIFT_FLAG - b"\x9d" # W x1a|SHIFT_FLAG - b"\x9b" # X x1b|SHIFT_FLAG - b"\x9c" # Y x1c|SHIFT_FLAG - b"\x9a" # Z x1d|SHIFT_FLAG - b"\x22" # [ - b"\x25" # \ backslash - b"\x2d" # ] - b"\x26" # ^ x23|SHIFT_FLAG (shift 6) - b"\x25" # _ x2d|SHIFT_FLAG (shift -) - b"\x24" # ` - b"\x14" # a - b"\x05" # b - b"\x06" # c - b"\x07" # d - b"\x08" # e - b"\x09" # f - b"\x0a" # g - b"\x0b" # h - b"\x0c" # i - b"\x0d" # j - b"\x0e" # k - b"\x0f" # l - b"\x33" # m - b"\x11" # n - b"\x12" # o - b"\x13" # p - b"\x04" # q - b"\x15" # r - b"\x16" # s - b"\x17" # t - b"\x18" # u - b"\x19" # v - b"\x1d" # w - b"\x1b" # x - b"\x1c" # y - b"\x1a" # z - b"\x21" # { x2f|SHIFT_FLAG (shift [) - b"\x23" # | x31|SHIFT_FLAG (shift \) - b"\x2e" # } x30|SHIFT_FLAG (shift ]) - b"\x1f" # ~ x35|SHIFT_FLAG (shift `) - b"\x4c" # DEL DELETE (called Forward Delete in usb.org document) - ) - - NEED_ALTGR = "~{[|`\\^@]}€" - - def _above128charval_to_keycode(self, char_val): - """Return keycode for above 128 ascii codes. - - Since the values are sparse, this may be more space efficient than bloating the table above - or adding a dict. - - :param char_val: ascii char value - :return: keycode, with modifiers if needed - """ - if char_val == 224: # à - keycode = 0x27 - elif char_val == 231: # ç - keycode = 0x26 - elif char_val == 232: # è - keycode = 0x24 - elif char_val == 233: # é - keycode = 0x1f - elif char_val == 249: # ù - keycode = 0x34 - elif char_val == 8364: # € - keycode = 0x08 # altgr will be added thanks to NEED_ALTGR - elif char_val == 176: # ° - keycode = 0xad - #  TODO: add missing ÀÈÉÙ - else: - raise ValueError("Not an ASCII character.") - - return keycode diff --git a/src/lib/adafruit_hid/keyboard_layout_us.mpy b/src/lib/adafruit_hid/keyboard_layout_us.mpy new file mode 100644 index 0000000..7b3398c Binary files /dev/null and b/src/lib/adafruit_hid/keyboard_layout_us.mpy differ diff --git a/src/lib/adafruit_hid/keyboard_layout_us.py b/src/lib/adafruit_hid/keyboard_layout_us.py deleted file mode 100644 index 8b908e2..0000000 --- a/src/lib/adafruit_hid/keyboard_layout_us.py +++ /dev/null @@ -1,164 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Dan Halbert for Adafruit Industries -# -# SPDX-License-Identifier: MIT - -""" -`adafruit_hid.keyboard_layout_us.KeyboardLayoutUS` -======================================================= - -* Author(s): Dan Halbert, AngainorDev -""" - -from .keyboard_layout import KeyboardLayout - - -class KeyboardLayoutUS(KeyboardLayout): - """Map ASCII characters to appropriate keypresses on a standard US PC keyboard. - - Non-ASCII characters and most control characters will raise an exception. - """ - - # The ASCII_TO_KEYCODE bytes object is used as a table to maps ASCII 0-127 - # to the corresponding # keycode on a US 104-key keyboard. - # The user should not normally need to use this table, - # but it is not marked as private. - # - # Because the table only goes to 127, we use the top bit of each byte (ox80) to indicate - # that the shift key should be pressed. So any values 0x{8,9,a,b}* are shifted characters. - # - # The Python compiler will concatenate all these bytes literals into a single bytes object. - # Micropython/CircuitPython will store the resulting bytes constant in flash memory - # if it's in a .mpy file, so it doesn't use up valuable RAM. - # - # \x00 entries have no keyboard key and so won't be sent. - ASCII_TO_KEYCODE = ( - b"\x00" # NUL - b"\x00" # SOH - b"\x00" # STX - b"\x00" # ETX - b"\x00" # EOT - b"\x00" # ENQ - b"\x00" # ACK - b"\x00" # BEL \a - b"\x2a" # BS BACKSPACE \b (called DELETE in the usb.org document) - b"\x2b" # TAB \t - b"\x28" # LF \n (called Return or ENTER in the usb.org document) - b"\x00" # VT \v - b"\x00" # FF \f - b"\x00" # CR \r - b"\x00" # SO - b"\x00" # SI - b"\x00" # DLE - b"\x00" # DC1 - b"\x00" # DC2 - b"\x00" # DC3 - b"\x00" # DC4 - b"\x00" # NAK - b"\x00" # SYN - b"\x00" # ETB - b"\x00" # CAN - b"\x00" # EM - b"\x00" # SUB - b"\x29" # ESC - b"\x00" # FS - b"\x00" # GS - b"\x00" # RS - b"\x00" # US - b"\x2c" # SPACE - b"\x9e" # ! x1e|SHIFT_FLAG (shift 1) - b"\xb4" # " x34|SHIFT_FLAG (shift ') - b"\xa0" # # x20|SHIFT_FLAG (shift 3) - b"\xa1" # $ x21|SHIFT_FLAG (shift 4) - b"\xa2" # % x22|SHIFT_FLAG (shift 5) - b"\xa4" # & x24|SHIFT_FLAG (shift 7) - b"\x34" # ' - b"\xa6" # ( x26|SHIFT_FLAG (shift 9) - b"\xa7" # ) x27|SHIFT_FLAG (shift 0) - b"\xa5" # * x25|SHIFT_FLAG (shift 8) - b"\xae" # + x2e|SHIFT_FLAG (shift =) - b"\x36" # , - b"\x2d" # - - b"\x37" # . - b"\x38" # / - b"\x27" # 0 - b"\x1e" # 1 - b"\x1f" # 2 - b"\x20" # 3 - b"\x21" # 4 - b"\x22" # 5 - b"\x23" # 6 - b"\x24" # 7 - b"\x25" # 8 - b"\x26" # 9 - b"\xb3" # : x33|SHIFT_FLAG (shift ;) - b"\x33" # ; - b"\xb6" # < x36|SHIFT_FLAG (shift ,) - b"\x2e" # = - b"\xb7" # > x37|SHIFT_FLAG (shift .) - b"\xb8" # ? x38|SHIFT_FLAG (shift /) - b"\x9f" # @ x1f|SHIFT_FLAG (shift 2) - b"\x84" # A x04|SHIFT_FLAG (shift a) - b"\x85" # B x05|SHIFT_FLAG (etc.) - b"\x86" # C x06|SHIFT_FLAG - b"\x87" # D x07|SHIFT_FLAG - b"\x88" # E x08|SHIFT_FLAG - b"\x89" # F x09|SHIFT_FLAG - b"\x8a" # G x0a|SHIFT_FLAG - b"\x8b" # H x0b|SHIFT_FLAG - b"\x8c" # I x0c|SHIFT_FLAG - b"\x8d" # J x0d|SHIFT_FLAG - b"\x8e" # K x0e|SHIFT_FLAG - b"\x8f" # L x0f|SHIFT_FLAG - b"\x90" # M x10|SHIFT_FLAG - b"\x91" # N x11|SHIFT_FLAG - b"\x92" # O x12|SHIFT_FLAG - b"\x93" # P x13|SHIFT_FLAG - b"\x94" # Q x14|SHIFT_FLAG - b"\x95" # R x15|SHIFT_FLAG - b"\x96" # S x16|SHIFT_FLAG - b"\x97" # T x17|SHIFT_FLAG - b"\x98" # U x18|SHIFT_FLAG - b"\x99" # V x19|SHIFT_FLAG - b"\x9a" # W x1a|SHIFT_FLAG - b"\x9b" # X x1b|SHIFT_FLAG - b"\x9c" # Y x1c|SHIFT_FLAG - b"\x9d" # Z x1d|SHIFT_FLAG - b"\x2f" # [ - b"\x31" # \ backslash - b"\x30" # ] - b"\xa3" # ^ x23|SHIFT_FLAG (shift 6) - b"\xad" # _ x2d|SHIFT_FLAG (shift -) - b"\x35" # ` - b"\x04" # a - b"\x05" # b - b"\x06" # c - b"\x07" # d - b"\x08" # e - b"\x09" # f - b"\x0a" # g - b"\x0b" # h - b"\x0c" # i - b"\x0d" # j - b"\x0e" # k - b"\x0f" # l - b"\x10" # m - b"\x11" # n - b"\x12" # o - b"\x13" # p - b"\x14" # q - b"\x15" # r - b"\x16" # s - b"\x17" # t - b"\x18" # u - b"\x19" # v - b"\x1a" # w - b"\x1b" # x - b"\x1c" # y - b"\x1d" # z - b"\xaf" # { x2f|SHIFT_FLAG (shift [) - b"\xb1" # | x31|SHIFT_FLAG (shift \) - b"\xb0" # } x30|SHIFT_FLAG (shift ]) - b"\xb5" # ~ x35|SHIFT_FLAG (shift `) - b"\x4c" # DEL DELETE (called Forward Delete in usb.org document) - ) - diff --git a/src/lib/adafruit_hid/keycode.mpy b/src/lib/adafruit_hid/keycode.mpy index 106bba1..4a30986 100644 Binary files a/src/lib/adafruit_hid/keycode.mpy and b/src/lib/adafruit_hid/keycode.mpy differ diff --git a/src/lib/adafruit_hid/mouse.mpy b/src/lib/adafruit_hid/mouse.mpy index 6289bd4..9e09cc3 100644 Binary files a/src/lib/adafruit_hid/mouse.mpy and b/src/lib/adafruit_hid/mouse.mpy differ diff --git a/src/lib/adafruit_progressbar.mpy b/src/lib/adafruit_progressbar.mpy deleted file mode 100644 index 01ccf6e..0000000 Binary files a/src/lib/adafruit_progressbar.mpy and /dev/null differ diff --git a/src/lib/adafruit_progressbar/__init__.mpy b/src/lib/adafruit_progressbar/__init__.mpy new file mode 100644 index 0000000..4c2855d Binary files /dev/null and b/src/lib/adafruit_progressbar/__init__.mpy differ diff --git a/src/lib/adafruit_progressbar/horizontalprogressbar.mpy b/src/lib/adafruit_progressbar/horizontalprogressbar.mpy new file mode 100644 index 0000000..dede30e Binary files /dev/null and b/src/lib/adafruit_progressbar/horizontalprogressbar.mpy differ diff --git a/src/lib/adafruit_progressbar/progressbar.mpy b/src/lib/adafruit_progressbar/progressbar.mpy new file mode 100644 index 0000000..233d429 Binary files /dev/null and b/src/lib/adafruit_progressbar/progressbar.mpy differ diff --git a/src/lib/adafruit_progressbar/verticalprogressbar.mpy b/src/lib/adafruit_progressbar/verticalprogressbar.mpy new file mode 100644 index 0000000..046ad45 Binary files /dev/null and b/src/lib/adafruit_progressbar/verticalprogressbar.mpy differ diff --git a/src/lib/adafruit_register/i2c_bcd_alarm.mpy b/src/lib/adafruit_register/i2c_bcd_alarm.mpy index 991465d..1e9a8dc 100644 Binary files a/src/lib/adafruit_register/i2c_bcd_alarm.mpy and b/src/lib/adafruit_register/i2c_bcd_alarm.mpy differ diff --git a/src/lib/adafruit_register/i2c_bcd_datetime.mpy b/src/lib/adafruit_register/i2c_bcd_datetime.mpy index b27a58b..87d5ce1 100644 Binary files a/src/lib/adafruit_register/i2c_bcd_datetime.mpy and b/src/lib/adafruit_register/i2c_bcd_datetime.mpy differ diff --git a/src/lib/adafruit_register/i2c_bit.mpy b/src/lib/adafruit_register/i2c_bit.mpy index 9348454..f71b01b 100644 Binary files a/src/lib/adafruit_register/i2c_bit.mpy and b/src/lib/adafruit_register/i2c_bit.mpy differ diff --git a/src/lib/adafruit_register/i2c_bits.mpy b/src/lib/adafruit_register/i2c_bits.mpy index c526647..33cc8cc 100644 Binary files a/src/lib/adafruit_register/i2c_bits.mpy and b/src/lib/adafruit_register/i2c_bits.mpy differ diff --git a/src/lib/adafruit_register/i2c_struct.mpy b/src/lib/adafruit_register/i2c_struct.mpy index 59925e6..9a64c35 100644 Binary files a/src/lib/adafruit_register/i2c_struct.mpy and b/src/lib/adafruit_register/i2c_struct.mpy differ diff --git a/src/lib/adafruit_register/i2c_struct_array.mpy b/src/lib/adafruit_register/i2c_struct_array.mpy index a052f15..dcba0f1 100644 Binary files a/src/lib/adafruit_register/i2c_struct_array.mpy and b/src/lib/adafruit_register/i2c_struct_array.mpy differ diff --git a/src/lib/adafruit_st7789.mpy b/src/lib/adafruit_st7789.mpy index 577e7f5..1a0db60 100644 Binary files a/src/lib/adafruit_st7789.mpy and b/src/lib/adafruit_st7789.mpy differ diff --git a/src/lib/hmac.py b/src/lib/hmac.py index 79ec923..3a2d19a 100644 --- a/src/lib/hmac.py +++ b/src/lib/hmac.py @@ -3,7 +3,7 @@ Implements the HMAC algorithm as described by RFC 2104. """ -import warnings as _warnings +#import warnings as _warnings import binascii from adafruit_hashlib import sha1 as SHA1 PendingDeprecationWarning = None @@ -47,9 +47,9 @@ def __init__(self, key, msg=None, digestmod=None): if not isinstance(key, (bytes, bytearray)): raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).__name__) - if digestmod is None: - _warnings.warn("HMAC() without an explicit digestmod argument " - "is deprecated.", PendingDeprecationWarning, 2) + #if digestmod is None: + #_warnings.warn("HMAC() without an explicit digestmod argument " + # "is deprecated.", PendingDeprecationWarning, 2) # digestmod = _hashlib.md5 if callable(digestmod): @@ -62,9 +62,9 @@ def __init__(self, key, msg=None, digestmod=None): if hasattr(self.inner, 'block_size'): blocksize = self.inner.block_size if blocksize < 16: - _warnings.warn('block_size of %d seems too small; using our ' - 'default of %d.' % (blocksize, self.blocksize), - RuntimeWarning, 2) + #_warnings.warn('block_size of %d seems too small; using our ' + # 'default of %d.' % (blocksize, self.blocksize), + # RuntimeWarning, 2) blocksize = self.blocksize else: # _warnings.warn('No block_size attribute on given digest object; Assuming %d.' diff --git a/src/lib/pico_dio.py b/src/lib/pico_dio.py index 7b261ec..6d75616 100644 --- a/src/lib/pico_dio.py +++ b/src/lib/pico_dio.py @@ -4,7 +4,10 @@ import terminalio from adafruit_display_text import label # from adafruit_display_shapes import rect -from adafruit_progressbar import ProgressBar +from adafruit_progressbar.horizontalprogressbar import ( + HorizontalProgressBar, + HorizontalFillDirection, +) from adafruit_st7789 import ST7789 @@ -32,8 +35,8 @@ def get_display(): def get_splash(): - splash = displayio.Group(max_size=10) - text_group2 = displayio.Group(max_size=10, scale=3, x=40, y=20) + splash = displayio.Group() + text_group2 = displayio.Group(scale=3, x=40, y=20) text2 = "Picoth" text_area2 = label.Label(terminalio.FONT, text=text2, color=0x00FF00) text_group2.append(text_area2) @@ -43,15 +46,15 @@ def get_splash(): # OTP screen def get_otp_group(): - otp_group = displayio.Group(max_size=10, scale=1, x=0, y=0) + otp_group = displayio.Group(scale=1, x=0, y=0) # OTP Code - text_group1 = displayio.Group(max_size=10, scale=6, x=15, y=100) + text_group1 = displayio.Group(scale=6, x=15, y=100) text1 = "999999" text_area1 = label.Label(terminalio.FONT, text=text1, color=0x00FF00) text_group1.append(text_area1) # Subgroup for text scaling otp_group.append(text_group1) # OTP label - text_group2 = displayio.Group(max_size=10, scale=3, x=40, y=20) + text_group2 = displayio.Group(scale=3, x=40, y=20) text2 = "OTP Label" text_area2 = label.Label(terminalio.FONT, text=text2, color=0xFF0000) text_group2.append(text_area2) @@ -65,25 +68,31 @@ def get_otp_group(): rect2 = rect.Rect(0, 70, 120, 4, fill=0x00fa00) otp_group.append(rect2) """ - progress = ProgressBar(0, 60, 240, 9, bar_color=0x00fa00, outline_color=0x1e1e1e) + progress = HorizontalProgressBar( + (0, 60), + (249, 9), + outline_color=0x1e1e1e, + bar_color=0x00fa00, + direction=HorizontalFillDirection.LEFT_TO_RIGHT, + ) otp_group.append(progress) return otp_group, text_area1, text_area2, progress def get_page_group(): - page_group = displayio.Group(max_size=10, scale=1, x=0, y=0) + page_group = displayio.Group(scale=1, x=0, y=0) # Mode - text_group1 = displayio.Group(max_size=10, scale=4, x=5, y=20) + text_group1 = displayio.Group(scale=4, x=5, y=20) text_area1 = label.Label(terminalio.FONT, text="xx", color=0x00FF00) text_group1.append(text_area1) # Subgroup for text scaling page_group.append(text_group1) # Page number - text_group2 = displayio.Group(max_size=10, scale=3, x=70, y=70) + text_group2 = displayio.Group(scale=3, x=70, y=70) text_area2 = label.Label(terminalio.FONT, text="Page X", color=0xFF0000) text_group2.append(text_area2) # Subgroup for text scaling page_group.append(text_group2) # Label - text_group3 = displayio.Group(max_size=10, scale=3, x=10, y=110) + text_group3 = displayio.Group(scale=3, x=10, y=110) text_area3 = label.Label(terminalio.FONT, text="Label", color=0xFF0000) text_group3.append(text_area3) page_group.append(text_group3) diff --git a/src/params.sample.json b/src/params.sample.json deleted file mode 100644 index b3d87b0..0000000 --- a/src/params.sample.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "check": "ff00112233", - "layout": "fr", - "time_offset": -3600, - "pages":[ - {"type": "TOTP", - "name": " Crypto OTPs", - "keys": [ - ["","000000",""], - ["qTrade","FF7829","ftslvgd2zddprptn"], - ["Bittrex","0081EB","stflvgd2zddprptn"], - ["Nash.io","5790FF","ltfsvgd2zddprptn"], - ["Github","F34F29","vtfslgd2zddprptn"], - ["","000000",""], - ["","000000",""], - ["Discord","4285F4","fslvgd2zddprptnt"], - ["","000000",""], - ["","000000",""] - ] - }, - {"type": "TOTP", - "name": " TEST OTPs", - "keys": [ - ["TEST 0","444444","ftslvgd2zddprptn"], - ["TEST 1","FF0000","tslvgd2zddprptnf"], - ["TEST 2","00FF00","slvgd2zddprptnft"], - ["TEST 3","0000FF","lvgd2zddprptnfts"], - ["TEST 4","00FF00","vgd2zddprptnftsl"], - ["TEST 5","0000FF","gd2zddprptnftslv"], - ["TEST 6","FF0000","d2zddprptnftslvg"], - ["TEST 7","0000FF","2zddprptnftslvgd"], - ["TEST 8","FF0000","zddprptnftslvgd2"], - ["TEST 9","00FF00","ddprptnftslvgd2z"] - ] - } - ] -}