Created
February 22, 2015 19:17
-
-
Save anonymous/62518112917bf09d7522 to your computer and use it in GitHub Desktop.
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 <stdio.h> | |
#include <stdlib.h> | |
//#include <conio.h> | |
#include <time.h> | |
#include <windows.h> | |
#include <string.h> | |
#include <math.h> | |
//initialise variables to make the GPIO easier to use | |
//uses BCM_GPIO mode for the pins | |
// H C P E I O J M | |
const int positivePins[8] = {21, 24, 19, 12, 04, 13, 17, 05}; | |
// D K L G N F B A | |
const int negativePins[8] = {25, 27, 22, 20, 06, 16, 23, 18}; | |
//letters created as a test | |
const unsigned char characters[][8] = {{0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, // space | |
{0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00000000, 0b00010000, 0b00000000}, // ! | |
{0b00101000, 0b00101000, 0b00101000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, // " | |
{0b00000000, 0b00101000, 0b01111100, 0b00101000, 0b00101000, 0b01111100, 0b00101000, 0b00000000}, // # | |
{0b00010000, 0b00111100, 0b01010000, 0b00111000, 0b00010100, 0b01111000, 0b00010000, 0b00000000}, // $ | |
{0b00000000, 0b01000100, 0b00001000, 0b00010000, 0b00100000, 0b01000100, 0b00000000, 0b00000000}, // % | |
{0b00110000, 0b01001000, 0b01000000, 0b00100000, 0b01010100, 0b01001000, 0b00110100, 0b00000000}, // & | |
{0b00010000, 0b00010000, 0b00010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, // ' | |
{0b00010000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00010000, 0b00000000}, // ( | |
{0b00010000, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00010000, 0b00000000}, // ) | |
{0b00000000, 0b01010100, 0b00111000, 0b01111100, 0b00111000, 0b01010100, 0b00000000, 0b00000000}, // * | |
{0b00000000, 0b00010000, 0b00010000, 0b01111100, 0b00010000, 0b00010000, 0b00000000, 0b00000000}, // + | |
{0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010000, 0b00010000, 0b00100000}, // , | |
{0b00000000, 0b00000000, 0b00000000, 0b01111100, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, // - | |
{0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010000, 0b00000000}, // . | |
{0b00000000, 0b00000010, 0b00000100, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b00000000}, // / | |
{0b00011000, 0b00100100, 0b00100100, 0b00100100, 0b00100100, 0b00100100, 0b00011000, 0b00000000}, // 0 | |
{0b00010000, 0b00110000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00111000, 0b00000000}, // 1 | |
{0b00110000, 0b01001000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b01111000, 0b00000000}, // 2 | |
{0b00110000, 0b01001000, 0b00001000, 0b00110000, 0b00001000, 0b01001000, 0b00110000, 0b00000000}, // 3 | |
{0b00001000, 0b00011000, 0b00101000, 0b01001000, 0b01111100, 0b00001000, 0b00001000, 0b00000000}, // 4 | |
{0b01111000, 0b01000000, 0b01000000, 0b00110000, 0b00001000, 0b01001000, 0b00110000, 0b00000000}, // 5 | |
{0b00110000, 0b01001000, 0b01000000, 0b01110000, 0b01001000, 0b01001000, 0b00110000, 0b00000000}, // 6 | |
{0b01111000, 0b00001000, 0b00001000, 0b00010000, 0b00010000, 0b00100000, 0b00100000, 0b00000000}, // 7 | |
{0b00110000, 0b01001000, 0b01001000, 0b00110000, 0b01001000, 0b01001000, 0b00110000, 0b00000000}, // 8 | |
{0b00110000, 0b01001000, 0b01001000, 0b00111000, 0b00001000, 0b01001000, 0b00110000, 0b00000000}, // 9 | |
{0b00000000, 0b00000000, 0b00010000, 0b00000000, 0b00000000, 0b00010000, 0b00000000, 0b00000000}, // : | |
{0b00000000, 0b00000000, 0b00010000, 0b00000000, 0b00000000, 0b00010000, 0b00010000, 0b00100000}, // ; | |
{0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b00100000, 0b00010000, 0b00001000, 0b00000000}, // < | |
{0b00000000, 0b00000000, 0b01111100, 0b00000000, 0b01111100, 0b00000000, 0b00000000, 0b00000000}, // = | |
{0b00100000, 0b00010000, 0b00001000, 0b00000100, 0b00001000, 0b00010000, 0b00100000, 0b00000000}, // > | |
{0b00111000, 0b01000100, 0b00000100, 0b00001000, 0b00010000, 0b00000000, 0b00010000, 0b00000000}, // ? | |
{0b00111000, 0b01000100, 0b01011100, 0b01010100, 0b01011100, 0b01000000, 0b00111000, 0b00000000}, // @ | |
{0b00111000, 0b01000100, 0b01000100, 0b01111100, 0b01000100, 0b01000100, 0b01000100, 0b00000000}, // A | |
{0b01111000, 0b01000100, 0b01000100, 0b01111000, 0b01000100, 0b01000100, 0b01111000, 0b00000000}, // B | |
{0b00111000, 0b01000100, 0b01000000, 0b01000000, 0b01000000, 0b01000100, 0b00111000, 0b00000000}, // C | |
{0b01111000, 0b01000100, 0b01000100, 0b01000100, 0b01000100, 0b01000100, 0b01111000, 0b00000000}, // D | |
{0b01111100, 0b01000000, 0b01000000, 0b01111000, 0b01000000, 0b01000000, 0b01111100, 0b00000000}, // E | |
{0b01111100, 0b01000000, 0b01000000, 0b01111000, 0b01000000, 0b01000000, 0b01000000, 0b00000000}, // F | |
{0b00111000, 0b01000100, 0b01000000, 0b01011100, 0b01000100, 0b01000100, 0b00111000, 0b00000000}, // G | |
{0b01000100, 0b01000100, 0b01000100, 0b01111100, 0b01000100, 0b01000100, 0b01000100, 0b00000000}, // H | |
{0b01111100, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b01111100, 0b00000000}, // I | |
{0b01111100, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b01001000, 0b00110000, 0b00000000}, // J | |
{0b01000100, 0b01001000, 0b01010000, 0b01100000, 0b01010000, 0b01001000, 0b01000100, 0b00000000}, // K | |
{0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b01111100, 0b00000000}, // L | |
{0b01000100, 0b01101100, 0b01010100, 0b01000100, 0b01000100, 0b01000100, 0b01000100, 0b00000000}, // M | |
{0b01000100, 0b01100100, 0b01100100, 0b01010100, 0b01001100, 0b01001100, 0b01000100, 0b00000000}, // N | |
{0b00111000, 0b01000100, 0b01000100, 0b01000100, 0b01000100, 0b01000100, 0b00111000, 0b00000000} // O | |
}; | |
//comparison columns for lighting the grid | |
const unsigned char lightOn[] = {0b10000000, 0b01000000, 0b00100000, 0b00010000, 0b00001000, 0b00000100, 0b00000010, 0b00000001}; | |
const int characterOffset = 32; | |
const int ledCount = 8; | |
void Display (const unsigned char first[], const unsigned char second[]) | |
{ | |
int shift; | |
int row; | |
int column; | |
unsigned char firstLetter; | |
unsigned char secondLetter; | |
for(shift = 0; shift < ledCount; shift++) | |
{ | |
system("cls"); | |
printf("/========\\\n"); | |
for(row = 0; row < ledCount; row++) | |
{ | |
printf("|"); | |
for(column = 0; column < ledCount; column++) | |
{ | |
firstLetter = first[row] << shift; | |
secondLetter = second[row] >> (ledCount - shift); | |
if(firstLetter & lightOn[column] || secondLetter & lightOn[column]) | |
{ | |
printf("0"); | |
} | |
else | |
{ | |
printf(" "); | |
} | |
} | |
printf("|\n"); | |
} | |
printf("\\========/"); | |
Sleep(100); | |
} | |
} | |
int main (void) | |
{ | |
int i; | |
int length = (sizeof(characters) / sizeof(characters[0])) - 1; | |
printf("Starting Byte Array Test\n\n"); | |
for(i = 0; i < length; i++) | |
{ | |
Display(characters[i], characters[i + 1]); | |
} | |
printf("\n\nProgram Complete\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment