FW_LED_System_Monitor/patterns.py
Leone, Mark A [LGS] 68989ed8e4 Implement snapshot capability
Rename plugin funcs to make implemenation more intuitive

Add ID for snap. Remove redundant left/right id func. Show err if snap file not found

Track per-file snapshot error
2025-06-29 23:02:44 -04:00

199 lines
No EOL
5.4 KiB
Python

import numpy as np
import re
import os
import sys
import importlib
lightning_bolt_bot = np.array( [[0,0,0,0,0,0,0], # 0
[0,0,0,0,0,1,0], # 1
[0,0,0,0,1,1,0], # 2
[0,0,0,1,1,0,0], # 3
[0,0,1,1,1,0,0], # 4
[0,1,1,1,0,0,0], # 5
[0,1,1,1,1,1,0], # 6
[0,0,0,1,1,1,0], # 7
[0,0,1,1,1,0,0], # 8
[0,0,1,1,0,0,0], # 9
[0,1,1,0,0,0,0], #10
[0,1,0,0,0,0,0], #11
[0,0,0,0,0,0,0]],#12
dtype=bool).T
# Cut out bottom row because top segment is one row shorter
lightning_bolt_top = np.array( [[0,0,0,0,0,0,0], # 0
[0,0,0,0,0,1,0], # 1
[0,0,0,0,1,1,0], # 2
[0,0,0,1,1,0,0], # 3
[0,0,1,1,1,0,0], # 4
[0,1,1,1,0,0,0], # 5
[0,1,1,1,1,1,0], # 6
[0,0,0,1,1,1,0], # 7
[0,0,1,1,1,0,0], # 8
[0,0,1,1,0,0,0], # 9
[0,1,1,0,0,0,0], #10
[0,1,0,0,0,0,0]],#11
dtype=bool).T
# This table represents the 3x3 grid of LEDs to be drawn for each fill ratio
lookup_table = np.array(
[
[
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
],
[
[0, 0, 0],
[0, 1, 0],
[0, 0, 0]
],
[
[0, 1, 0],
[0, 1, 0],
[0, 0, 0]
],
[
[0, 1, 1],
[0, 1, 0],
[0, 0, 0]
],
[
[0, 1, 1],
[0, 1, 1],
[0, 0, 0]
],
[
[0, 1, 1],
[0, 1, 1],
[0, 0, 1]
],
[
[0, 1, 1],
[0, 1, 1],
[0, 1, 1]
],
[
[0, 1, 1],
[0, 1, 1],
[1, 1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