Skip to content

Instantly share code, notes, and snippets.

@joeycastillo
Created December 4, 2024 18:55
Show Gist options
  • Save joeycastillo/1f6de9d291d85fe1f1714a6aeefc1fe4 to your computer and use it in GitHub Desktop.
Save joeycastillo/1f6de9d291d85fe1f1714a6aeefc1fe4 to your computer and use it in GitHub Desktop.
Convert marimapper 3D map of LEDs into Pixelblaze-compatible array of points
# open csv file and convert to JSON
import csv, json
with open('led_map_3d.csv', 'r') as f:
reader = csv.reader(f)
data = list(reader)
# remove first row of csv file (header)
data = data[1:]
output = []
# assumes 800 LEDs on your Pixelblaze, change as needed.
# output format is an array of 800 points in the form of [x,y,z]
for i in range (0, 800):
# not all points are in the CSV
# iterate over each row and see if an index matches i
# if it does, add the point to output
# if not, add [0,0,0]
found = False
for j in range (0, len(data)):
index, x, y, z, _, _, _, _ = data[j]
if int(index) == i:
# output.append([float(x), float(y), float(z)])
output.append([-float(x), float(z), -float(y)])
found = True
break
if not found:
output.append([0,0,0])
print(json.dumps(output))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment