Created
October 22, 2013 23:39
-
-
Save chalfant/7110079 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 <avr/pgmspace.h> | |
int A_pin = 2; // Data pin for rows selection A | |
int B_pin = 3; // Data pin for rows selection B | |
int C_pin = 4; // Data pin for rows selection C | |
int D_pin = 5; // Data pin for rows selection D | |
int G1_pin = 9; //6; //green leds for uppwer rows | |
int G2_pin = 10; //7; //green leds for lower rows | |
// these pins may be switched (see forum) | |
int R1_pin = 11; //red leds for uppwer rows | |
int R2_pin = 12; //red leds for lower rows | |
int S_pin = 8; //Clock pin | |
int L_pin = 6; //9; //Latch pin | |
int E_pin = 7; //10; //Enable pin | |
int g1; | |
int g2; | |
int r1; | |
int r2; | |
int xdelay = 250; | |
unsigned long byte_checker = (unsigned long)1 << 0; | |
unsigned long displayBitmap[2*32*2]; // Bitmap for display | |
// The bitmap (64x32) is arranged with 8 bytes per row aligned on long. | |
// The upper 32 rows controls the Red LED's | |
// The lower 32 rows controls the Green LED's | |
// To get yellow, set both green and red at the same time... ;-) | |
/* CMC | |
* Looks like the bitmap is in x*y where x is the columns | |
* I'll need to reduce the number of rows to 16 | |
* and modify the rest of the program to handle that | |
*/ | |
const prog_uint8_t PROGMEM BitMap[8] = { | |
B10111110, | |
B10111110, | |
B10111110, | |
B10110110, | |
B10101010, | |
B10011100, | |
B10111110 | |
}; | |
prog_uchar PROGMEM myfont[256][5] = { | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 1 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 2 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 3 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 4 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 5 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 6 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 7 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 8 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 9 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 10 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 11 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 12 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 13 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 14 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 15 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 16 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 17 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 18 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 19 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 20 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 21 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 22 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 23 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 24 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 25 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 26 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 27 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 28 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 29 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 30 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 31 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 32 | |
{ 0x00, 0x00, 0x7d, 0x00, 0x00 }, // 33 | |
{ 0x00, 0x70, 0x00, 0x70, 0x00 }, // 34 | |
{ 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // 35 | |
{ 0x12, 0x2a, 0x7f, 0x2a, 0x24 }, // 36 | |
{ 0x62, 0x64, 0x08, 0x13, 0x23 }, // 37 | |
{ 0x36, 0x49, 0x55, 0x22, 0x05 }, // 38 | |
{ 0x00, 0x50, 0x60, 0x00, 0x00 }, // 39 | |
{ 0x00, 0x1c, 0x22, 0x41, 0x00 }, // 40 | |
{ 0x00, 0x41, 0x22, 0x1c, 0x00 }, // 41 | |
{ 0x14, 0x08, 0x3e, 0x08, 0x14 }, // 42 | |
{ 0x08, 0x08, 0x3e, 0x08, 0x08 }, // 43 | |
{ 0x00, 0x05, 0x06, 0x00, 0x00 }, // 44 | |
{ 0x08, 0x08, 0x08, 0x08, 0x08 }, // 45 | |
{ 0x00, 0x03, 0x03, 0x00, 0x00 }, // 46 | |
{ 0x02, 0x04, 0x08, 0x10, 0x20 }, // 47 | |
{ 0x3e, 0x45, 0x49, 0x51, 0x3e }, // 48 | |
{ 0x00, 0x21, 0x7f, 0x01, 0x00 }, // 49 | |
{ 0x21, 0x43, 0x45, 0x49, 0x31 }, // 50 | |
{ 0x42, 0x41, 0x51, 0x69, 0x46 }, // 51 | |
{ 0x0c, 0x14, 0x24, 0x7f, 0x04 }, // 52 | |
{ 0x72, 0x51, 0x51, 0x51, 0x4e }, // 53 | |
{ 0x1e, 0x29, 0x49, 0x49, 0x06 }, // 54 | |
{ 0x40, 0x47, 0x48, 0x50, 0x60 }, // 55 | |
{ 0x36, 0x49, 0x49, 0x49, 0x36 }, // 56 | |
{ 0x30, 0x49, 0x49, 0x4a, 0x3c }, // 57 | |
{ 0x00, 0x36, 0x36, 0x00, 0x00 }, // 58 | |
{ 0x00, 0x35, 0x36, 0x00, 0x00 }, // 59 | |
{ 0x08, 0x14, 0x22, 0x41, 0x00 }, // 60 | |
{ 0x14, 0x14, 0x14, 0x14, 0x14 }, // 61 | |
{ 0x41, 0x22, 0x14, 0x08, 0x00 }, // 62 | |
{ 0x20, 0x40, 0x45, 0x48, 0x30 }, // 63 | |
{ 0x26, 0x49, 0x4f, 0x41, 0x3e }, // 64 | |
{ 0x3f, 0x44, 0x44, 0x44, 0x3f }, // 65 | |
{ 0x7f, 0x49, 0x49, 0x49, 0x36 }, // 66 | |
{ 0x3e, 0x41, 0x41, 0x41, 0x22 }, // 67 | |
{ 0x7f, 0x41, 0x41, 0x41, 0x3e }, // 68 | |
{ 0x7f, 0x49, 0x49, 0x49, 0x41 }, // 69 | |
{ 0x7f, 0x48, 0x48, 0x48, 0x40 }, // 70 | |
{ 0x3e, 0x41, 0x49, 0x49, 0x2f }, // 71 | |
{ 0x7f, 0x08, 0x08, 0x08, 0x7f }, // 72 | |
{ 0x00, 0x41, 0x7f, 0x41, 0x00 }, // 73 | |
{ 0x02, 0x01, 0x41, 0x7e, 0x40 }, // 74 | |
{ 0x7f, 0x08, 0x14, 0x22, 0x41 }, // 75 | |
{ 0x7f, 0x01, 0x01, 0x01, 0x01 }, // 76 | |
{ 0x7f, 0x40, 0x20, 0x40, 0x7f }, // 77 | |
{ 0x7f, 0x10, 0x08, 0x04, 0x7f }, // 78 | |
{ 0x3e, 0x41, 0x41, 0x41, 0x3e }, // 79 | |
{ 0x7f, 0x48, 0x48, 0x48, 0x30 }, // 80 | |
{ 0x3e, 0x41, 0x45, 0x42, 0x3d }, // 81 | |
{ 0x7f, 0x48, 0x4c, 0x4a, 0x31 }, // 82 | |
{ 0x31, 0x49, 0x49, 0x49, 0x46 }, // 83 | |
{ 0x40, 0x40, 0x7f, 0x40, 0x40 }, // 84 | |
{ 0x7e, 0x01, 0x01, 0x01, 0x7e }, // 85 | |
{ 0x7c, 0x02, 0x01, 0x02, 0x7c }, // 86 | |
{ 0x7e, 0x01, 0x0e, 0x01, 0x7e }, // 87 | |
{ 0x63, 0x14, 0x08, 0x14, 0x63 }, // 88 | |
{ 0x70, 0x08, 0x07, 0x08, 0x70 }, // 89 | |
{ 0x43, 0x45, 0x49, 0x51, 0x61 }, // 90 | |
{ 0x00, 0x7f, 0x41, 0x41, 0x00 }, // 91 | |
{ 0x54, 0x34, 0x1f, 0x34, 0x54 }, // 92 | |
{ 0x00, 0x41, 0x41, 0x7f, 0x00 }, // 93 | |
{ 0x10, 0x20, 0x40, 0x20, 0x10 }, // 94 | |
{ 0x01, 0x01, 0x01, 0x01, 0x01 }, // 95 | |
{ 0x00, 0x40, 0x20, 0x10, 0x00 }, // 96 | |
{ 0x02, 0x15, 0x15, 0x15, 0x0f }, // 97 | |
{ 0x7f, 0x09, 0x11, 0x11, 0x0e }, // 98 | |
{ 0x0e, 0x11, 0x11, 0x11, 0x02 }, // 99 | |
{ 0x0e, 0x11, 0x11, 0x09, 0x7f }, // 100 | |
{ 0x0e, 0x15, 0x15, 0x15, 0x0c }, // 101 | |
{ 0x08, 0x3f, 0x48, 0x40, 0x20 }, // 102 | |
{ 0x30, 0x49, 0x49, 0x49, 0x7e }, // 103 | |
{ 0x7f, 0x08, 0x10, 0x10, 0x0f }, // 104 | |
{ 0x00, 0x11, 0x5f, 0x01, 0x00 }, // 105 | |
{ 0x02, 0x01, 0x21, 0x7e, 0x00 }, // 106 | |
{ 0x7f, 0x04, 0x0a, 0x11, 0x00 }, // 107 | |
{ 0x00, 0x41, 0x7f, 0x01, 0x00 }, // 108 | |
{ 0x1f, 0x10, 0x0c, 0x10, 0x0f }, // 109 | |
{ 0x1f, 0x08, 0x10, 0x10, 0x0f }, // 110 | |
{ 0x0e, 0x11, 0x11, 0x11, 0x0e }, // 111 | |
{ 0x1f, 0x14, 0x14, 0x14, 0x08 }, // 112 | |
{ 0x08, 0x14, 0x14, 0x0c, 0x1f }, // 113 | |
{ 0x1f, 0x08, 0x10, 0x10, 0x08 }, // 114 | |
{ 0x09, 0x15, 0x15, 0x15, 0x12 }, // 115 | |
{ 0x20, 0x7e, 0x21, 0x01, 0x02 }, // 116 | |
{ 0x1e, 0x01, 0x01, 0x02, 0x1f }, // 117 | |
{ 0x1c, 0x02, 0x01, 0x02, 0x1c }, // 118 | |
{ 0x1e, 0x01, 0x06, 0x01, 0x1e }, // 119 | |
{ 0x11, 0x0a, 0x04, 0x0a, 0x11 }, // 120 | |
{ 0x18, 0x05, 0x05, 0x05, 0x1e }, // 121 | |
{ 0x11, 0x13, 0x15, 0x19, 0x11 }, // 122 | |
{ 0x00, 0x08, 0x36, 0x41, 0x00 }, // 123 | |
{ 0x00, 0x00, 0x7f, 0x00, 0x00 }, // 124 | |
{ 0x00, 0x41, 0x36, 0x08, 0x00 }, // 125 | |
{ 0x08, 0x08, 0x2a, 0x1c, 0x08 }, // 126 | |
{ 0x08, 0x1c, 0x2a, 0x08, 0x08 }, // 127 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 128 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 129 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 130 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 131 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 132 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 133 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 134 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 135 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 136 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 137 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 138 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 139 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 140 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 141 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 142 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 143 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 144 | |
{ 0x07, 0x05, 0x07, 0x00, 0x00 }, // 145 | |
{ 0x00, 0x00, 0x78, 0x40, 0x40 }, // 146 | |
{ 0x01, 0x01, 0x0f, 0x00, 0x00 }, // 147 | |
{ 0x04, 0x02, 0x01, 0x00, 0x00 }, // 148 | |
{ 0x00, 0x0c, 0x0c, 0x00, 0x00 }, // 149 | |
{ 0x28, 0x28, 0x29, 0x2a, 0x3c }, // 150 | |
{ 0x10, 0x11, 0x16, 0x14, 0x18 }, // 151 | |
{ 0x02, 0x04, 0x0f, 0x10, 0x00 }, // 152 | |
{ 0x0c, 0x08, 0x19, 0x09, 0x0e }, // 153 | |
{ 0x09, 0x09, 0x0f, 0x09, 0x09 }, // 154 | |
{ 0x09, 0x0a, 0x0c, 0x1f, 0x08 }, // 155 | |
{ 0x08, 0x1f, 0x08, 0x0a, 0x0c }, // 156 | |
{ 0x01, 0x09, 0x09, 0x0f, 0x01 }, // 157 | |
{ 0x15, 0x15, 0x15, 0x1f, 0x00 }, // 158 | |
{ 0x0c, 0x00, 0x0d, 0x01, 0x0e }, // 159 | |
{ 0x04, 0x04, 0x04, 0x04, 0x04 }, // 160 | |
{ 0x40, 0x41, 0x5e, 0x48, 0x70 }, // 161 | |
{ 0x04, 0x08, 0x1f, 0x20, 0x40 }, // 162 | |
{ 0x38, 0x20, 0x61, 0x22, 0x3c }, // 163 | |
{ 0x11, 0x11, 0x1f, 0x11, 0x11 }, // 164 | |
{ 0x22, 0x24, 0x28, 0x7f, 0x20 }, // 165 | |
{ 0x21, 0x7e, 0x20, 0x21, 0x3e }, // 166 | |
{ 0x28, 0x28, 0x7f, 0x28, 0x28 }, // 167 | |
{ 0x08, 0x31, 0x21, 0x22, 0x3c }, // 168 | |
{ 0x10, 0x60, 0x21, 0x3e, 0x20 }, // 169 | |
{ 0x21, 0x21, 0x21, 0x21, 0x3f }, // 170 | |
{ 0x20, 0x79, 0x22, 0x7c, 0x20 }, // 171 | |
{ 0x29, 0x29, 0x01, 0x02, 0x1c }, // 172 | |
{ 0x21, 0x22, 0x24, 0x2a, 0x31 }, // 173 | |
{ 0x20, 0x7e, 0x21, 0x29, 0x31 }, // 174 | |
{ 0x30, 0x09, 0x01, 0x02, 0x3c }, // 175 | |
{ 0x08, 0x31, 0x29, 0x26, 0x3c }, // 176 | |
{ 0x28, 0x29, 0x3e, 0x48, 0x08 }, // 177 | |
{ 0x30, 0x00, 0x31, 0x02, 0x3c }, // 178 | |
{ 0x10, 0x51, 0x5e, 0x50, 0x10 }, // 179 | |
{ 0x00, 0x7f, 0x08, 0x04, 0x00 }, // 180 | |
{ 0x11, 0x12, 0x7c, 0x10, 0x10 }, // 181 | |
{ 0x01, 0x21, 0x21, 0x21, 0x01 }, // 182 | |
{ 0x21, 0x2a, 0x24, 0x2a, 0x30 }, // 183 | |
{ 0x22, 0x24, 0x6f, 0x34, 0x22 }, // 184 | |
{ 0x00, 0x01, 0x02, 0x7c, 0x00 }, // 185 | |
{ 0x0f, 0x00, 0x20, 0x10, 0x0f }, // 186 | |
{ 0x7e, 0x11, 0x11, 0x11, 0x11 }, // 187 | |
{ 0x20, 0x21, 0x21, 0x22, 0x3c }, // 188 | |
{ 0x10, 0x20, 0x10, 0x08, 0x06 }, // 189 | |
{ 0x26, 0x20, 0x7f, 0x20, 0x26 }, // 190 | |
{ 0x20, 0x24, 0x22, 0x25, 0x38 }, // 191 | |
{ 0x00, 0x2a, 0x2a, 0x2a, 0x01 }, // 192 | |
{ 0x0e, 0x12, 0x22, 0x02, 0x07 }, // 193 | |
{ 0x01, 0x0a, 0x04, 0x0a, 0x30 }, // 194 | |
{ 0x28, 0x3e, 0x29, 0x29, 0x29 }, // 195 | |
{ 0x10, 0x7f, 0x10, 0x14, 0x18 }, // 196 | |
{ 0x01, 0x21, 0x21, 0x3f, 0x01 }, // 197 | |
{ 0x29, 0x29, 0x29, 0x29, 0x3f }, // 198 | |
{ 0x10, 0x50, 0x51, 0x52, 0x1c }, // 199 | |
{ 0x78, 0x01, 0x02, 0x7c, 0x00 }, // 200 | |
{ 0x1f, 0x00, 0x3f, 0x01, 0x06 }, // 201 | |
{ 0x3f, 0x01, 0x02, 0x04, 0x08 }, // 202 | |
{ 0x3f, 0x21, 0x21, 0x21, 0x3f }, // 203 | |
{ 0x38, 0x20, 0x21, 0x22, 0x3c }, // 204 | |
{ 0x21, 0x21, 0x01, 0x02, 0x0c }, // 205 | |
{ 0x20, 0x10, 0x40, 0x20, 0x00 }, // 206 | |
{ 0x70, 0x50, 0x70, 0x00, 0x00 }, // 207 | |
{ 0x0e, 0x11, 0x09, 0x06, 0x19 }, // 208 | |
{ 0x02, 0x55, 0x15, 0x55, 0x0f }, // 209 | |
{ 0x1f, 0x2a, 0x2a, 0x2a, 0x14 }, // 210 | |
{ 0x0a, 0x15, 0x15, 0x11, 0x02 }, // 211 | |
{ 0x3f, 0x02, 0x02, 0x04, 0x3e }, // 212 | |
{ 0x0e, 0x11, 0x19, 0x15, 0x12 }, // 213 | |
{ 0x0f, 0x12, 0x22, 0x22, 0x1c }, // 214 | |
{ 0x1c, 0x22, 0x22, 0x22, 0x3f }, // 215 | |
{ 0x02, 0x01, 0x1e, 0x10, 0x10 }, // 216 | |
{ 0x20, 0x20, 0x00, 0x70, 0x00 }, // 217 | |
{ 0x00, 0x00, 0x10, 0x5f, 0x00 }, // 218 | |
{ 0x28, 0x10, 0x28, 0x00, 0x00 }, // 219 | |
{ 0x18, 0x24, 0x7e, 0x24, 0x08 }, // 220 | |
{ 0x14, 0x7f, 0x15, 0x01, 0x01 }, // 221 | |
{ 0x1f, 0x48, 0x50, 0x50, 0x0f }, // 222 | |
{ 0x0e, 0x51, 0x11, 0x51, 0x0e }, // 223 | |
{ 0x3f, 0x12, 0x22, 0x22, 0x1c }, // 224 | |
{ 0x1c, 0x22, 0x22, 0x12, 0x3f }, // 225 | |
{ 0x3c, 0x52, 0x52, 0x52, 0x3c }, // 226 | |
{ 0x03, 0x05, 0x02, 0x05, 0x06 }, // 227 | |
{ 0x1a, 0x26, 0x20, 0x26, 0x1a }, // 228 | |
{ 0x1e, 0x41, 0x01, 0x42, 0x1f }, // 229 | |
{ 0x63, 0x55, 0x49, 0x41, 0x41 }, // 230 | |
{ 0x22, 0x3c, 0x20, 0x3e, 0x22 }, // 231 | |
{ 0x51, 0x4a, 0x44, 0x4a, 0x51 }, // 232 | |
{ 0x3c, 0x02, 0x02, 0x02, 0x3f }, // 233 | |
{ 0x28, 0x28, 0x3e, 0x28, 0x48 }, // 234 | |
{ 0x22, 0x3c, 0x28, 0x28, 0x2e }, // 235 | |
{ 0x3e, 0x28, 0x38, 0x28, 0x3e }, // 236 | |
{ 0x04, 0x04, 0x15, 0x04, 0x04 }, // 237 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 238 | |
{ 0x7f, 0x7f, 0x7f, 0x7f, 0x7f }, // 239 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 240 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 241 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 242 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 243 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 244 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 245 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 246 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 247 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 248 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 249 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 250 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 251 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 252 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 253 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 254 | |
{ 0x00, 0x00, 0x00, 0x00, 0x00 } // 255 | |
}; | |
char *disp[] = {" FUN WITH ", "ARDUINO!!!!!", " fun with ", "arduino :)"}; | |
void setup(){ | |
pinMode(A_pin, OUTPUT); | |
pinMode(B_pin, OUTPUT); | |
pinMode(C_pin, OUTPUT); | |
pinMode(D_pin, OUTPUT); | |
pinMode(G1_pin, OUTPUT); | |
pinMode(G2_pin, OUTPUT); | |
pinMode(R1_pin, OUTPUT); | |
pinMode(R2_pin, OUTPUT); | |
pinMode(S_pin, OUTPUT); | |
pinMode(L_pin, OUTPUT); | |
pinMode(E_pin, OUTPUT); | |
//set_pixel(1,3,3); | |
Serial.begin(9600); | |
// This setup code writes the string in char* disp[] to the display | |
// buffer once. This buffer will be read on each loop to setup the display | |
// TODO: Modify these for loops so they are not hardcoded to the string | |
// iterate over lines in char *disp[] (4 in example) | |
for (byte line=0; line < 4; ++line) { | |
// iterate over characters in current line (each line has 12 in example) | |
for (byte c=0; c<11; ++c) { | |
// iterate over each "column" in 5x7 character (one byte per column) | |
for (byte y=0; y<5; ++y) { | |
// fetch that column byte from the font store in myfont | |
byte data = (byte) pgm_read_byte (&myfont[ disp[line][c] ][y]); | |
// iterate over each row in the column byte | |
for (byte x=0; x<7; ++x) { | |
// if the current pixel in the row,column is 1, turn the led on | |
// but remember that the led_pin LOW is on. | |
// | |
// This sets the first line in the string to red | |
// all other lines green | |
if (data & (1<<x)) { | |
// on is off | |
int color = 2; | |
if (line > 1) | |
color = 1; | |
// since letters are 5x7, add space at the bottom and rt side | |
// to separate them. That makes 6x8 | |
// set_pixel(row,column,color) | |
set_pixel((6-x) + (line * 8),y + (c*6),color); | |
} else { | |
//set_pixel(x,y,1); | |
} | |
} | |
} | |
} | |
} | |
} | |
void loop() { | |
// iterate over each row (wait, why only 16?) | |
for(int x=0; x<16; x++){ // start a line scan | |
digitalWrite(E_pin, HIGH); | |
byte_checker = (unsigned long)1 << 0; // reset to 1 | |
// iterate over the 64 columns of the display | |
for(int y = 0; y < 64; y++) { | |
// We are going to use this PORT interface to the ATmega128 | |
// to control the digital out pins instead of digitalWrite() | |
// so we need to setup a byte var which we will use to set | |
// those pins. | |
//000 R2 R1 G2 G1 CLK | |
byte row = B00011110; // Default to R[1|2] G[1|2] off and CLOCK to low. | |
// TODO: These need to be modified for a smaller display bitmap | |
// G1 | |
g1 = x*2; | |
g2 = (x*2) + 32; | |
r1 = (x*2) + 64; | |
r2 = (x*2) + 96; | |
// if we hit column 32, reset byte_checker to 1. Why? | |
// I think because byte_checker is 32 bits long and we've | |
// shifted past it's left side. | |
if (y==32) | |
byte_checker = (unsigned long)1 << 0; | |
// if column > 31 add one to row we are going to use to lookup | |
// in the display bitmap. Why? Is this because the display bitmap | |
// is a one dimensional array standing in for a 2d matrix? | |
if (y > 31) { | |
g1++; | |
g2++; | |
r1++; | |
r2++; | |
} | |
// if the g1 pin should be set for this row,colum | |
// then xor equal the row at the g1 position (1 shift left 1) | |
if (displayBitmap[g1] & byte_checker) | |
row ^= (1 << 1); | |
if (displayBitmap[g2] & byte_checker) | |
row ^= (1 << 2); | |
if (displayBitmap[r1] & byte_checker) | |
row ^= (1 << 4); | |
if (displayBitmap[r2] & byte_checker) | |
row ^= (1 << 3); | |
byte_checker <<= 1; | |
PORTB = row; // this sets the pins 8-13 based on the byte row | |
delayMicroseconds(1); //needed to not toggle the clock too fast | |
PORTB |= B00000001; // Clock back to HIGH | |
} | |
digitalWrite(E_pin, LOW); | |
digitalWrite(L_pin,HIGH); // latch the data | |
digitalWrite(L_pin,LOW); | |
int pinState = 0; | |
int abcd_pins[] = {A_pin,B_pin,C_pin,D_pin}; | |
// i still don't get this, the index is out of bounds and wiring | |
// doesn't throw an exception. So the first pin we are writing to | |
// is based on whatever's at the end of the abcd_pins[] array! | |
// I should probably change this to 3..0 | |
// this sets the row selector (which may be different w/ my display) | |
for (int i=4; i>=0; i--) { | |
if ( x & (1<<i) ) | |
pinState = 1; | |
else | |
pinState = 0; | |
digitalWrite(abcd_pins[i], pinState); | |
} | |
digitalWrite(E_pin, HIGH); | |
delayMicroseconds(xdelay); | |
} | |
} | |
void set_pixel(int x, int y, int color) { | |
// find byte location | |
int location = x*2; | |
if (y>31) | |
location++; | |
if ((color == 1) || (color == 3)) | |
displayBitmap[location] ^= (unsigned long)1<<y%32; | |
if ((color == 2) || (color == 3)) | |
displayBitmap[location+64] ^= (unsigned long)1<<y%32; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment