Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify coordinate loading #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions xmaslights-spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def xmaslight():
import neopixel
import re
import math
import json

# You are welcome to add any of these:
# import random
Expand All @@ -24,18 +25,8 @@ def xmaslight():

coordfilename = "Python/coords.txt"

fin = open(coordfilename,'r')
coords_raw = fin.readlines()

coords_bits = [i.split(",") for i in coords_raw]

coords = []

for slab in coords_bits:
new_coord = []
for i in slab:
new_coord.append(int(re.sub(r'[^-\d]','', i)))
coords.append(new_coord)
with open(coordfilename,'r') as fin:
coords = list(map(json.loads, fin.readlines()))

#set up the pixels (AKA 'LEDs')
PIXEL_COUNT = len(coords) # this should be 500
Expand Down