Skip to content

Instantly share code, notes, and snippets.

@anthonykeane
Created August 10, 2014 08:03
Show Gist options
  • Save anthonykeane/9c7084fbf78f6cd2d0d2 to your computer and use it in GitHub Desktop.
Save anthonykeane/9c7084fbf78f6cd2d0d2 to your computer and use it in GitHub Desktop.
/* OctoWS2811 BasicTest.ino - Basic RGB LED Test
http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
Copyright (c) 2013 Paul Stoffregen, PJRC.COM, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Required Connections
--------------------
pin 2: LED Strip #1 OctoWS2811 drives 8 LED Strips.
pin 14: LED strip #2 All 8 are the same length.
pin 7: LED strip #3
pin 8: LED strip #4 A 100 ohm resistor should used
pin 6: LED strip #5 between each Teensy pin and the
pin 20: LED strip #6 wire to the LED strip, to minimize
pin 21: LED strip #7 high frequency ringining & noise.
pin 5: LED strip #8
pin 15 & 16 - Connect together, but do not use
pin 4 - Do not use
pin 3 - Do not use as PWM. Normal use is ok.
This test is useful for checking if your LED strips work, and which
color config (WS2811_RGB, WS2811_GRB, etc) they require.
*/
#include <OctoWS2811.h>
#ifndef FIXEDNUMS15x31_H
#define FIXEDNUMS15x31_H
#include <inttypes.h>
#include <avr/pgmspace.h>
#define RED 0x010000
#define GREEN 0x000100
#define BLUE 0x000001
#define YELLOW 0x010100
#define PINK 0x030001
#define ORANGE 0xE05800
#define BLACK 0x000000
#define WHITE 0x010101
//#define RED 0xFF0000
//#define GREEN 0x00FF00
//#define BLUE 0x0000FF
//#define YELLOW 0xFFFF00
//#define PINK 0xFF1088
//#define ORANGE 0xE05800
#define WHITE 0xFFFFFF
static uint8_t font[] PROGMEM = {
0x3F,0xFC, 0x7F,0xFE, 0xFF,0xFF, 0xE0,0x07, 0xE0,0x07, 0xE0,0x07, 0xE0,0x07, 0xFF,0xFF, 0x7F,0xFE, 0x3F,0xFC, //char 0 verticaly aligned
B00000000, B00000000,
B00000000, B00000000,
B01100000, B00000111,
B01100000, B00000111,
B11111111, B11111111,
B11111111, B11111111,
B11111111, B11111111,
B00000000, B00000111,
B00000000, B00000111,
B00000000, B00000000, // char 1
B00110000, B00000111,
B01110000, B00001111,
B11110000, B00011111,
B11100000, B00111111,
B11100000, B01110111,
B11100000, B11100111,
B11100001, B11000111,
B11111111, B10000111,
B01111111, B00000111,
B00111110, B00000111, // char 2
0
};
#endif
const int ledsPerStrip = 110;
DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
//HardwareSerial Uart = HardwareSerial();
void setup() {
//Serial.begin(9600);
leds.begin();
leds.show();
}
int PINoffset = ledsPerStrip; // cos pin 6 is used this is the 5th so skip the first (5-1)* ledsPerStrip
//int col = 1;
uint8_t line = 0xff;
int i = leds.numPixels();
void loop()
{
for (int q=0; q < (10); q++)
{
show(q,'1',5,WHITE);
show(q,'0',4,WHITE);
show(q,'2',3,WHITE);
// show(q,4,GREEN);
// show(q,3,BLUE);
// show(q,2,RED);
// show(q,1,PINK);
// show(q,0,YELLOW);
//
leds.show();
}
clear();
delayMicroseconds(5000);
}
/*
position is the char position
row is the vertical bit pattern within the font char
c is the char to display
*/
void show(int position, int c, int row, int colour)
{
c = (c - '0')*20;
line = pgm_read_byte(font+(position*2)+c);
for (i=0; i < (8); i++)
{
{
if (line & 0x01) {
leds.setPixel(i+8+(PINoffset*7)+18*row, colour);
}
else
{
leds.setPixel(i+8+(PINoffset*7)+18*row,BLACK );
}
line >>= 1;
}
}
line = pgm_read_byte(font+(position*2)+1+c);
for (i=0; i < (8); i++)
{
//if (i<8)
{
if (line & 0x01) {
leds.setPixel(i+(PINoffset*7)+18*row, colour);
}
else
{
leds.setPixel(i+(PINoffset*7)+18*row, BLACK);
}
line >>= 1;
}
}
}
void clear()
{
for (i=0; i < (ledsPerStrip); i++)
{
leds.setPixel(i+(PINoffset*7), BLACK);
}
leds.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment