Created
August 8, 2023 13:29
-
-
Save TheSofox/de873284cb048d213a6cb7b2a96a8be4 to your computer and use it in GitHub Desktop.
Code for Sofox Protogen ( https://sofoxcentral.com/electronic-costuming/protogen )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_GFX.h> | |
#include <Adafruit_NeoMatrix.h> | |
#include <Adafruit_NeoPixel.h> | |
#define BLACK 0x0000 | |
#define BLUE 0x001F | |
#define RED 0xF800 | |
#define GREEN 0x07E0 | |
#define CYAN 0x07FF | |
#define MAGENTA 0xF81F | |
#define YELLOW 0xFFE0 | |
#define WHITE 0xFFFF | |
#define PIN 6 | |
#define EAR_PIN1 5 | |
#define EAR_PIN2 4 | |
#define EAR_LED_COUNT 6 | |
// TWO 32x8 displays put together makes ONE 32x16 display | |
#define MATRIX_WIDTH 32 | |
#define MATRIX_HEIGHT 16 | |
// MATRIX DECLARATION: | |
// Parameter 1 = width of NeoPixel matrix | |
// Parameter 2 = height of matrix | |
// Parameter 3 = pin number (most are valid) | |
// Parameter 4 = matrix layout flags, add together as needed: | |
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT: | |
// Position of the FIRST LED in the matrix; pick two, e.g. | |
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner. | |
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal | |
// rows or in vertical columns, respectively; pick one or the other. | |
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed | |
// in the same order, or alternate lines reverse direction; pick one. | |
// See example below for these values in action. | |
// Parameter 5 = pixel type flags, add together as needed: | |
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) | |
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) | |
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) | |
// NEO_GRBW Pixels are wired for GRBW bitstream (RGB+W NeoPixel products) | |
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) | |
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, 1, 2, PIN, | |
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + | |
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG + NEO_TILE_ZIGZAG , | |
NEO_GRB + NEO_KHZ800); | |
Adafruit_NeoPixel strip1(EAR_LED_COUNT, EAR_PIN1, NEO_GRB + NEO_KHZ800); | |
Adafruit_NeoPixel strip2(EAR_LED_COUNT, EAR_PIN2, NEO_GRB + NEO_KHZ800); | |
const uint16_t mainColour = matrix.Color(190,30,200); | |
const uint32_t earColour1 = strip1.Color(190,30,200); | |
const uint32_t earColour2 = strip2.Color(190,30,200); | |
uint8_t current_expression[] { | |
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | |
0x7, 0x80, 0x3, 0xc0, 0x3, 0xc0, 0x7, 0x80, 0x1, 0xc0, 0x7, | |
0x0, 0x0, 0xc0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | |
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x80, 0x6, | |
0x0, 0x0, 0xc7, 0x8c, 0x0, 0x0, 0x7c, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 | |
}; | |
void setupMatrix() { | |
matrix.begin(); | |
matrix.setTextWrap(false); | |
matrix.setBrightness(40); | |
matrix.setTextColor(RED); | |
strip1.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) | |
strip1.show(); // Turn OFF all pixels ASAP | |
strip1.setBrightness(40); // Set BRIGHTNESS to about 1/5 (max = 255) | |
strip2.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) | |
strip2.show(); // Turn OFF all pixels ASAP | |
strip2.setBrightness(40); // Set BRIGHTNESS to about 1/5 (max = 255) | |
drawMatrix(); | |
} | |
int x = matrix.width(); | |
int matrix_pass = 0; | |
void setup() { | |
setupMatrix(); | |
} | |
void drawMatrix() { | |
matrix.fillScreen(0); | |
matrix.drawBitmap(0,0,current_expression, 32,16,mainColour); | |
matrix.show(); | |
for(int i=0; i<strip1.numPixels(); i++) { | |
strip1.setPixelColor(i, earColour1); | |
} | |
strip1.show(); | |
for(int i=0; i<strip2.numPixels(); i++) { | |
strip2.setPixelColor(i, earColour2); | |
} | |
strip2.show(); | |
} | |
const int totalData = MATRIX_WIDTH*MATRIX_HEIGHT/8; | |
void clear_expression(){ | |
for(int i=0; i<totalData; i++){ | |
current_expression[i]=0; | |
} | |
} | |
void loop() { | |
drawMatrix(); | |
delay(1000); | |
} | |
void drawText() { | |
uint16_t colors[] ={RED, GREEN, BLUE}; | |
matrix.fillScreen(0); | |
matrix.setCursor(x, 0); | |
matrix.print(F("THANK YOU")); | |
matrix.setCursor(x, 8); | |
matrix.print(F(" TAPE & MERLIN")); | |
if(--x < -96) { | |
x = matrix.width(); | |
if(++matrix_pass >= 3) matrix_pass = 0; | |
matrix.setTextColor(colors[matrix_pass]); | |
} | |
/*matrix.drawPixel(0,0,BLUE); | |
matrix.drawPixel(0,8,YELLOW);*/ | |
matrix.show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment