diff --git a/PoC/VdL_demo/main.ino b/PoC/VdL_demo/main.ino new file mode 100644 index 0000000..9f7c25c --- /dev/null +++ b/PoC/VdL_demo/main.ino @@ -0,0 +1,116 @@ +#include "Adafruit_GFX.h" +#include "RGBmatrixPanel.h" + +#define CLK 8 +#define LAT A3 +#define OE 9 +#define SIZEOF_BITMAP 24 +#define N 0 +#define O 1 +#define T 2 +#define R 3 +#define P 4 +#define I 5 +#define C 6 +#define D 7 +#define E 8 +#define S 9 +#define G 10 + +#define Y 3 + + +extern prog_uchar pacman_bitmaps[]; +extern prog_uchar letter_bitmaps[]; +extern prog_uchar invader_bitmaps[]; + +RGBmatrixPanel matrix(A0, A1, A2, CLK, LAT, OE, true); +uint16_t black = matrix.Color444(0, 0, 0); +uint16_t yellow = matrix.Color444(15, 15, 0); +uint16_t darkyellow = matrix.Color444(1, 1, 0); +uint16_t red = matrix.Color444(15, 0, 0); +uint16_t white = matrix.Color444(15, 15, 15); +uint16_t pink = matrix.Color444(15, 3, 15); +uint16_t palePink = matrix.Color444(15, 8, 15); +uint16_t blue = matrix.Color444(0, 0, 10); +uint16_t cyan = matrix.Color444(0, 15, 15); +uint16_t orange = matrix.Color444(15, 5, 0); +uint16_t darkOrange = matrix.Color444(15, 1, 0); +uint16_t green = matrix.Color444(0, 15, 0); + + +int direction = 1; +int biteDirection = 1; //opening or closing +int dotsY = 8; +unsigned long loopCounter = 0; +boolean didChange = false; +boolean caught = false; +uint16_t pillColor = palePink; +unsigned char *letterBitmaps[] = {(letter_bitmaps), (letter_bitmaps+18), (letter_bitmaps+36), (letter_bitmaps+54), (letter_bitmaps+72), (letter_bitmaps+94), (letter_bitmaps+104), (letter_bitmaps+122), (letter_bitmaps+140), (letter_bitmaps+158), (letter_bitmaps+176)}; + + +void setup() { + matrix.begin(); +} + +void loop() { + nootropicDesign(); + clear(); + matrix.swapBuffers(false); + delay(500); +} + + +void nootropicDesign() { + int y = 1; + int offset = 0; + for(int x=32;x>-140;x--) { + offset = 0; + clear(); + offset += drawBitmap(x+offset, y, letterBitmaps[N], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[O], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[O], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[T], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[R], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[O], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[P], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[I], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[C], darkOrange) + 1; + offset += 3; + offset += drawBitmap(x+offset, y, letterBitmaps[D], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[E], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[S], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[I], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[G], darkOrange) + 1; + offset += drawBitmap(x+offset, y, letterBitmaps[N], darkOrange) + 1; + matrix.swapBuffers(false); + delay(15); + } +} + +void clear() { + matrix.fillScreen(black); +} + +uint8_t drawBitmap(int x, int y, unsigned char *bmp, uint16_t color) { + uint8_t width = pgm_read_byte(bmp); + uint8_t height = pgm_read_byte(bmp+1); + unsigned char *p = bmp+2; + uint8_t b; + uint8_t bit; + + for (uint8_t j=0;j> bit) & 0x1) { + matrix.drawPixel(x+i, y+j, color); + } + bit--; + } + } + return width; +} diff --git a/PoC/VdL_demo/pixel.cpp b/PoC/VdL_demo/pixel.cpp new file mode 100644 index 0000000..0ceddc6 --- /dev/null +++ b/PoC/VdL_demo/pixel.cpp @@ -0,0 +1,16 @@ +#include + +PROGMEM prog_uchar pixel_bitmaps[] = { + +// n +9,8, +0b11111111,0b11111111, +0b11111111,0b11111111, +0b11111111,0b11111111, +0b11111111,0b11111111, +0b11111111,0b11111111, +0b11111111,0b11111111, +0b11111111,0b11111111, +0b11111111,0b11111111, + +}; diff --git a/PoC/shiftout1.ino b/PoC/shiftout1.ino new file mode 100644 index 0000000..b9961f3 --- /dev/null +++ b/PoC/shiftout1.ino @@ -0,0 +1,88 @@ +//**************************************************************// +// Name : shiftOutCode, Dual Binary Counters // +// Author : Carlyn Maw, Tom Igoe // +// Date : 25 Oct, 2006 // +// Version : 1.0 // +// Notes : Code for using a 74HC595 Shift Register // +// : to count from 0 to 255 // +//**************************************************************// + +//Pin connected to ST_CP of 74HC595 +int latchPin = 8; +//Pin connected to SH_CP of 74HC595 +int clockPin = 12; +////Pin connected to DS of 74HC595 +int dataPin = 11; + + + +void setup() { + //Start Serial for debuging purposes + Serial.begin(9600); + //set pins to output because they are addressed in the main loop + pinMode(latchPin, OUTPUT); + +} + +void loop() { + //count up routine + for (int j = 0; j < 256; j++) { + //ground latchPin and hold low for as long as you are transmitting + digitalWrite(latchPin, 0); + //count up on GREEN LEDs + shiftOut(dataPin, clockPin, j); + //count down on RED LEDs + shiftOut(dataPin, clockPin, 255-j); + //return the latch pin high to signal chip that it + //no longer needs to listen for information + digitalWrite(latchPin, 1); + delay(1000); + } +} + +void shiftOut(int myDataPin, int myClockPin, byte myDataOut) { + // This shifts 8 bits out MSB first, + //on the rising edge of the clock, + //clock idles low + +..//internal function setup + int i=0; + int pinState; + pinMode(myClockPin, OUTPUT); + pinMode(myDataPin, OUTPUT); + +. //clear everything out just in case to +. //prepare shift register for bit shifting + digitalWrite(myDataPin, 0); + digitalWrite(myClockPin, 0); + + //for each bit in the byte myDataOut� + //NOTICE THAT WE ARE COUNTING DOWN in our for loop + //This means that %00000001 or "1" will go through such + //that it will be pin Q0 that lights. + for (i=7; i>=0; i--) { + digitalWrite(myClockPin, 0); + + //if the value passed to myDataOut and a bitmask result + // true then... so if we are at i=6 and our value is + // %11010100 it would the code compares it to %01000000 + // and proceeds to set pinState to 1. + if ( myDataOut & (1<=0; i--) { + digitalWrite(myClockPin, 0); + + //if the value passed to myDataOut and a bitmask result + // true then... so if we are at i=6 and our value is + // %11010100 it would the code compares it to %01000000 + // and proceeds to set pinState to 1. + if ( myDataOut & (1<=0; i--) { + digitalWrite(myClockPin, 0); + + //if the value passed to myDataOut and a bitmask result + // true then... so if we are at i=6 and our value is + // %11010100 it would the code compares it to %01000000 + // and proceeds to set pinState to 1. + if ( myDataOut & (1<