Skip to content

Instantly share code, notes, and snippets.

View connornishijima's full-sized avatar

Lixie Labs connornishijima

View GitHub Profile
@connornishijima
connornishijima / web_flasher_rx.ino
Created December 20, 2023 02:28
SB Light Transfer Receiver
/*
This is designed to run on stock Sensory Bridge hardware, and uses the Sweet Spot LEDs to receive data
from the tool at https://sensorybridge.rocks/light_transfer/ when you hold your phone upside down 2-3
inches above the LEDs! Binary data is sent through screen flashes and decoded by this Arduino Sketch,
printing the result to the Serial Monitor. It uses a CRC8 byte at the end of every packet to determine
the validity of the data sent, but no forward error correction like Hamming/Reed-Solomon codes yet.
Unfortunately, I can't guarantee this works on anything but a stock Sensory Bridge with OEM LEDs, so
this will never be the only option available for sending data to the device, but one of many.
@connornishijima
connornishijima / code.py
Last active December 16, 2023 02:41
"Lovely Music Generator" For CircuitPython by LIXIE LABS
# ----------------------------------------------------------------------------
# LOVELY MUSIC GENERATOR by LIXIE LABS
# https://leds.social/@lixielabs
#
# Plays random notes/chords from the Amaj7 scale in a pleasing fashion using
# audiopwmio to drive a speaker with five synthio sine voices and ADSR envelopes.
# Import dependencies
import time
import board
@connornishijima
connornishijima / christmas_light_fixer.h
Created December 9, 2023 22:05
Christmas Light Fixer (Incandescent LUT)
// This function reduces harsh blue tones in RGB LED lights, bringing
// them closer to the look of retro tinted incandescent bulbs.
//
// All input colors to the christmas_light_fixer() function are multiplied
// by a LUT of a warm white, reducing the power of the blue spectrum while
// preserving the brightness of the yellow spectrum.
CRGB christmas_light_fixer( CRGB input_color ){
CRGB incandescent_lookup = CRGB( 255, 113, 40 );
CRGB out_color = input_color;
@connornishijima
connornishijima / lixie_aa_polygon.cpp
Last active July 18, 2023 19:38
Anti-aliased 2D Wireframe Rendering Function
// Draws an open-ended polygon using anti-aliased strokes with user-defined subpixel positioning, scaling and opacity.
// The coordinates of the vertices of your polygon are floating point values on or between LED coordinates, not 0.0-1.0
// like UV coordinates. Output is grayscale values (0.0-1.0) written to a global "float mask[Y_SIZE][X_SIZE]" array.
// Polygons are defined as a 2D array of vertices that form a vector shape, no closed shapes officially supported yet.
// On an ESP32-S3, this rasterizes the polygon very, VERY quickly.
void lixie_aa_polygon(float vertices[][2], uint16_t num_vertices, float x_offset, float y_offset, float x_scale, float y_scale, float angle_deg, float opacity) {
// Line thickness
float stroke_width = 1.0; // Alter this
float stroke_width_inv = 1.0 / stroke_width; // Don't alter this
@connornishijima
connornishijima / mothers_day_clock.ino
Last active May 9, 2022 03:24
Mother's Day Clock Firmware
#include <TimeLib.h>
#include <WiFiUdp.h>
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
#include "Pixie_Chroma.h" // ... Include library
PixieChroma pix; // ............ Get class object
WiFiUDP Udp;
#define DATA_PIN 5 // GPIO to use for Pixie Chroma data line
#define PIXIES_X 3 // Total amount and arrangement
@connornishijima
connornishijima / to_string.cpp
Created April 27, 2022 14:37
Compact universal "to_string()" conversion
// Allows for a "print()" function that accepts char* to take any common variable type
// Also allows you to detect the type of any variable if that type was first defined
// in a MAKE_TYPE_INFO(type) macro
// @lixielabs 4/27/22
template <typename t_type> struct type_info { static const char * name; }; // Define type_info
template <typename t_type> const char * type_info<t_type>::name = "unknown"; // Set default state
#define TYPE_NAME(var) type_info< typeof(var) >::name // Macro to parse variable type name
#define MAKE_TYPE_INFO(type) template <> const char * type_info<type>::name = #type; // Macro to define variable type name
@connornishijima
connornishijima / chroma_FPS_test.ino
Last active March 11, 2022 22:24
Quick demo of Pixie Chroma code showing the current frame rate with a rainbow pattern!
#include "Pixie_Chroma.h" // ... Include library (1.0.0 used here)
PixieChroma pix; // ............ Get class object
#define PIXIES_PER_PIN 3 // ... Needed for quad mode
#define PIXIES_X 6 // ... How many Pixie PCBs "wide" is our display?
#define PIXIES_Y 2 // ... How many tall?
void setup() {
pix.begin_quad(PIXIES_PER_PIN, PIXIES_X, PIXIES_Y); // Initialize Pixies
# Pixie driver test abusing SPI bus for clean data transfer at any speed
# If this works, let me know so I can simplify usage!
# Currently it sends a raw byte array below to render images to connected
# Pixies, flashing between a PIX_SMILE icon and a solid color at a visible rate.
# -------------------------------------------------------------------------
# SPI must be enabled using "sudo raspi-config" under "Interfacing Options"
# -------------------------------------------------------------------------
import spidev
@connornishijima
connornishijima / sstv_test.ino
Created March 2, 2020 02:20
ROBOT12 BW on Arduino Uno w/ tone() function and timers! ---- (320x120 image is 1-bit BW stored in PROGMEM bytes)
volatile bool broadcast_done = false;
volatile uint8_t bit_index = 0;
volatile uint16_t byte_index = 0;
volatile uint8_t sync_count = 0;
uint8_t pixel_bit = 0;
uint8_t pixel_byte = 0;
bool bit_changed = false;
const uint8_t image[4800] PROGMEM = {
0, 15, 143, 255, 255, 255, 255, 255, 255, 255, 0, 31, 254, 0, 63, 252, 7, 128, 0, 0, 0, 0, 0, 15, 143, 255, 255, 255, 255, 255, 255, 255, 0, 31, 254, 0, 63, 252, 7, 128, 0, 30, 7, 128, 15, 255, 0, 31, 255, 255, 128, 15, 255, 0, 31, 254, 14, 0, 0, 0, 0, 0, 0, 31, 7, 128, 15, 255, 0, 31, 255, 255, 128, 15, 255, 0, 15, 254, 15, 0, 0, 124, 3, 192, 7, 255, 128, 15, 255, 255, 192, 3, 255, 128, 7, 255, 60, 0, 0, 0, 0, 0, 0, 60, 3, 192, 7, 255, 128, 15, 255, 255, 224, 3, 255, 128, 7, 255, 28, 0, 0, 248, 1, 224, 3, 255, 192, 7, 255, 255, 240, 1, 255, 192, 3, 255, 248, 0, 0, 0, 0, 0, 0, 248, 1, 224, 1, 255, 192, 3, 255, 255, 240, 1, 255, 224, 3, 255, 248, 0, 255, 240, 1, 240, 1, 255, 224, 3, 255, 255, 248, 0, 255, 240, 1, 255, 240, 0, 255, 255, 255, 255, 255, 240, 0, 240,
#include "digitalwritefast.h"
const uint8_t PROGMEM score[] = {0x90,83,0x91,77,0x92,66,0x93,72,1,212,0x80,0x81,0x82,0x83,0,31,0x90,82,0x91,65,0x92,71,0x93,76,1,212,0x80,0x81,0x82,0x83,0,31,0x90,81,0x91,64,0x92,75,0x93,70,1,212,0x80,0x81,0x82,0x83,0,31,0x90,74,0x91,63,0x92,69,0x93,80,1,212,0x81,0x82,0x83,0,31,0x91,79,0x92,73,0x93,62,0x94,68,0x80,1,25,0x81,0x82,0x83,0x84,0,52,0x90,78,0x91,72,0x92,67,0x93,61,1,56,0x80,0x81,0x82,0x83,0,20,0x90,60,0x91,71,0x92,66,0x93,77,10,242,0x82,0,31,0x80,0x81,0x83,1,244,0x90,67,0x91,62,0,68,0x80,0x81,0,34,0x90,67,0x91,62,0,68,0x80,0x81,0,34,0x90,68,0x91,63,0,68,0x80,0x81,0,34,0x90,67,0x91,62,0,68,0x80,0x81,0,34,0x90,67,0x91,62,0,68,0x80,0x81,0,34,0x90,63,0x91,68,0,68,0x80,0x81,0,34,0x90,67,0x91,62,0,68,0x80,0x81,0,34,0x90,67,0x91,62,0,68,0x80,0x81,0,34,0x90,68,0x91,63,0,68,0x80,0x81,0,34,0x90,67,0x91,62,0,68,0x80,0x81,0,34,0x90,62,0x91,67,0,68,0x80,0x81,0,34,0x90,68,0x91,63,0,68,0x80,0x81,0,34,0x90,62,0x91,67,0,68,0x80,0x81,0,34,0x90,63,0x91,68,0,68,0x80,0x81,0,34,0x90,67,0x