├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── githubci.yml ├── .gitignore ├── Adafruit_LEDBackpack.cpp ├── Adafruit_LEDBackpack.h ├── README.md ├── examples ├── HT16K33 │ └── HT16K33.ino ├── bargraph24 │ └── bargraph24.ino ├── bicolor8x8 │ └── bicolor8x8.ino ├── clock_sevenseg_ds1307 │ └── clock_sevenseg_ds1307.ino ├── clock_sevenseg_gps │ └── clock_sevenseg_gps.ino ├── custom_character │ ├── README.md │ ├── custom_character_generator │ │ └── custom_character_generator.ino │ └── customgen │ │ └── customgen.pde ├── matrix16x8 │ └── matrix16x8.ino ├── matrix8x8 │ └── matrix8x8.ino ├── minimatrix16x8 │ └── minimatrix16x8.ino ├── quadalphaanimation │ └── quadalphaanimation.ino ├── quadalphanum │ └── quadalphanum.ino ├── quadalphanum_mini │ └── quadalphanum_mini.ino ├── roboface │ └── roboface.ino ├── sevenseg │ └── sevenseg.ino └── wavface │ ├── wavface.ino │ └── wavs │ ├── beware_i.wav │ ├── ihunger.wav │ └── run_cowd.wav ├── library.properties └── license.txt /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening an issue on an Adafruit Arduino library repository. To 2 | improve the speed of resolution please review the following guidelines and 3 | common troubleshooting steps below before creating the issue: 4 | 5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use 6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why 7 | something isn't working as expected. In many cases the problem is a common issue 8 | that you will more quickly receive help from the forum community. GitHub issues 9 | are meant for known defects in the code. If you don't know if there is a defect 10 | in the code then start with troubleshooting on the forum first. 11 | 12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully 13 | check all of the steps and commands to run have been followed. Consult the 14 | forum if you're unsure or have questions about steps in a guide/tutorial. 15 | 16 | - **For Arduino projects check these very common issues to ensure they don't apply**: 17 | 18 | - For uploading sketches or communicating with the board make sure you're using 19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes 20 | very hard to tell the difference between a data and charge cable! Try using the 21 | cable with other devices or swapping to another cable to confirm it is not 22 | the problem. 23 | 24 | - **Be sure you are supplying adequate power to the board.** Check the specs of 25 | your board and plug in an external power supply. In many cases just 26 | plugging a board into your computer is not enough to power it and other 27 | peripherals. 28 | 29 | - **Double check all soldering joints and connections.** Flakey connections 30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints. 31 | 32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't 33 | guarantee a clone board will have the same functionality and work as expected 34 | with this code and don't support them. 35 | 36 | If you're sure this issue is a defect in the code and checked the steps above 37 | please fill in the following fields to provide enough troubleshooting information. 38 | You may delete the guideline and text above to just leave the following details: 39 | 40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE** 41 | 42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO 43 | VERSION HERE** 44 | 45 | - List the steps to reproduce the problem below (if possible attach a sketch or 46 | copy the sketch code in too): **LIST REPRO STEPS BELOW** 47 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code! 2 | Before you open the request please review the following guidelines and tips to 3 | help it be more easily integrated: 4 | 5 | - **Describe the scope of your change--i.e. what the change does and what parts 6 | of the code were modified.** This will help us understand any risks of integrating 7 | the code. 8 | 9 | - **Describe any known limitations with your change.** For example if the change 10 | doesn't apply to a supported platform of the library please mention it. 11 | 12 | - **Please run any tests or examples that can exercise your modified code.** We 13 | strive to not break users of the code and running tests/examples helps with this 14 | process. 15 | 16 | Thank you again for contributing! We will try to test and integrate the change 17 | as soon as we can, but be aware we have many GitHub repositories to manage and 18 | can't immediately respond to every request. There is no need to bump or check in 19 | on a pull request (it will clutter the discussion of the request). 20 | 21 | Also don't be worried if the request is closed or not integrated--sometimes the 22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the 23 | priorities of the pull request. Don't fret, the open source community thrives on 24 | forks and GitHub makes it easy to keep your changes in a forked repo. 25 | 26 | After reviewing the guidelines above you can delete this text from the pull request. 27 | -------------------------------------------------------------------------------- /.github/workflows/githubci.yml: -------------------------------------------------------------------------------- 1 | name: Arduino Library CI 2 | 3 | on: [pull_request, push, repository_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/setup-python@v4 11 | with: 12 | python-version: '3.x' 13 | - uses: actions/checkout@v3 14 | - uses: actions/checkout@v3 15 | with: 16 | repository: adafruit/ci-arduino 17 | path: ci 18 | 19 | - name: pre-install 20 | run: bash ci/actions_install.sh 21 | 22 | - name: test platforms 23 | run: python3 ci/build_platform.py uno 24 | 25 | - name: clang 26 | run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r . 27 | 28 | - name: doxygen 29 | env: 30 | GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} 31 | PRETTYNAME : "Adafruit LED Backpack Library" 32 | run: bash ci/doxy_gen_and_deploy.sh 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Our handy .gitignore for automation ease 2 | Doxyfile* 3 | doxygen_sqlite3.db 4 | html 5 | -------------------------------------------------------------------------------- /Adafruit_LEDBackpack.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_LEDBackpack.cpp 3 | * 4 | * @mainpage Adafruit LED Backpack library for Arduino. 5 | * 6 | * @section intro_sec Introduction 7 | * 8 | * This is an Arduino library for our I2C LED Backpacks: 9 | * ----> http://www.adafruit.com/products/ 10 | * ----> http://www.adafruit.com/products/ 11 | * 12 | * These displays use I2C to communicate, 2 pins are required to 13 | * interface. There are multiple selectable I2C addresses. For backpacks 14 | * with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks 15 | * with 3 Address Select pins: 0x70 thru 0x77 16 | * 17 | * Adafruit invests time and resources providing this open source code, 18 | * please support Adafruit and open-source hardware by purchasing 19 | * products from Adafruit! 20 | * 21 | * @section dependencies Dependencies 22 | * 23 | * This library depends on Adafruit_GFX 25 | * being present on your system. Please make sure you have installed the latest 26 | * version before using this library. 27 | * 28 | * @section author Author 29 | * 30 | * Written by Limor Fried/Ladyada for Adafruit Industries. 31 | * 32 | * @section license License 33 | * 34 | * MIT license, all text above must be included in any redistribution 35 | * 36 | */ 37 | 38 | #include "Adafruit_LEDBackpack.h" 39 | #include "Adafruit_GFX.h" 40 | 41 | #ifndef _BV 42 | #define _BV(bit) (1 << (bit)) ///< Bit-value if not defined by Arduino 43 | #endif 44 | 45 | #ifndef _swap_int16_t 46 | #define _swap_int16_t(a, b) \ 47 | { \ 48 | int16_t t = a; \ 49 | a = b; \ 50 | b = t; \ 51 | } ///< 16-bit var swap 52 | #endif 53 | 54 | static const PROGMEM uint8_t sevensegfonttable[] = { 55 | 56 | 0b00000000, // (space) 57 | 0b10000110, // ! 58 | 0b00100010, // " 59 | 0b01111110, // # 60 | 0b01101101, // $ 61 | 0b11010010, // % 62 | 0b01000110, // & 63 | 0b00100000, // ' 64 | 0b00101001, // ( 65 | 0b00001011, // ) 66 | 0b00100001, // * 67 | 0b01110000, // + 68 | 0b00010000, // , 69 | 0b01000000, // - 70 | 0b10000000, // . 71 | 0b01010010, // / 72 | 0b00111111, // 0 73 | 0b00000110, // 1 74 | 0b01011011, // 2 75 | 0b01001111, // 3 76 | 0b01100110, // 4 77 | 0b01101101, // 5 78 | 0b01111101, // 6 79 | 0b00000111, // 7 80 | 0b01111111, // 8 81 | 0b01101111, // 9 82 | 0b00001001, // : 83 | 0b00001101, // ; 84 | 0b01100001, // < 85 | 0b01001000, // = 86 | 0b01000011, // > 87 | 0b11010011, // ? 88 | 0b01011111, // @ 89 | 0b01110111, // A 90 | 0b01111100, // B 91 | 0b00111001, // C 92 | 0b01011110, // D 93 | 0b01111001, // E 94 | 0b01110001, // F 95 | 0b00111101, // G 96 | 0b01110110, // H 97 | 0b00110000, // I 98 | 0b00011110, // J 99 | 0b01110101, // K 100 | 0b00111000, // L 101 | 0b00010101, // M 102 | 0b00110111, // N 103 | 0b00111111, // O 104 | 0b01110011, // P 105 | 0b01101011, // Q 106 | 0b00110011, // R 107 | 0b01101101, // S 108 | 0b01111000, // T 109 | 0b00111110, // U 110 | 0b00111110, // V 111 | 0b00101010, // W 112 | 0b01110110, // X 113 | 0b01101110, // Y 114 | 0b01011011, // Z 115 | 0b00111001, // [ 116 | 0b01100100, // 117 | 0b00001111, // ] 118 | 0b00100011, // ^ 119 | 0b00001000, // _ 120 | 0b00000010, // ` 121 | 0b01011111, // a 122 | 0b01111100, // b 123 | 0b01011000, // c 124 | 0b01011110, // d 125 | 0b01111011, // e 126 | 0b01110001, // f 127 | 0b01101111, // g 128 | 0b01110100, // h 129 | 0b00010000, // i 130 | 0b00001100, // j 131 | 0b01110101, // k 132 | 0b00110000, // l 133 | 0b00010100, // m 134 | 0b01010100, // n 135 | 0b01011100, // o 136 | 0b01110011, // p 137 | 0b01100111, // q 138 | 0b01010000, // r 139 | 0b01101101, // s 140 | 0b01111000, // t 141 | 0b00011100, // u 142 | 0b00011100, // v 143 | 0b00010100, // w 144 | 0b01110110, // x 145 | 0b01101110, // y 146 | 0b01011011, // z 147 | 0b01000110, // { 148 | 0b00110000, // | 149 | 0b01110000, // } 150 | 0b00000001, // ~ 151 | 0b00000000, // del 152 | }; 153 | 154 | static const PROGMEM uint16_t alphafonttable[] = { 155 | 156 | 0b0000000000000001, 0b0000000000000010, 0b0000000000000100, 157 | 0b0000000000001000, 0b0000000000010000, 0b0000000000100000, 158 | 0b0000000001000000, 0b0000000010000000, 0b0000000100000000, 159 | 0b0000001000000000, 0b0000010000000000, 0b0000100000000000, 160 | 0b0001000000000000, 0b0010000000000000, 0b0100000000000000, 161 | 0b1000000000000000, 0b0000000000000000, 0b0000000000000000, 162 | 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 163 | 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 164 | 0b0001001011001001, 0b0001010111000000, 0b0001001011111001, 165 | 0b0000000011100011, 0b0000010100110000, 0b0001001011001000, 166 | 0b0011101000000000, 0b0001011100000000, 167 | 0b0000000000000000, // 168 | 0b0000000000000110, // ! 169 | 0b0000001000100000, // " 170 | 0b0001001011001110, // # 171 | 0b0001001011101101, // $ 172 | 0b0000110000100100, // % 173 | 0b0010001101011101, // & 174 | 0b0000010000000000, // ' 175 | 0b0010010000000000, // ( 176 | 0b0000100100000000, // ) 177 | 0b0011111111000000, // * 178 | 0b0001001011000000, // + 179 | 0b0000100000000000, // , 180 | 0b0000000011000000, // - 181 | 0b0100000000000000, // . 182 | 0b0000110000000000, // / 183 | 0b0000110000111111, // 0 184 | 0b0000000000000110, // 1 185 | 0b0000000011011011, // 2 186 | 0b0000000010001111, // 3 187 | 0b0000000011100110, // 4 188 | 0b0010000001101001, // 5 189 | 0b0000000011111101, // 6 190 | 0b0000000000000111, // 7 191 | 0b0000000011111111, // 8 192 | 0b0000000011101111, // 9 193 | 0b0001001000000000, // : 194 | 0b0000101000000000, // ; 195 | 0b0010010000000000, // < 196 | 0b0000000011001000, // = 197 | 0b0000100100000000, // > 198 | 0b0001000010000011, // ? 199 | 0b0000001010111011, // @ 200 | 0b0000000011110111, // A 201 | 0b0001001010001111, // B 202 | 0b0000000000111001, // C 203 | 0b0001001000001111, // D 204 | 0b0000000011111001, // E 205 | 0b0000000001110001, // F 206 | 0b0000000010111101, // G 207 | 0b0000000011110110, // H 208 | 0b0001001000001001, // I 209 | 0b0000000000011110, // J 210 | 0b0010010001110000, // K 211 | 0b0000000000111000, // L 212 | 0b0000010100110110, // M 213 | 0b0010000100110110, // N 214 | 0b0000000000111111, // O 215 | 0b0000000011110011, // P 216 | 0b0010000000111111, // Q 217 | 0b0010000011110011, // R 218 | 0b0000000011101101, // S 219 | 0b0001001000000001, // T 220 | 0b0000000000111110, // U 221 | 0b0000110000110000, // V 222 | 0b0010100000110110, // W 223 | 0b0010110100000000, // X 224 | 0b0001010100000000, // Y 225 | 0b0000110000001001, // Z 226 | 0b0000000000111001, // [ 227 | 0b0010000100000000, // 228 | 0b0000000000001111, // ] 229 | 0b0000110000000011, // ^ 230 | 0b0000000000001000, // _ 231 | 0b0000000100000000, // ` 232 | 0b0001000001011000, // a 233 | 0b0010000001111000, // b 234 | 0b0000000011011000, // c 235 | 0b0000100010001110, // d 236 | 0b0000100001011000, // e 237 | 0b0000000001110001, // f 238 | 0b0000010010001110, // g 239 | 0b0001000001110000, // h 240 | 0b0001000000000000, // i 241 | 0b0000000000001110, // j 242 | 0b0011011000000000, // k 243 | 0b0000000000110000, // l 244 | 0b0001000011010100, // m 245 | 0b0001000001010000, // n 246 | 0b0000000011011100, // o 247 | 0b0000000101110000, // p 248 | 0b0000010010000110, // q 249 | 0b0000000001010000, // r 250 | 0b0010000010001000, // s 251 | 0b0000000001111000, // t 252 | 0b0000000000011100, // u 253 | 0b0010000000000100, // v 254 | 0b0010100000010100, // w 255 | 0b0010100011000000, // x 256 | 0b0010000000001100, // y 257 | 0b0000100001001000, // z 258 | 0b0000100101001001, // { 259 | 0b0001001000000000, // | 260 | 0b0010010010001001, // } 261 | 0b0000010100100000, // ~ 262 | 0b0011111111111111, 263 | 264 | }; 265 | 266 | void Adafruit_LEDBackpack::setDisplayState(bool state) { 267 | uint8_t buffer; 268 | if (state) 269 | buffer = HT16K33_BLINK_CMD | 1; 270 | else 271 | buffer = HT16K33_BLINK_CMD; 272 | i2c_dev->write(&buffer, 1); 273 | } 274 | 275 | void Adafruit_LEDBackpack::setBrightness(uint8_t b) { 276 | if (b > 15) 277 | b = 15; // limit to max brightness 278 | uint8_t buffer = HT16K33_CMD_BRIGHTNESS | b; 279 | i2c_dev->write(&buffer, 1); 280 | } 281 | 282 | void Adafruit_LEDBackpack::blinkRate(uint8_t b) { 283 | if (b > 3) 284 | b = 0; // turn off if not sure 285 | uint8_t buffer = HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON | (b << 1); 286 | i2c_dev->write(&buffer, 1); 287 | } 288 | 289 | Adafruit_LEDBackpack::Adafruit_LEDBackpack(void) {} 290 | 291 | bool Adafruit_LEDBackpack::begin(uint8_t _addr, TwoWire *theWire) { 292 | if (i2c_dev) 293 | delete i2c_dev; 294 | i2c_dev = new Adafruit_I2CDevice(_addr, theWire); 295 | if (!i2c_dev->begin()) 296 | return false; 297 | 298 | // turn on oscillator 299 | uint8_t buffer[1] = {0x21}; 300 | i2c_dev->write(buffer, 1); 301 | 302 | // internal RAM powers up with garbage/random values. 303 | // ensure internal RAM is cleared before turning on display 304 | // this ensures that no garbage pixels show up on the display 305 | // when it is turned on. 306 | clear(); 307 | writeDisplay(); 308 | 309 | blinkRate(HT16K33_BLINK_OFF); 310 | 311 | setBrightness(15); // max brightness 312 | 313 | return true; 314 | } 315 | 316 | void Adafruit_LEDBackpack::writeDisplay(void) { 317 | uint8_t buffer[17]; 318 | 319 | buffer[0] = 0x00; // start at address $00 320 | 321 | for (uint8_t i = 0; i < 8; i++) { 322 | buffer[1 + 2 * i] = displaybuffer[i] & 0xFF; 323 | buffer[2 + 2 * i] = displaybuffer[i] >> 8; 324 | } 325 | 326 | i2c_dev->write(buffer, 17); 327 | } 328 | 329 | void Adafruit_LEDBackpack::clear(void) { 330 | for (uint8_t i = 0; i < 8; i++) { 331 | displaybuffer[i] = 0; 332 | } 333 | } 334 | 335 | /******************************* QUAD ALPHANUM OBJECT */ 336 | 337 | Adafruit_AlphaNum4::Adafruit_AlphaNum4(void) {} 338 | 339 | void Adafruit_AlphaNum4::writeDigitRaw(uint8_t n, uint16_t bitmask) { 340 | displaybuffer[n] = bitmask; 341 | } 342 | 343 | void Adafruit_AlphaNum4::writeDigitAscii(uint8_t n, uint8_t a, bool d) { 344 | uint16_t font = pgm_read_word(alphafonttable + a); 345 | 346 | displaybuffer[n] = font; 347 | 348 | /* 349 | Serial.print(a, DEC); 350 | Serial.print(" / '"); Serial.write(a); 351 | Serial.print("' = 0x"); Serial.println(font, HEX); 352 | */ 353 | 354 | if (d) 355 | displaybuffer[n] |= (1 << 14); 356 | } 357 | 358 | /******************************* 24 BARGRAPH OBJECT */ 359 | 360 | Adafruit_24bargraph::Adafruit_24bargraph(void) {} 361 | 362 | void Adafruit_24bargraph::setBar(uint8_t bar, uint8_t color) { 363 | uint16_t a, c; 364 | 365 | if (bar < 12) 366 | c = bar / 4; 367 | else 368 | c = (bar - 12) / 4; 369 | 370 | a = bar % 4; 371 | if (bar >= 12) 372 | a += 4; 373 | 374 | // Serial.print("Ano = "); Serial.print(a); Serial.print(" Cath = "); 375 | // Serial.println(c); 376 | if (color == LED_RED) { 377 | // Turn on red LED. 378 | displaybuffer[c] |= _BV(a); 379 | // Turn off green LED. 380 | displaybuffer[c] &= ~_BV(a + 8); 381 | } else if (color == LED_YELLOW) { 382 | // Turn on red and green LED. 383 | displaybuffer[c] |= _BV(a) | _BV(a + 8); 384 | } else if (color == LED_OFF) { 385 | // Turn off red and green LED. 386 | displaybuffer[c] &= ~_BV(a) & ~_BV(a + 8); 387 | } else if (color == LED_GREEN) { 388 | // Turn on green LED. 389 | displaybuffer[c] |= _BV(a + 8); 390 | // Turn off red LED. 391 | displaybuffer[c] &= ~_BV(a); 392 | } 393 | } 394 | 395 | /******************************* 16x8 MATRIX OBJECT */ 396 | 397 | Adafruit_8x16matrix::Adafruit_8x16matrix(void) : Adafruit_GFX(8, 16) {} 398 | 399 | void Adafruit_8x16matrix::drawPixel(int16_t x, int16_t y, uint16_t color) { 400 | 401 | // check rotation, move pixel around if necessary 402 | switch (getRotation()) { 403 | case 2: 404 | _swap_int16_t(x, y); 405 | x = 16 - x - 1; 406 | break; 407 | case 3: 408 | x = 16 - x - 1; 409 | y = 8 - y - 1; 410 | break; 411 | case 0: 412 | _swap_int16_t(x, y); 413 | y = 8 - y - 1; 414 | break; 415 | } 416 | /* 417 | Serial.print("("); Serial.print(x); 418 | Serial.print(","); Serial.print(y); 419 | Serial.println(")"); 420 | */ 421 | 422 | if ((y < 0) || (y >= 8)) 423 | return; 424 | if ((x < 0) || (x >= 16)) 425 | return; 426 | 427 | if (color) { 428 | displaybuffer[y] |= 1 << x; 429 | } else { 430 | displaybuffer[y] &= ~(1 << x); 431 | } 432 | } 433 | 434 | /******************************* 16x8 MINI MATRIX OBJECT */ 435 | 436 | Adafruit_8x16minimatrix::Adafruit_8x16minimatrix(void) : Adafruit_GFX(8, 16) {} 437 | 438 | void Adafruit_8x16minimatrix::drawPixel(int16_t x, int16_t y, uint16_t color) { 439 | 440 | if ((y < 0) || (x < 0)) 441 | return; 442 | if ((getRotation() % 2 == 0) && ((y >= 16) || (x >= 8))) 443 | return; 444 | if ((getRotation() % 2 == 1) && ((x >= 16) || (y >= 8))) 445 | return; 446 | 447 | // check rotation, move pixel around if necessary 448 | switch (getRotation()) { 449 | case 2: 450 | if (y >= 8) { 451 | x += 8; 452 | y -= 8; 453 | } 454 | _swap_int16_t(x, y); 455 | break; 456 | case 3: 457 | x = 16 - x - 1; 458 | if (x >= 8) { 459 | x -= 8; 460 | y += 8; 461 | } 462 | break; 463 | case 0: 464 | y = 16 - y - 1; 465 | x = 8 - x - 1; 466 | if (y >= 8) { 467 | x += 8; 468 | y -= 8; 469 | } 470 | _swap_int16_t(x, y); 471 | break; 472 | case 1: 473 | y = 8 - y - 1; 474 | if (x >= 8) { 475 | x -= 8; 476 | y += 8; 477 | } 478 | break; 479 | } 480 | 481 | if (color) { 482 | displaybuffer[x] |= 1 << y; 483 | } else { 484 | displaybuffer[x] &= ~(1 << y); 485 | } 486 | } 487 | 488 | /******************************* 8x8 MATRIX OBJECT */ 489 | 490 | Adafruit_8x8matrix::Adafruit_8x8matrix(void) : Adafruit_GFX(8, 8) {} 491 | 492 | void Adafruit_8x8matrix::drawPixel(int16_t x, int16_t y, uint16_t color) { 493 | if ((y < 0) || (y >= 8)) 494 | return; 495 | if ((x < 0) || (x >= 8)) 496 | return; 497 | 498 | // check rotation, move pixel around if necessary 499 | switch (getRotation()) { 500 | case 1: 501 | _swap_int16_t(x, y); 502 | x = 8 - x - 1; 503 | break; 504 | case 2: 505 | x = 8 - x - 1; 506 | y = 8 - y - 1; 507 | break; 508 | case 3: 509 | _swap_int16_t(x, y); 510 | y = 8 - y - 1; 511 | break; 512 | } 513 | 514 | // wrap around the x 515 | x += 7; 516 | x %= 8; 517 | 518 | if (color) { 519 | displaybuffer[y] |= 1 << x; 520 | } else { 521 | displaybuffer[y] &= ~(1 << x); 522 | } 523 | } 524 | 525 | /******************************* 8x8 BICOLOR MATRIX OBJECT */ 526 | 527 | Adafruit_BicolorMatrix::Adafruit_BicolorMatrix(void) : Adafruit_GFX(8, 8) {} 528 | 529 | void Adafruit_BicolorMatrix::drawPixel(int16_t x, int16_t y, uint16_t color) { 530 | if ((y < 0) || (y >= 8)) 531 | return; 532 | if ((x < 0) || (x >= 8)) 533 | return; 534 | 535 | switch (getRotation()) { 536 | case 1: 537 | _swap_int16_t(x, y); 538 | x = 8 - x - 1; 539 | break; 540 | case 2: 541 | x = 8 - x - 1; 542 | y = 8 - y - 1; 543 | break; 544 | case 3: 545 | _swap_int16_t(x, y); 546 | y = 8 - y - 1; 547 | break; 548 | } 549 | 550 | if (color == LED_GREEN) { 551 | // Turn on green LED. 552 | displaybuffer[y] |= 1 << x; 553 | // Turn off red LED. 554 | displaybuffer[y] &= ~(1 << (x + 8)); 555 | } else if (color == LED_RED) { 556 | // Turn on red LED. 557 | displaybuffer[y] |= 1 << (x + 8); 558 | // Turn off green LED. 559 | displaybuffer[y] &= ~(1 << x); 560 | } else if (color == LED_YELLOW) { 561 | // Turn on green and red LED. 562 | displaybuffer[y] |= (1 << (x + 8)) | (1 << x); 563 | } else if (color == LED_OFF) { 564 | // Turn off green and red LED. 565 | displaybuffer[y] &= ~(1 << x) & ~(1 << (x + 8)); 566 | } 567 | } 568 | 569 | /******************************* 7 SEGMENT OBJECT */ 570 | 571 | Adafruit_7segment::Adafruit_7segment(void) { position = 0; } 572 | 573 | void Adafruit_7segment::print(const String &c) { write(c.c_str(), c.length()); } 574 | 575 | void Adafruit_7segment::print(const char c[]) { write(c, strlen(c)); } 576 | 577 | void Adafruit_7segment::print(char c) { write(c); } 578 | 579 | void Adafruit_7segment::print(unsigned long n, int base) { 580 | if (base == 0) 581 | write(n); 582 | else 583 | printNumber(n, base); 584 | } 585 | 586 | void Adafruit_7segment::print(unsigned char b, int base) { 587 | print((unsigned long)b, base); 588 | } 589 | 590 | void Adafruit_7segment::print(int n, int base) { print((long)n, base); } 591 | 592 | void Adafruit_7segment::print(unsigned int n, int base) { 593 | print((unsigned long)n, base); 594 | } 595 | 596 | void Adafruit_7segment::println(void) { position = 0; } 597 | 598 | void Adafruit_7segment::println(const String &c) { 599 | print(c); 600 | println(); 601 | } 602 | 603 | void Adafruit_7segment::println(const char c[]) { 604 | print(c); 605 | println(); 606 | } 607 | 608 | void Adafruit_7segment::println(char c) { 609 | print(c); 610 | println(); 611 | } 612 | 613 | void Adafruit_7segment::println(unsigned char b, int base) { 614 | print(b, base); 615 | println(); 616 | } 617 | 618 | void Adafruit_7segment::println(int n, int base) { 619 | print(n, base); 620 | println(); 621 | } 622 | 623 | void Adafruit_7segment::println(unsigned int n, int base) { 624 | print(n, base); 625 | println(); 626 | } 627 | 628 | void Adafruit_7segment::println(long n, int base) { 629 | print(n, base); 630 | println(); 631 | } 632 | 633 | void Adafruit_7segment::println(unsigned long n, int base) { 634 | print(n, base); 635 | println(); 636 | } 637 | 638 | void Adafruit_7segment::println(double n, int digits) { 639 | print(n, digits); 640 | println(); 641 | } 642 | 643 | void Adafruit_7segment::print(double n, int digits) { printFloat(n, digits); } 644 | 645 | size_t Adafruit_7segment::write(char c) { 646 | 647 | uint8_t r = 0; 648 | 649 | if (c == '\n') 650 | position = 0; 651 | if (c == '\r') 652 | position = 0; 653 | 654 | if ((c >= ' ') && (c <= 127)) { 655 | writeDigitAscii(position, c); 656 | r = 1; 657 | } 658 | 659 | position++; 660 | if (position == 2) 661 | position++; 662 | 663 | return r; 664 | } 665 | 666 | size_t Adafruit_7segment::write(const char *buffer, size_t size) { 667 | size_t n = 0; 668 | 669 | while (n < size) { 670 | write(buffer[n]); 671 | n++; 672 | } 673 | 674 | // Clear unwritten positions 675 | for (uint8_t i = position; i < 5; i++) { 676 | writeDigitRaw(i, 0x00); 677 | } 678 | 679 | return n; 680 | } 681 | 682 | void Adafruit_7segment::writeDigitRaw(uint8_t d, uint8_t bitmask) { 683 | if (d > 4) 684 | return; 685 | displaybuffer[d] = bitmask; 686 | } 687 | 688 | void Adafruit_7segment::drawColon(bool state) { 689 | if (state) 690 | displaybuffer[2] = 0x2; 691 | else 692 | displaybuffer[2] = 0; 693 | } 694 | 695 | void Adafruit_7segment::writeColon(void) { 696 | uint8_t buffer[3]; 697 | 698 | buffer[0] = 0x04; // start at address $02 699 | buffer[1] = displaybuffer[2] & 0xFF; 700 | buffer[2] = displaybuffer[2] >> 8; 701 | 702 | i2c_dev->write(buffer, 3); 703 | } 704 | 705 | void Adafruit_7segment::writeDigitNum(uint8_t d, uint8_t num, bool dot) { 706 | if (d > 4 || num > 15) 707 | return; 708 | 709 | if (num >= 10) { // Hex characters 710 | switch (num) { 711 | case 10: 712 | writeDigitAscii(d, 'a', dot); 713 | break; 714 | case 11: 715 | writeDigitAscii(d, 'B', dot); 716 | break; 717 | case 12: 718 | writeDigitAscii(d, 'C', dot); 719 | break; 720 | case 13: 721 | writeDigitAscii(d, 'd', dot); 722 | break; 723 | case 14: 724 | writeDigitAscii(d, 'E', dot); 725 | break; 726 | case 15: 727 | writeDigitAscii(d, 'F', dot); 728 | break; 729 | } 730 | } 731 | 732 | else 733 | writeDigitAscii(d, num + 48, dot); // use ASCII offset 734 | } 735 | 736 | void Adafruit_7segment::writeDigitAscii(uint8_t d, uint8_t c, bool dot) { 737 | if (d > 4) 738 | return; 739 | 740 | uint8_t font = pgm_read_byte(sevensegfonttable + c - 32); 741 | 742 | writeDigitRaw(d, font | (dot << 7)); 743 | } 744 | 745 | void Adafruit_7segment::print(long n, int base) { printNumber(n, base); } 746 | 747 | void Adafruit_7segment::printNumber(long n, uint8_t base) { 748 | printFloat(n, 0, base); 749 | } 750 | 751 | void Adafruit_7segment::printFloat(double n, uint8_t fracDigits, uint8_t base) { 752 | uint8_t numericDigits = 4; // available digits on display 753 | bool isNegative = false; // true if the number is negative 754 | 755 | // is the number negative? 756 | if (n < 0) { 757 | isNegative = true; // need to draw sign later 758 | --numericDigits; // the sign will take up one digit 759 | n *= -1; // pretend the number is positive 760 | } 761 | 762 | // calculate the factor required to shift all fractional digits 763 | // into the integer part of the number 764 | double toIntFactor = 1.0; 765 | for (int i = 0; i < fracDigits; ++i) 766 | toIntFactor *= base; 767 | 768 | // create integer containing digits to display by applying 769 | // shifting factor and rounding adjustment 770 | uint32_t displayNumber = n * toIntFactor + 0.5; 771 | 772 | // calculate upper bound on displayNumber given 773 | // available digits on display 774 | uint32_t tooBig = 1; 775 | for (int i = 0; i < numericDigits; ++i) 776 | tooBig *= base; 777 | 778 | // if displayNumber is too large, try fewer fractional digits 779 | while (displayNumber >= tooBig) { 780 | --fracDigits; 781 | toIntFactor /= base; 782 | displayNumber = n * toIntFactor + 0.5; 783 | } 784 | 785 | // did toIntFactor shift the decimal off the display? 786 | if (toIntFactor < 1) { 787 | printError(); 788 | } else { 789 | // otherwise, display the number 790 | int8_t displayPos = 4; 791 | 792 | for (uint8_t i = 0; displayNumber || i <= fracDigits; ++i) { 793 | bool displayDecimal = (fracDigits != 0 && i == fracDigits); 794 | writeDigitNum(displayPos--, displayNumber % base, displayDecimal); 795 | if (displayPos == 2) 796 | writeDigitRaw(displayPos--, 0x00); 797 | displayNumber /= base; 798 | } 799 | 800 | // display negative sign if negative 801 | if (isNegative) 802 | writeDigitRaw(displayPos--, 0x40); 803 | 804 | // clear remaining display positions 805 | while (displayPos >= 0) 806 | writeDigitRaw(displayPos--, 0x00); 807 | } 808 | } 809 | 810 | void Adafruit_7segment::printError(void) { 811 | for (uint8_t i = 0; i < SEVENSEG_DIGITS; ++i) { 812 | writeDigitRaw(i, (i == 2 ? 0x00 : 0x40)); 813 | } 814 | } 815 | -------------------------------------------------------------------------------- /Adafruit_LEDBackpack.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_LEDBackpack.h 3 | * 4 | * Part of Adafruit's Arduino library for our I2C LED Backpacks: 5 | * ----> http://www.adafruit.com/products/ 6 | * ----> http://www.adafruit.com/products/ 7 | * 8 | * These displays use I2C to communicate, 2 pins are required to 9 | * interface. There are multiple selectable I2C addresses. For backpacks 10 | * with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks 11 | * with 3 Address Select pins: 0x70 thru 0x77 12 | * 13 | * Adafruit invests time and resources providing this open source code, 14 | * please support Adafruit and open-source hardware by purchasing 15 | * products from Adafruit! 16 | * 17 | * Written by Limor Fried/Ladyada for Adafruit Industries. 18 | * 19 | * MIT license, all text above must be included in any redistribution 20 | */ 21 | 22 | #ifndef Adafruit_LEDBackpack_h 23 | #define Adafruit_LEDBackpack_h 24 | 25 | #if (ARDUINO >= 100) 26 | #include "Arduino.h" 27 | #else 28 | #include "WProgram.h" 29 | #endif 30 | 31 | #include 32 | 33 | #include "Adafruit_GFX.h" 34 | 35 | #define LED_ON 1 ///< GFX color of lit LED segments (single-color displays) 36 | #define LED_OFF 0 ///< GFX color of unlit LED segments (single-color displays) 37 | 38 | #define LED_RED 1 ///< GFX color for red LED segments (bi-color displays) 39 | #define LED_YELLOW 2 ///< GFX color for yellow LED segments (bi-color displays) 40 | #define LED_GREEN 3 ///< GFX color for green LED segments (bi-color displays) 41 | 42 | #define HT16K33_BLINK_CMD 0x80 ///< I2C register for BLINK setting 43 | #define HT16K33_BLINK_DISPLAYON 0x01 ///< I2C value for steady on 44 | #define HT16K33_BLINK_OFF 0 ///< I2C value for steady off 45 | #define HT16K33_BLINK_2HZ 1 ///< I2C value for 2 Hz blink 46 | #define HT16K33_BLINK_1HZ 2 ///< I2C value for 1 Hz blink 47 | #define HT16K33_BLINK_HALFHZ 3 ///< I2C value for 0.5 Hz blink 48 | 49 | #define HT16K33_CMD_BRIGHTNESS 0xE0 ///< I2C register for BRIGHTNESS setting 50 | 51 | #define SEVENSEG_DIGITS 5 ///< # Digits in 7-seg displays, plus NUL end 52 | 53 | /* 54 | Segment names for 14-segment alphanumeric displays. 55 | See https://learn.adafruit.com/14-segment-alpha-numeric-led-featherwing/usage 56 | 57 | -------A------- 58 | |\ | /| 59 | | \ J / | 60 | | H | K | 61 | F \ | / B 62 | | \|/ | 63 | |--G1--|--G2--| 64 | | /|\ | 65 | E / | \ C 66 | | L | N | 67 | | / M \ | 68 | |/ | \| 69 | -------D------- DP 70 | */ 71 | 72 | #define ALPHANUM_SEG_A 0b0000000000000001 ///< Alphanumeric segment A 73 | #define ALPHANUM_SEG_B 0b0000000000000010 ///< Alphanumeric segment B 74 | #define ALPHANUM_SEG_C 0b0000000000000100 ///< Alphanumeric segment C 75 | #define ALPHANUM_SEG_D 0b0000000000001000 ///< Alphanumeric segment D 76 | #define ALPHANUM_SEG_E 0b0000000000010000 ///< Alphanumeric segment E 77 | #define ALPHANUM_SEG_F 0b0000000000100000 ///< Alphanumeric segment F 78 | #define ALPHANUM_SEG_G1 0b0000000001000000 ///< Alphanumeric segment G1 79 | #define ALPHANUM_SEG_G2 0b0000000010000000 ///< Alphanumeric segment G2 80 | #define ALPHANUM_SEG_H 0b0000000100000000 ///< Alphanumeric segment H 81 | #define ALPHANUM_SEG_J 0b0000001000000000 ///< Alphanumeric segment J 82 | #define ALPHANUM_SEG_K 0b0000010000000000 ///< Alphanumeric segment K 83 | #define ALPHANUM_SEG_L 0b0000100000000000 ///< Alphanumeric segment L 84 | #define ALPHANUM_SEG_M 0b0001000000000000 ///< Alphanumeric segment M 85 | #define ALPHANUM_SEG_N 0b0010000000000000 ///< Alphanumeric segment N 86 | #define ALPHANUM_SEG_DP 0b0100000000000000 ///< Alphanumeric segment DP 87 | 88 | /*! 89 | @brief Class encapsulating the raw HT16K33 controller device. 90 | */ 91 | class Adafruit_LEDBackpack { 92 | public: 93 | /*! 94 | @brief Constructor for HT16K33 devices. 95 | */ 96 | Adafruit_LEDBackpack(void); 97 | 98 | /*! 99 | @brief Start I2C and initialize display state (blink off, full 100 | brightness). 101 | @param _addr I2C address. 102 | @param theWire TwoWire bus reference to use. 103 | @return true if successful, otherwise false 104 | 105 | */ 106 | bool begin(uint8_t _addr = 0x70, TwoWire *theWire = &Wire); 107 | 108 | /*! 109 | @brief Turn display on or off 110 | @param state State: true = on, false = off 111 | */ 112 | void setDisplayState(bool state); 113 | 114 | /*! 115 | @brief Set display brightness. 116 | @param b Brightness: 0 (min) to 15 (max). 117 | */ 118 | void setBrightness(uint8_t b); 119 | 120 | /*! 121 | @brief Set display blink rate. 122 | @param b One of: 123 | HT16K33_BLINK_OFF = no blinking 124 | HT16K33_BLINK_2HZ = 2 Hz blink 125 | HT16K33_BLINK_1HZ = 1 Hz blink 126 | HT16K33_BLINK_HALFHZ = 0.5 Hz blink 127 | */ 128 | void blinkRate(uint8_t b); 129 | 130 | /*! 131 | @brief Issue buffered data in RAM to display. 132 | */ 133 | void writeDisplay(void); 134 | 135 | /*! 136 | @brief Clear display. 137 | */ 138 | void clear(void); 139 | 140 | uint16_t displaybuffer[8]; ///< Raw display data 141 | 142 | protected: 143 | Adafruit_I2CDevice *i2c_dev = NULL; ///< Pointer to I2C bus interface 144 | }; 145 | 146 | /*! 147 | @brief Class for 24-element bargraph displays. 148 | */ 149 | class Adafruit_24bargraph : public Adafruit_LEDBackpack { 150 | public: 151 | /*! 152 | @brief Constructor for 24-element bargraph displays. 153 | */ 154 | Adafruit_24bargraph(void); 155 | 156 | /*! 157 | @brief Set color a single bar (dot). 158 | @param bar Bar index (0 to 23). 159 | @param color Bar color: LED_OFF, LED_GREEN, LED_YELLOW or LED_RED. 160 | */ 161 | void setBar(uint8_t bar, uint8_t color); 162 | }; 163 | 164 | /*! 165 | @brief Class for 8x16 pixel single-color matrices. 166 | */ 167 | class Adafruit_8x16matrix : public Adafruit_LEDBackpack, public Adafruit_GFX { 168 | public: 169 | /*! 170 | @brief Constructor for 8x16 pixel single-color matrices. 171 | */ 172 | Adafruit_8x16matrix(void); 173 | 174 | /*! 175 | @brief Lowest-level pixel drawing function required by Adafruit_GFX. 176 | Does not have an immediate effect -- must call writeDisplay() 177 | after any drawing operations to refresh display contents. 178 | @param x Pixel column (horizontal). 179 | @param y Pixel row (vertical). 180 | @param color Pixel color (1 = pixel on, 0 = pixel off). 181 | */ 182 | void drawPixel(int16_t x, int16_t y, uint16_t color); 183 | }; 184 | 185 | /*! 186 | @brief Class for 8x16 pixel single-color mini matrices. 187 | */ 188 | class Adafruit_8x16minimatrix : public Adafruit_LEDBackpack, 189 | public Adafruit_GFX { 190 | public: 191 | /*! 192 | @brief Constructor for 8x16 pixel single-color mini matrices. 193 | */ 194 | Adafruit_8x16minimatrix(void); 195 | 196 | /*! 197 | @brief Lowest-level pixel drawing function required by Adafruit_GFX. 198 | Does not have an immediate effect -- must call writeDisplay() 199 | after any drawing operations to refresh display contents. 200 | @param x Pixel column (horizontal). 201 | @param y Pixel row (vertical). 202 | @param color Pixel color (1 = pixel on, 0 = pixel off). 203 | */ 204 | void drawPixel(int16_t x, int16_t y, uint16_t color); 205 | }; 206 | 207 | /*! 208 | @brief Class for 8x8 pixel single-color matrices. 209 | */ 210 | class Adafruit_8x8matrix : public Adafruit_LEDBackpack, public Adafruit_GFX { 211 | public: 212 | /*! 213 | @brief Constructor for 8x8 pixel single-color matrices. 214 | */ 215 | Adafruit_8x8matrix(void); 216 | 217 | /*! 218 | @brief Lowest-level pixel drawing function required by Adafruit_GFX. 219 | Does not have an immediate effect -- must call writeDisplay() 220 | after any drawing operations to refresh display contents. 221 | @param x Pixel column (horizontal). 222 | @param y Pixel row (vertical). 223 | @param color Pixel color (1 = pixel on, 0 = pixel off). 224 | */ 225 | void drawPixel(int16_t x, int16_t y, uint16_t color); 226 | }; 227 | 228 | /*! 229 | @brief Class for bi-color matrices. 230 | */ 231 | class Adafruit_BicolorMatrix : public Adafruit_LEDBackpack, 232 | public Adafruit_GFX { 233 | public: 234 | /*! 235 | @brief Constructor for 8x8 pixel bi-color matrices. 236 | */ 237 | Adafruit_BicolorMatrix(void); 238 | 239 | /*! 240 | @brief Lowest-level pixel drawing function required by Adafruit_GFX. 241 | Does not have an immediate effect -- must call writeDisplay() 242 | after any drawing operations to refresh display contents. 243 | @param x Pixel column (horizontal). 244 | @param y Pixel row (vertical). 245 | @param color Pixel color (LED_OFF, LED_GREEN, LED_YELLOW or LED_RED). 246 | */ 247 | void drawPixel(int16_t x, int16_t y, uint16_t color); 248 | }; 249 | 250 | #define RAW_BITS 0 ///< Issue 7-segment data as raw bits 251 | 252 | /*! 253 | @brief Class for 7-segment numeric displays. 254 | */ 255 | class Adafruit_7segment : public Adafruit_LEDBackpack { 256 | public: 257 | /*! 258 | @brief Constructor for 7-segment numeric displays. 259 | */ 260 | Adafruit_7segment(void); 261 | 262 | /*! 263 | @brief Issue single character to display. 264 | @param c Character to write (ASCII character, not numeric). 265 | @return 1 if character written, else 0 (non-ASCII characters). 266 | */ 267 | size_t write(char c); 268 | 269 | /*! 270 | @brief Write characters from buffer to display. 271 | @param buffer Character array to write 272 | @param size Number of characters to write 273 | @return Number of characters written 274 | */ 275 | size_t write(const char *buffer, size_t size); 276 | 277 | /*! 278 | @brief Print byte-size numeric value to 7-segment display. 279 | @param c Numeric value. 280 | */ 281 | void print(char c); 282 | 283 | /*! 284 | @brief Print unsigned byte-size numeric value to 7-segment display. 285 | @param b Numeric value. 286 | @param base Number base (default = RAW_BITS = raw bits) 287 | */ 288 | void print(unsigned char b, int base = RAW_BITS); 289 | 290 | /*! 291 | @brief Print integer value to 7-segment display. 292 | @param n Numeric value. 293 | @param base Number base (default = DEC = base 10) 294 | */ 295 | void print(int n, int base = DEC); 296 | 297 | /*! 298 | @brief Print unsigned integer value to 7-segment display. 299 | @param n Numeric value. 300 | @param base Number base (default = DEC = base 10) 301 | */ 302 | void print(unsigned int n, int base = DEC); 303 | 304 | /*! 305 | @brief Print long integer value to 7-segment display. 306 | @param n Numeric value. 307 | @param base Number base (default = DEC = base 10) 308 | */ 309 | void print(long n, int base = DEC); 310 | 311 | /*! 312 | @brief Print unsigned long integer value to 7-segment display. 313 | @param n Numeric value. 314 | @param base Number base (default = DEC = base 10) 315 | */ 316 | void print(unsigned long n, int base = DEC); 317 | 318 | /*! 319 | @brief Print double-precision float value to 7-segment display. 320 | @param n Numeric value. 321 | @param digits Fractional-part digits. 322 | */ 323 | void print(double n, int digits = 2); 324 | 325 | /*! 326 | @brief Print from a String object to 7-segment display. 327 | @param c String object, passed by reference. 328 | */ 329 | void print(const String &c); 330 | 331 | /*! 332 | @brief Print from a C-style string array to 7-segment display. 333 | @param c Array of characters. 334 | */ 335 | void print(const char c[]); 336 | 337 | /*! 338 | @brief Print byte-size numeric value w/newline to 7-segment display. 339 | @param c Numeric value. 340 | */ 341 | void println(char c); 342 | 343 | /*! 344 | @brief Print unsigned byte-size numeric value w/newline to 7-segment 345 | display. 346 | @param b Numeric value. 347 | @param base Number base (default = RAW_BITS = raw bits) 348 | */ 349 | void println(unsigned char b, int base = RAW_BITS); 350 | 351 | /*! 352 | @brief Print integer value with newline to 7-segment display. 353 | @param n Numeric value. 354 | @param base Number base (default = DEC = base 10) 355 | */ 356 | void println(int n, int base = DEC); 357 | 358 | /*! 359 | @brief Print unsigned integer value with newline to 7-segment display. 360 | @param n Numeric value. 361 | @param base Number base (default = DEC = base 10) 362 | */ 363 | void println(unsigned int n, int base = DEC); 364 | 365 | /*! 366 | @brief Print long integer value with newline to 7-segment display. 367 | @param n Numeric value. 368 | @param base Number base (default = DEC = base 10) 369 | */ 370 | void println(long n, int base = DEC); 371 | 372 | /*! 373 | @brief Print unsigned long integer value w/newline to 7-segment display. 374 | @param n Numeric value. 375 | @param base Number base (default = DEC = base 10) 376 | */ 377 | void println(unsigned long n, int base = DEC); 378 | 379 | /*! 380 | @brief Print double-precision float value to 7-segment display. 381 | @param n Numeric value. 382 | @param digits Fractional-part digits. 383 | */ 384 | void println(double n, int digits = 2); 385 | 386 | /*! 387 | @brief Print from a String object w/newline to 7-segment display. 388 | @param c String object, passed by reference. 389 | */ 390 | void println(const String &c); 391 | 392 | /*! 393 | @brief Print from a C-style string array w/newline to 7-segment display. 394 | @param c Array of characters. 395 | */ 396 | void println(const char c[]); 397 | 398 | /*! 399 | @brief Print newline to 7-segment display (rewind position to start). 400 | */ 401 | void println(void); 402 | 403 | /*! 404 | @brief Write raw segment bits into display buffer. 405 | @param x Character position (0-3). 406 | @param bitmask Segment bits. 407 | */ 408 | void writeDigitRaw(uint8_t x, uint8_t bitmask); 409 | 410 | /*! 411 | @brief Set specific digit # to a numeric value. 412 | @param x Character position. 413 | @param num Numeric (not ASCII) value. 414 | @param dot If true, light corresponding decimal. 415 | */ 416 | void writeDigitNum(uint8_t x, uint8_t num, bool dot = false); 417 | 418 | /*! 419 | @brief Set specific digit # to a character value. 420 | @param x Character position. 421 | @param c Character (ASCII). 422 | @param dot If true, light corresponding decimal. 423 | */ 424 | void writeDigitAscii(uint8_t x, uint8_t c, bool dot = false); 425 | 426 | /*! 427 | @brief Set or unset colon segment. 428 | @param state 'true' to enable colon, 'false' for off. 429 | */ 430 | void drawColon(bool state); 431 | 432 | /*! 433 | @brief General integer-printing function used by some of the print() 434 | variants. 435 | @param n Numeric value. 436 | @param base Base (2 = binary). 437 | */ 438 | void printNumber(long n, uint8_t base = 2); 439 | 440 | /*! 441 | @brief General float-printing function used by some of the print() 442 | variants. 443 | @param n Numeric value. 444 | @param fracDigits Fractional-part digits. 445 | @param base Base (default DEC = base 10). 446 | */ 447 | void printFloat(double n, uint8_t fracDigits = 2, uint8_t base = DEC); 448 | 449 | /*! 450 | @brief Light display segments in an error-indicating configuration. 451 | */ 452 | void printError(void); 453 | 454 | /*! 455 | @brief Issue colon-on directly to display (bypass buffer). 456 | */ 457 | void writeColon(void); 458 | 459 | private: 460 | uint8_t position; ///< Current print position, 0-3 461 | }; 462 | 463 | /*! 464 | @brief Class for four-digit alphanumeric displays. 465 | */ 466 | class Adafruit_AlphaNum4 : public Adafruit_LEDBackpack { 467 | public: 468 | /*! 469 | @brief Constructor for four-digit alphanumeric displays. 470 | */ 471 | Adafruit_AlphaNum4(void); 472 | 473 | /*! 474 | @brief Write single character of alphanumeric display as raw bits 475 | (not a general print function). 476 | @param n Character index (0-3). 477 | @param bitmask Segment bitmask. 478 | */ 479 | void writeDigitRaw(uint8_t n, uint16_t bitmask); 480 | 481 | /*! 482 | @brief Write single ASCII character to alphanumeric display. 483 | @param n Character index (0-3). 484 | @param ascii ASCII character. 485 | @param dot If true, also light corresponding dot segment. 486 | */ 487 | void writeDigitAscii(uint8_t n, uint8_t ascii, bool dot = false); 488 | }; 489 | 490 | #endif // Adafruit_LEDBackpack_h 491 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adafruit-LED-Backpack-Library [![Build Status](https://github.com/adafruit/Adafruit_LED_Backpack/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_LED_Backpack/actions) 2 | 3 | 4 | ## Compatibility 5 | 6 | MCU | Tested Works | Doesn't Work | Not Tested | Notes 7 | ----------------- | :----------: | :----------: | :---------: | ----- 8 | Atmega328 @ 16MHz | X | | | 9 | Atmega328 @ 12MHz | X | | | 10 | Atmega32u4 @ 16MHz | X | | | 11 | Atmega32u4 @ 8MHz | X | | | 12 | ESP8266 | X | | | 13 | ESP32 | X | | | 14 | ESP32S2 | X | | | 15 | ESP32S3 | X | | | 16 | Atmega2560 @ 16MHz | X | | | 17 | ATSAM3X8E | X | | | Use SDA/SCL on pins 20 & 21 18 | ATSAM21D | X | | | 19 | ATtiny85 @ 16MHz | X | | | Use 0 for SDA, 2 for SCL, examples may need Serial references removed 20 | ATtiny85 @ 8MHz | X | | | Use 0 for SDA, 2 for SCL, examples may need Serial references removed 21 | 22 | * ATmega328 @ 16MHz : Arduino UNO, Adafruit Pro Trinket 5V, Adafruit Metro 328, Adafruit Metro Mini 23 | * ATmega328 @ 12MHz : Adafruit Pro Trinket 3V 24 | * ATmega32u4 @ 16MHz : Arduino Leonardo, Arduino Micro, Arduino Yun, Teensy 2.0 25 | * ATmega32u4 @ 8MHz : Adafruit Flora, Bluefruit Micro 26 | * ESP8266 : Adafruit Huzzah 27 | * ESP32 : Unexpected Maker tinyPICO 28 | * ESP32S2 : Unexpected Maker tinyS2 29 | * ESP32S3 : Unexpected Maker tinyS3 30 | * ATmega2560 @ 16MHz : Arduino Mega 31 | * ATSAM3X8E : Arduino Due 32 | * ATSAM21D : Arduino Zero, M0 Pro 33 | * ATtiny85 @ 16MHz : Adafruit Trinket 5V 34 | * ATtiny85 @ 8MHz : Adafruit Gemma, Arduino Gemma, Adafruit Trinket 3V 35 | 36 | 37 | -------------------------------------------------------------------------------- /examples/HT16K33/HT16K33.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for our I2C LED Backpacks 3 | 4 | Designed specifically to work with the Adafruit LED Matrix backpacks 5 | ----> http://www.adafruit.com/products/872 6 | ----> http://www.adafruit.com/products/871 7 | ----> http://www.adafruit.com/products/870 8 | 9 | These displays use I2C to communicate, 2 pins are required to 10 | interface. There are multiple selectable I2C addresses. For backpacks 11 | with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks 12 | with 3 Address Select pins: 0x70 thru 0x77 13 | 14 | Adafruit invests time and resources providing this open source code, 15 | please support Adafruit and open-source hardware by purchasing 16 | products from Adafruit! 17 | 18 | Written by Limor Fried/Ladyada for Adafruit Industries. 19 | BSD license, all text above must be included in any redistribution 20 | ****************************************************/ 21 | 22 | #include 23 | #include 24 | #include "Adafruit_LEDBackpack.h" 25 | 26 | #ifndef _BV 27 | #define _BV(bit) (1<<(bit)) 28 | #endif 29 | 30 | 31 | Adafruit_LEDBackpack matrix = Adafruit_LEDBackpack(); 32 | 33 | uint8_t counter = 0; 34 | 35 | void setup() { 36 | Serial.begin(9600); 37 | Serial.println("HT16K33 test"); 38 | 39 | matrix.begin(0x70); // pass in the address 40 | } 41 | 42 | void loop() { 43 | // paint one LED per row. The HT16K33 internal memory looks like 44 | // a 8x16 bit matrix (8 rows, 16 columns) 45 | for (uint8_t i=0; i<8; i++) { 46 | // draw a diagonal row of pixels 47 | matrix.displaybuffer[i] = _BV((counter+i) % 16) | _BV((counter+i+8) % 16) ; 48 | } 49 | // write the changes we just made to the display 50 | matrix.writeDisplay(); 51 | delay(100); 52 | 53 | counter++; 54 | if (counter >= 16) counter = 0; 55 | } 56 | -------------------------------------------------------------------------------- /examples/bargraph24/bargraph24.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for our I2C LED Backpacks 3 | 4 | Designed specifically to work with the Adafruit LED 24 Bargraph Backpack 5 | ----> http://www.adafruit.com/products/721 6 | 7 | These displays use I2C to communicate, 2 pins are required to 8 | interface. There are multiple selectable I2C addresses. For backpacks 9 | with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks 10 | with 3 Address Select pins: 0x70 thru 0x77 11 | 12 | Adafruit invests time and resources providing this open source code, 13 | please support Adafruit and open-source hardware by purchasing 14 | products from Adafruit! 15 | 16 | Written by Limor Fried/Ladyada for Adafruit Industries. 17 | BSD license, all text above must be included in any redistribution 18 | ****************************************************/ 19 | 20 | #include 21 | #include 22 | #include "Adafruit_LEDBackpack.h" 23 | 24 | Adafruit_24bargraph bar = Adafruit_24bargraph(); 25 | 26 | void setup() { 27 | Serial.begin(9600); 28 | Serial.println("HT16K33 Bi-Color Bargraph test"); 29 | 30 | bar.begin(0x70); // pass in the address 31 | 32 | for (uint8_t b=0; b<24; b++ ){ 33 | if ((b % 3) == 0) bar.setBar(b, LED_RED); 34 | if ((b % 3) == 1) bar.setBar(b, LED_YELLOW); 35 | if ((b % 3) == 2) bar.setBar(b, LED_GREEN); 36 | } 37 | bar.writeDisplay(); 38 | delay(2000); 39 | } 40 | 41 | 42 | void loop() { 43 | for (uint8_t b=0; b<24; b++) { 44 | bar.setBar(b, LED_RED); 45 | bar.writeDisplay(); 46 | delay(50); 47 | bar.setBar(b, LED_OFF); 48 | bar.writeDisplay(); 49 | } 50 | for (uint8_t b=0; b<24; b++) { 51 | bar.setBar(b, LED_GREEN); 52 | bar.writeDisplay(); 53 | delay(50); 54 | bar.setBar(b, LED_OFF); 55 | bar.writeDisplay(); 56 | } 57 | 58 | for (uint8_t b=0; b<24; b++) { 59 | bar.setBar(23-b, LED_YELLOW); 60 | bar.writeDisplay(); 61 | delay(50); 62 | bar.setBar(23-b, LED_OFF); 63 | bar.writeDisplay(); 64 | } 65 | } -------------------------------------------------------------------------------- /examples/bicolor8x8/bicolor8x8.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for our I2C LED Backpacks 3 | 4 | Designed specifically to work with the Adafruit LED Matrix backpacks 5 | ----> http://www.adafruit.com/products/872 6 | ----> http://www.adafruit.com/products/871 7 | ----> http://www.adafruit.com/products/870 8 | 9 | These displays use I2C to communicate, 2 pins are required to 10 | interface. There are multiple selectable I2C addresses. For backpacks 11 | with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks 12 | with 3 Address Select pins: 0x70 thru 0x77 13 | 14 | Adafruit invests time and resources providing this open source code, 15 | please support Adafruit and open-source hardware by purchasing 16 | products from Adafruit! 17 | 18 | Written by Limor Fried/Ladyada for Adafruit Industries. 19 | BSD license, all text above must be included in any redistribution 20 | ****************************************************/ 21 | 22 | #include 23 | #include 24 | #include "Adafruit_LEDBackpack.h" 25 | 26 | Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix(); 27 | 28 | void setup() { 29 | Serial.begin(9600); 30 | Serial.println("8x8 LED Matrix Test"); 31 | 32 | matrix.begin(0x70); // pass in the address 33 | } 34 | 35 | static const uint8_t PROGMEM 36 | smile_bmp[] = 37 | { B00111100, 38 | B01000010, 39 | B10100101, 40 | B10000001, 41 | B10100101, 42 | B10011001, 43 | B01000010, 44 | B00111100 }, 45 | neutral_bmp[] = 46 | { B00111100, 47 | B01000010, 48 | B10100101, 49 | B10000001, 50 | B10111101, 51 | B10000001, 52 | B01000010, 53 | B00111100 }, 54 | frown_bmp[] = 55 | { B00111100, 56 | B01000010, 57 | B10100101, 58 | B10000001, 59 | B10011001, 60 | B10100101, 61 | B01000010, 62 | B00111100 }; 63 | 64 | void loop() { 65 | 66 | matrix.clear(); 67 | matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_GREEN); 68 | matrix.writeDisplay(); 69 | delay(500); 70 | 71 | matrix.clear(); 72 | matrix.drawBitmap(0, 0, neutral_bmp, 8, 8, LED_YELLOW); 73 | matrix.writeDisplay(); 74 | delay(500); 75 | 76 | matrix.clear(); 77 | matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_RED); 78 | matrix.writeDisplay(); 79 | delay(500); 80 | 81 | matrix.clear(); // clear display 82 | matrix.drawPixel(0, 0, LED_GREEN); 83 | matrix.writeDisplay(); // write the changes we just made to the display 84 | delay(500); 85 | 86 | matrix.clear(); 87 | matrix.drawLine(0,0, 7,7, LED_YELLOW); 88 | matrix.writeDisplay(); // write the changes we just made to the display 89 | delay(500); 90 | 91 | matrix.clear(); 92 | matrix.drawRect(0,0, 8,8, LED_RED); 93 | matrix.fillRect(2,2, 4,4, LED_GREEN); 94 | matrix.writeDisplay(); // write the changes we just made to the display 95 | delay(500); 96 | 97 | matrix.clear(); 98 | matrix.drawCircle(3,3, 3, LED_YELLOW); 99 | matrix.writeDisplay(); // write the changes we just made to the display 100 | delay(500); 101 | 102 | matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely 103 | matrix.setTextSize(1); 104 | matrix.setTextColor(LED_GREEN); 105 | for (int8_t x=7; x>=-36; x--) { 106 | matrix.clear(); 107 | matrix.setCursor(x,0); 108 | matrix.print("Hello"); 109 | matrix.writeDisplay(); 110 | delay(100); 111 | } 112 | matrix.setRotation(3); 113 | matrix.setTextColor(LED_RED); 114 | for (int8_t x=7; x>=-36; x--) { 115 | matrix.clear(); 116 | matrix.setCursor(x,0); 117 | matrix.print("World"); 118 | matrix.writeDisplay(); 119 | delay(100); 120 | } 121 | matrix.setRotation(0); 122 | } 123 | -------------------------------------------------------------------------------- /examples/clock_sevenseg_ds1307/clock_sevenseg_ds1307.ino: -------------------------------------------------------------------------------- 1 | // Clock example using a seven segment display & DS1307 real-time clock. 2 | // 3 | // Must have the Adafruit RTClib library installed too! See: 4 | // https://github.com/adafruit/RTClib 5 | // 6 | // Designed specifically to work with the Adafruit LED 7-Segment backpacks 7 | // and DS1307 real-time clock breakout: 8 | // ----> http://www.adafruit.com/products/881 9 | // ----> http://www.adafruit.com/products/880 10 | // ----> http://www.adafruit.com/products/879 11 | // ----> http://www.adafruit.com/products/878 12 | // ----> https://www.adafruit.com/products/264 13 | // 14 | // Adafruit invests time and resources providing this open source code, 15 | // please support Adafruit and open-source hardware by purchasing 16 | // products from Adafruit! 17 | // 18 | // Written by Tony DiCola for Adafruit Industries. 19 | // Released under a MIT license: https://opensource.org/licenses/MIT 20 | 21 | #include 22 | #include 23 | #include 24 | #include "Adafruit_LEDBackpack.h" 25 | 26 | 27 | // Set to false to display time in 12 hour format, or true to use 24 hour: 28 | #define TIME_24_HOUR false 29 | 30 | // I2C address of the display. Stick with the default address of 0x70 31 | // unless you've changed the address jumpers on the back of the display. 32 | #define DISPLAY_ADDRESS 0x70 33 | 34 | 35 | // Create display and DS1307 objects. These are global variables that 36 | // can be accessed from both the setup and loop function below. 37 | Adafruit_7segment clockDisplay = Adafruit_7segment(); 38 | RTC_DS1307 rtc = RTC_DS1307(); 39 | 40 | // Keep track of the hours, minutes, seconds displayed by the clock. 41 | // Start off at 0:00:00 as a signal that the time should be read from 42 | // the DS1307 to initialize it. 43 | int hours = 0; 44 | int minutes = 0; 45 | int seconds = 0; 46 | 47 | // Remember if the colon was drawn on the display so it can be blinked 48 | // on and off every second. 49 | bool blinkColon = false; 50 | 51 | 52 | void setup() { 53 | // Setup function runs once at startup to initialize the display 54 | // and DS1307 clock. 55 | 56 | // Setup Serial port to print debug output. 57 | Serial.begin(115200); 58 | Serial.println("Clock starting!"); 59 | 60 | // Setup the display. 61 | clockDisplay.begin(DISPLAY_ADDRESS); 62 | 63 | // Setup the DS1307 real-time clock. 64 | rtc.begin(); 65 | 66 | // Set the DS1307 clock if it hasn't been set before. 67 | bool setClockTime = !rtc.isrunning(); 68 | // Alternatively you can force the clock to be set again by 69 | // uncommenting this line: 70 | //setClockTime = true; 71 | if (setClockTime) { 72 | Serial.println("Setting DS1307 time!"); 73 | // This line sets the DS1307 time to the exact date and time the 74 | // sketch was compiled: 75 | rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); 76 | // Alternatively you can set the RTC with an explicit date & time, 77 | // for example to set January 21, 2014 at 3am you would uncomment: 78 | //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); 79 | } 80 | } 81 | 82 | void loop() { 83 | // Loop function runs over and over again to implement the clock logic. 84 | 85 | // Check if it's the top of the hour and get a new time reading 86 | // from the DS1307. This helps keep the clock accurate by fixing 87 | // any drift. 88 | if (minutes == 0) { 89 | // Get the time from the DS1307. 90 | DateTime now = rtc.now(); 91 | // Print out the time for debug purposes: 92 | Serial.print("Read date & time from DS1307: "); 93 | Serial.print(now.year(), DEC); 94 | Serial.print('/'); 95 | Serial.print(now.month(), DEC); 96 | Serial.print('/'); 97 | Serial.print(now.day(), DEC); 98 | Serial.print(' '); 99 | Serial.print(now.hour(), DEC); 100 | Serial.print(':'); 101 | Serial.print(now.minute(), DEC); 102 | Serial.print(':'); 103 | Serial.print(now.second(), DEC); 104 | Serial.println(); 105 | // Now set the hours and minutes. 106 | hours = now.hour(); 107 | minutes = now.minute(); 108 | } 109 | 110 | // Show the time on the display by turning it into a numeric 111 | // value, like 3:30 turns into 330, by multiplying the hour by 112 | // 100 and then adding the minutes. 113 | int displayValue = hours*100 + minutes; 114 | 115 | // Do 24 hour to 12 hour format conversion when required. 116 | if (!TIME_24_HOUR) { 117 | // Handle when hours are past 12 by subtracting 12 hours (1200 value). 118 | if (hours > 12) { 119 | displayValue -= 1200; 120 | } 121 | // Handle hour 0 (midnight) being shown as 12. 122 | else if (hours == 0) { 123 | displayValue += 1200; 124 | } 125 | } 126 | 127 | // Now print the time value to the display. 128 | clockDisplay.print(displayValue, DEC); 129 | 130 | // Add zero padding when in 24 hour mode and it's midnight. 131 | // In this case the print function above won't have leading 0's 132 | // which can look confusing. Go in and explicitly add these zeros. 133 | if (TIME_24_HOUR && hours == 0) { 134 | // Pad hour 0. 135 | clockDisplay.writeDigitNum(1, 0); 136 | // Also pad when the 10's minute is 0 and should be padded. 137 | if (minutes < 10) { 138 | clockDisplay.writeDigitNum(3, 0); 139 | } 140 | } 141 | 142 | // Blink the colon by flipping its value every loop iteration 143 | // (which happens every second). 144 | blinkColon = !blinkColon; 145 | clockDisplay.drawColon(blinkColon); 146 | 147 | // Now push out to the display the new values that were set above. 148 | clockDisplay.writeDisplay(); 149 | 150 | // Pause for a second for time to elapse. This value is in milliseconds 151 | // so 1000 milliseconds = 1 second. 152 | delay(1000); 153 | 154 | // Now increase the seconds by one. 155 | seconds += 1; 156 | // If the seconds go above 59 then the minutes should increase and 157 | // the seconds should wrap back to 0. 158 | if (seconds > 59) { 159 | seconds = 0; 160 | minutes += 1; 161 | // Again if the minutes go above 59 then the hour should increase and 162 | // the minutes should wrap back to 0. 163 | if (minutes > 59) { 164 | minutes = 0; 165 | hours += 1; 166 | // Note that when the minutes are 0 (i.e. it's the top of a new hour) 167 | // then the start of the loop will read the actual time from the DS1307 168 | // again. Just to be safe though we'll also increment the hour and wrap 169 | // back to 0 if it goes above 23 (i.e. past midnight). 170 | if (hours > 23) { 171 | hours = 0; 172 | } 173 | } 174 | } 175 | 176 | // Loop code is finished, it will jump back to the start of the loop 177 | // function again! 178 | } 179 | -------------------------------------------------------------------------------- /examples/clock_sevenseg_gps/clock_sevenseg_gps.ino: -------------------------------------------------------------------------------- 1 | // Clock example using a seven segment display & GPS for time. 2 | // 3 | // Must have the Adafruit GPS library installed too! See: 4 | // https://github.com/adafruit/Adafruit-GPS-Library 5 | // 6 | // Designed specifically to work with the Adafruit LED 7-Segment backpacks 7 | // and ultimate GPS breakout/shield: 8 | // ----> http://www.adafruit.com/products/881 9 | // ----> http://www.adafruit.com/products/880 10 | // ----> http://www.adafruit.com/products/879 11 | // ----> http://www.adafruit.com/products/878 12 | // ----> http://www.adafruit.com/products/746 13 | // 14 | // Adafruit invests time and resources providing this open source code, 15 | // please support Adafruit and open-source hardware by purchasing 16 | // products from Adafruit! 17 | // 18 | // Written by Tony DiCola for Adafruit Industries. 19 | // Released under a MIT license: https://opensource.org/licenses/MIT 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "Adafruit_LEDBackpack.h" 26 | 27 | 28 | // Set to false to display time in 12 hour format, or true to use 24 hour: 29 | #define TIME_24_HOUR false 30 | 31 | // Offset the hours from UTC (universal time) to your local time by changing 32 | // this value. The GPS time will be in UTC so lookup the offset for your 33 | // local time from a site like: 34 | // https://en.wikipedia.org/wiki/List_of_UTC_time_offsets 35 | // This value, -7, will set the time to UTC-7 or Pacific Standard Time during 36 | // daylight savings time. 37 | #define HOUR_OFFSET -7 38 | 39 | // I2C address of the display. Stick with the default address of 0x70 40 | // unless you've changed the address jumpers on the back of the display. 41 | #define DISPLAY_ADDRESS 0x70 42 | 43 | 44 | // Create display and GPS objects. These are global variables that 45 | // can be accessed from both the setup and loop function below. 46 | Adafruit_7segment clockDisplay = Adafruit_7segment(); 47 | SoftwareSerial gpsSerial(8, 7); // GPS breakout/shield will use a 48 | // software serial connection with 49 | // TX = pin 8 and RX = pin 7. 50 | Adafruit_GPS gps(&gpsSerial); 51 | 52 | 53 | void setup() { 54 | // Setup function runs once at startup to initialize the display and GPS. 55 | 56 | // Setup Serial port to print debug output. 57 | Serial.begin(115200); 58 | Serial.println("Clock starting!"); 59 | 60 | // Setup the display. 61 | clockDisplay.begin(DISPLAY_ADDRESS); 62 | 63 | // Setup the GPS using a 9600 baud connection (the default for most 64 | // GPS modules). 65 | gps.begin(9600); 66 | 67 | // Configure GPS to onlu output minimum data (location, time, fix). 68 | gps.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY); 69 | 70 | // Use a 1 hz, once a second, update rate. 71 | gps.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); 72 | 73 | // Enable the interrupt to parse GPS data. 74 | enableGPSInterrupt(); 75 | } 76 | 77 | void loop() { 78 | // Loop function runs over and over again to implement the clock logic. 79 | 80 | // Check if GPS has new data and parse it. 81 | if (gps.newNMEAreceived()) { 82 | gps.parse(gps.lastNMEA()); 83 | } 84 | 85 | // Grab the current hours, minutes, seconds from the GPS. 86 | // This will only be set once the GPS has a fix! Make sure to add 87 | // a coin cell battery so the GPS will save the time between power-up/down. 88 | int hours = gps.hour + HOUR_OFFSET; // Add hour offset to convert from UTC 89 | // to local time. 90 | // Handle when UTC + offset wraps around to a negative or > 23 value. 91 | if (hours < 0) { 92 | hours = 24+hours; 93 | } 94 | if (hours > 23) { 95 | hours = 24-hours; 96 | } 97 | int minutes = gps.minute; 98 | int seconds = gps.seconds; 99 | 100 | // Show the time on the display by turning it into a numeric 101 | // value, like 3:30 turns into 330, by multiplying the hour by 102 | // 100 and then adding the minutes. 103 | int displayValue = hours*100 + minutes; 104 | 105 | // Do 24 hour to 12 hour format conversion when required. 106 | if (!TIME_24_HOUR) { 107 | // Handle when hours are past 12 by subtracting 12 hours (1200 value). 108 | if (hours > 12) { 109 | displayValue -= 1200; 110 | } 111 | // Handle hour 0 (midnight) being shown as 12. 112 | else if (hours == 0) { 113 | displayValue += 1200; 114 | } 115 | } 116 | 117 | // Now print the time value to the display. 118 | clockDisplay.print(displayValue, DEC); 119 | 120 | // Add zero padding when in 24 hour mode and it's midnight. 121 | // In this case the print function above won't have leading 0's 122 | // which can look confusing. Go in and explicitly add these zeros. 123 | if (TIME_24_HOUR && hours == 0) { 124 | // Pad hour 0. 125 | clockDisplay.writeDigitNum(1, 0); 126 | // Also pad when the 10's minute is 0 and should be padded. 127 | if (minutes < 10) { 128 | clockDisplay.writeDigitNum(2, 0); 129 | } 130 | } 131 | 132 | // Blink the colon by turning it on every even second and off 133 | // every odd second. The modulus operator is very handy here to 134 | // check if a value is even (modulus 2 equals 0) or odd (modulus 2 135 | // equals 1). 136 | clockDisplay.drawColon(seconds % 2 == 0); 137 | 138 | // Now push out to the display the new values that were set above. 139 | clockDisplay.writeDisplay(); 140 | 141 | // Loop code is finished, it will jump back to the start of the loop 142 | // function again! Don't add any delays because the parsing needs to 143 | // happen all the time! 144 | } 145 | 146 | SIGNAL(TIMER0_COMPA_vect) { 147 | // Use a timer interrupt once a millisecond to check for new GPS data. 148 | // This piggybacks on Arduino's internal clock timer for the millis() 149 | // function. 150 | gps.read(); 151 | } 152 | 153 | void enableGPSInterrupt() { 154 | // Function to enable the timer interrupt that will parse GPS data. 155 | // Timer0 is already used for millis() - we'll just interrupt somewhere 156 | // in the middle and call the "Compare A" function above 157 | OCR0A = 0xAF; 158 | TIMSK0 |= _BV(OCIE0A); 159 | } 160 | -------------------------------------------------------------------------------- /examples/custom_character/README.md: -------------------------------------------------------------------------------- 1 | # Arduino-Custom-Character 2 | This repository holds arduino and processing code for printing Custom Characters on Adafruit HT16k33 8x8 Bicolor Led Matrix from software. 3 | 4 | 5 | Full explaination of this project is available on [Instructables](https://www.instructables.com/id/Custom-Character-Generator-Adafruit-HT16k33-Matrix/). 6 | -------------------------------------------------------------------------------- /examples/custom_character/custom_character_generator/custom_character_generator.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Adafruit_LEDBackpack.h" 4 | 5 | Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix(); 6 | 7 | 8 | String data=""; 9 | uint8_t emoji[]={0,0,0,0,0,0,0,0}; 10 | void setup() { 11 | // put your setup code here, to run once: 12 | Serial.begin(9600); 13 | matrix.begin(0x70); // pass in the address 14 | print_emoji(emoji,"green"); 15 | } 16 | 17 | void loop() { 18 | 19 | if (Serial.available()>0) 20 | { 21 | data=Serial.readStringUntil('\n'); 22 | Serial.println(data); 23 | 24 | } 25 | 26 | if (data!="") 27 | { 28 | 29 | emoji[0]=(val(data.substring(1,9))); 30 | //Serial.println(val(data.substring(1,9))); 31 | emoji[1]=(val(data.substring(11,19))); 32 | //Serial.println(val(data.substring(11,19))); 33 | emoji[2]=(val(data.substring(21,29))); 34 | //Serial.println(val(data.substring(21,29))); 35 | emoji[3]=(val(data.substring(31,39))); 36 | //Serial.println(val(data.substring(31,39))); 37 | emoji[4]=(val(data.substring(41,49))); 38 | //Serial.println(val(data.substring(41,49))); 39 | emoji[5]=(val(data.substring(51,59))); 40 | //Serial.println(val(data.substring(51,59))); 41 | emoji[6]=(val(data.substring(61,69))); 42 | //Serial.println(val(data.substring(61,69))); 43 | emoji[7]=(val(data.substring(71,79))); 44 | //Serial.println(val(data.substring(71,79))); 45 | data=""; 46 | print_emoji(emoji,"green"); 47 | } 48 | } 49 | 50 | int val(String str) 51 | { 52 | int v=0; 53 | for (int i=0;i<8;i++) 54 | { 55 | if (str[i]=='1') 56 | { 57 | v=v+power(2,(7-i)); 58 | } 59 | } 60 | return v; 61 | } 62 | 63 | int power(int base,int exponent) 64 | { 65 | int c=1; 66 | for (int i=0;i= x && mouseX <= x + width) 105 | { 106 | if(mouseY >= y && mouseY <= y + (height)) 107 | { 108 | if(framesPassed == delay) 109 | { 110 | framesPassed = 0; 111 | return true; 112 | } 113 | } 114 | } 115 | 116 | return false; 117 | } 118 | } 119 | 120 | //////////////////////////////////////////////////////////////////INITIALIZATION AND BUTTON PROCEDURES////////////////////////////////////////////////////// 121 | 122 | void init() 123 | { 124 | button1=new Button(50,50,20,20," ",5,255); 125 | button2=new Button(70,50,20,20," ",5,255); 126 | button3=new Button(90,50,20,20," ",5,255); 127 | button4=new Button(110,50,20,20," ",5,255); 128 | button5=new Button(130,50,20,20," ",5,255); 129 | button6=new Button(150,50,20,20," ",5,255); 130 | button7=new Button(170,50,20,20," ",5,255); 131 | button8=new Button(190,50,20,20," ",5,255); 132 | 133 | button9=new Button(50,70,20,20," ",5,255); 134 | button10=new Button(70,70,20,20," ",5,255); 135 | button11=new Button(90,70,20,20," ",5,255); 136 | button12=new Button(110,70,20,20," ",5,255); 137 | button13=new Button(130,70,20,20," ",5,255); 138 | button14=new Button(150,70,20,20," ",5,255); 139 | button15=new Button(170,70,20,20," ",5,255); 140 | button16=new Button(190,70,20,20," ",5,255); 141 | 142 | button17=new Button(50,90,20,20," ",5,255); 143 | button18=new Button(70,90,20,20," ",5,255); 144 | button19=new Button(90,90,20,20," ",5,255); 145 | button20=new Button(110,90,20,20," ",5,255); 146 | button21=new Button(130,90,20,20," ",5,255); 147 | button22=new Button(150,90,20,20," ",5,255); 148 | button23=new Button(170,90,20,20," ",5,255); 149 | button24=new Button(190,90,20,20," ",5,255); 150 | 151 | button25=new Button(50,110,20,20," ",5,255); 152 | button26=new Button(70,110,20,20," ",5,255); 153 | button27=new Button(90,110,20,20," ",5,255); 154 | button28=new Button(110,110,20,20," ",5,255); 155 | button29=new Button(130,110,20,20," ",5,255); 156 | button30=new Button(150,110,20,20," ",5,255); 157 | button31=new Button(170,110,20,20," ",5,255); 158 | button32=new Button(190,110,20,20," ",5,255); 159 | 160 | button33=new Button(50,130,20,20," ",5,255); 161 | button34=new Button(70,130,20,20," ",5,255); 162 | button35=new Button(90,130,20,20," ",5,255); 163 | button36=new Button(110,130,20,20," ",5,255); 164 | button37=new Button(130,130,20,20," ",5,255); 165 | button38=new Button(150,130,20,20," ",5,255); 166 | button39=new Button(170,130,20,20," ",5,255); 167 | button40=new Button(190,130,20,20," ",5,255); 168 | 169 | button41=new Button(50,150,20,20," ",5,255); 170 | button42=new Button(70,150,20,20," ",5,255); 171 | button43=new Button(90,150,20,20," ",5,255); 172 | button44=new Button(110,150,20,20," ",5,255); 173 | button45=new Button(130,150,20,20," ",5,255); 174 | button46=new Button(150,150,20,20," ",5,255); 175 | button47=new Button(170,150,20,20," ",5,255); 176 | button48=new Button(190,150,20,20," ",5,255); 177 | 178 | button49=new Button(50,170,20,20," ",5,255); 179 | button50=new Button(70,170,20,20," ",5,255); 180 | button51=new Button(90,170,20,20," ",5,255); 181 | button52=new Button(110,170,20,20," ",5,255); 182 | button53=new Button(130,170,20,20," ",5,255); 183 | button54=new Button(150,170,20,20," ",5,255); 184 | button55=new Button(170,170,20,20," ",5,255); 185 | button56=new Button(190,170,20,20," ",5,255); 186 | 187 | button57=new Button(50,190,20,20," ",5,255); 188 | button58=new Button(70,190,20,20," ",5,255); 189 | button59=new Button(90,190,20,20," ",5,255); 190 | button60=new Button(110,190,20,20," ",5,255); 191 | button61=new Button(130,190,20,20," ",5,255); 192 | button62=new Button(150,190,20,20," ",5,255); 193 | button63=new Button(170,190,20,20," ",5,255); 194 | button64=new Button(190,190,20,20," ",5,255); 195 | } 196 | 197 | void initdraw() 198 | { 199 | button1.Draw(); 200 | button2.Draw(); 201 | button3.Draw(); 202 | button4.Draw(); 203 | button5.Draw(); 204 | button6.Draw(); 205 | button7.Draw(); 206 | button8.Draw(); 207 | button9.Draw(); 208 | button10.Draw(); 209 | button11.Draw(); 210 | button12.Draw(); 211 | button13.Draw(); 212 | button14.Draw(); 213 | button15.Draw(); 214 | button16.Draw(); 215 | button17.Draw(); 216 | button18.Draw(); 217 | button19.Draw(); 218 | button20.Draw(); 219 | button21.Draw(); 220 | button22.Draw(); 221 | button23.Draw(); 222 | button24.Draw(); 223 | button25.Draw(); 224 | button26.Draw(); 225 | button27.Draw(); 226 | button28.Draw(); 227 | button29.Draw(); 228 | button30.Draw(); 229 | button31.Draw(); 230 | button32.Draw(); 231 | button33.Draw(); 232 | button34.Draw(); 233 | button35.Draw(); 234 | button36.Draw(); 235 | button37.Draw(); 236 | button38.Draw(); 237 | button39.Draw(); 238 | button40.Draw(); 239 | button41.Draw(); 240 | button42.Draw(); 241 | button43.Draw(); 242 | button44.Draw(); 243 | button45.Draw(); 244 | button46.Draw(); 245 | button47.Draw(); 246 | button48.Draw(); 247 | button49.Draw(); 248 | button50.Draw(); 249 | button51.Draw(); 250 | button52.Draw(); 251 | button53.Draw(); 252 | button54.Draw(); 253 | button55.Draw(); 254 | button56.Draw(); 255 | button57.Draw(); 256 | button58.Draw(); 257 | button59.Draw(); 258 | button60.Draw(); 259 | button61.Draw(); 260 | button62.Draw(); 261 | button63.Draw(); 262 | button64.Draw(); 263 | } 264 | 265 | void mousePressed() 266 | { 267 | if (button.IsPressed()) 268 | { 269 | subtext=make(); 270 | //print(subtext); 271 | myPort.write(subtext); 272 | } 273 | 274 | if(button1.IsPressed()){if(button1.getbuttoncolor()==255){button1.fillcolor=0;val1=1;}else{button1.fillcolor=255;val1=0;}} 275 | if(button2.IsPressed()){if(button2.getbuttoncolor()==255){button2.fillcolor=0;val2=1;}else{button2.fillcolor=255;val2=0;}} 276 | if(button3.IsPressed()){if(button3.getbuttoncolor()==255){button3.fillcolor=0;val3=1;}else{button3.fillcolor=255;val3=0;}} 277 | if(button4.IsPressed()){if(button4.getbuttoncolor()==255){button4.fillcolor=0;val4=1;}else{button4.fillcolor=255;val4=0;}} 278 | if(button5.IsPressed()){if(button5.getbuttoncolor()==255){button5.fillcolor=0;val5=1;}else{button5.fillcolor=255;val5=0;}} 279 | if(button6.IsPressed()){if(button6.getbuttoncolor()==255){button6.fillcolor=0;val6=1;}else{button6.fillcolor=255;val6=0;}} 280 | if(button7.IsPressed()){if(button7.getbuttoncolor()==255){button7.fillcolor=0;val7=1;}else{button7.fillcolor=255;val7=0;}} 281 | if(button8.IsPressed()){if(button8.getbuttoncolor()==255){button8.fillcolor=0;val8=1;}else{button8.fillcolor=255;val8=0;}} 282 | if(button9.IsPressed()){if(button9.getbuttoncolor()==255){button9.fillcolor=0;val9=1;}else{button9.fillcolor=255;val9=0;}} 283 | if(button10.IsPressed()){if(button10.getbuttoncolor()==255){button10.fillcolor=0;val10=1;}else{button10.fillcolor=255;val10=0;}} 284 | if(button11.IsPressed()){if(button11.getbuttoncolor()==255){button11.fillcolor=0;val11=1;}else{button11.fillcolor=255;val11=0;}} 285 | if(button12.IsPressed()){if(button12.getbuttoncolor()==255){button12.fillcolor=0;val12=1;}else{button12.fillcolor=255;val12=0;}} 286 | if(button13.IsPressed()){if(button13.getbuttoncolor()==255){button13.fillcolor=0;val13=1;}else{button13.fillcolor=255;val13=0;}} 287 | if(button14.IsPressed()){if(button14.getbuttoncolor()==255){button14.fillcolor=0;val14=1;}else{button14.fillcolor=255;val14=0;}} 288 | if(button15.IsPressed()){if(button15.getbuttoncolor()==255){button15.fillcolor=0;val15=1;}else{button15.fillcolor=255;val15=0;}} 289 | if(button16.IsPressed()){if(button16.getbuttoncolor()==255){button16.fillcolor=0;val16=1;}else{button16.fillcolor=255;val16=0;}} 290 | if(button17.IsPressed()){if(button17.getbuttoncolor()==255){button17.fillcolor=0;val17=1;}else{button17.fillcolor=255;val17=0;}} 291 | if(button18.IsPressed()){if(button18.getbuttoncolor()==255){button18.fillcolor=0;val18=1;}else{button18.fillcolor=255;val18=0;}} 292 | if(button19.IsPressed()){if(button19.getbuttoncolor()==255){button19.fillcolor=0;val19=1;}else{button19.fillcolor=255;val19=0;}} 293 | if(button20.IsPressed()){if(button20.getbuttoncolor()==255){button20.fillcolor=0;val20=1;}else{button20.fillcolor=255;val20=0;}} 294 | if(button21.IsPressed()){if(button21.getbuttoncolor()==255){button21.fillcolor=0;val21=1;}else{button21.fillcolor=255;val21=0;}} 295 | if(button22.IsPressed()){if(button22.getbuttoncolor()==255){button22.fillcolor=0;val22=1;}else{button22.fillcolor=255;val22=0;}} 296 | if(button23.IsPressed()){if(button23.getbuttoncolor()==255){button23.fillcolor=0;val23=1;}else{button23.fillcolor=255;val23=0;}} 297 | if(button24.IsPressed()){if(button24.getbuttoncolor()==255){button24.fillcolor=0;val24=1;}else{button24.fillcolor=255;val24=0;}} 298 | if(button25.IsPressed()){if(button25.getbuttoncolor()==255){button25.fillcolor=0;val25=1;}else{button25.fillcolor=255;val25=0;}} 299 | if(button26.IsPressed()){if(button26.getbuttoncolor()==255){button26.fillcolor=0;val26=1;}else{button26.fillcolor=255;val26=0;}} 300 | if(button27.IsPressed()){if(button27.getbuttoncolor()==255){button27.fillcolor=0;val27=1;}else{button27.fillcolor=255;val27=0;}} 301 | if(button28.IsPressed()){if(button28.getbuttoncolor()==255){button28.fillcolor=0;val28=1;}else{button28.fillcolor=255;val28=0;}} 302 | if(button29.IsPressed()){if(button29.getbuttoncolor()==255){button29.fillcolor=0;val29=1;}else{button29.fillcolor=255;val29=0;}} 303 | if(button30.IsPressed()){if(button30.getbuttoncolor()==255){button30.fillcolor=0;val30=1;}else{button30.fillcolor=255;val30=0;}} 304 | if(button31.IsPressed()){if(button31.getbuttoncolor()==255){button31.fillcolor=0;val31=1;}else{button31.fillcolor=255;val31=0;}} 305 | if(button32.IsPressed()){if(button32.getbuttoncolor()==255){button32.fillcolor=0;val32=1;}else{button32.fillcolor=255;val32=0;}} 306 | if(button33.IsPressed()){if(button33.getbuttoncolor()==255){button33.fillcolor=0;val33=1;}else{button33.fillcolor=255;val33=0;}} 307 | if(button34.IsPressed()){if(button34.getbuttoncolor()==255){button34.fillcolor=0;val34=1;}else{button34.fillcolor=255;val34=0;}} 308 | if(button35.IsPressed()){if(button35.getbuttoncolor()==255){button35.fillcolor=0;val35=1;}else{button35.fillcolor=255;val35=0;}} 309 | if(button36.IsPressed()){if(button36.getbuttoncolor()==255){button36.fillcolor=0;val36=1;}else{button36.fillcolor=255;val36=0;}} 310 | if(button37.IsPressed()){if(button37.getbuttoncolor()==255){button37.fillcolor=0;val37=1;}else{button37.fillcolor=255;val37=0;}} 311 | if(button38.IsPressed()){if(button38.getbuttoncolor()==255){button38.fillcolor=0;val38=1;}else{button38.fillcolor=255;val38=0;}} 312 | if(button39.IsPressed()){if(button39.getbuttoncolor()==255){button39.fillcolor=0;val39=1;}else{button39.fillcolor=255;val39=0;}} 313 | if(button40.IsPressed()){if(button40.getbuttoncolor()==255){button40.fillcolor=0;val40=1;}else{button40.fillcolor=255;val40=0;}} 314 | if(button41.IsPressed()){if(button41.getbuttoncolor()==255){button41.fillcolor=0;val41=1;}else{button41.fillcolor=255;val41=0;}} 315 | if(button42.IsPressed()){if(button42.getbuttoncolor()==255){button42.fillcolor=0;val42=1;}else{button42.fillcolor=255;val42=0;}} 316 | if(button43.IsPressed()){if(button43.getbuttoncolor()==255){button43.fillcolor=0;val43=1;}else{button43.fillcolor=255;val43=0;}} 317 | if(button44.IsPressed()){if(button44.getbuttoncolor()==255){button44.fillcolor=0;val44=1;}else{button44.fillcolor=255;val44=0;}} 318 | if(button45.IsPressed()){if(button45.getbuttoncolor()==255){button45.fillcolor=0;val45=1;}else{button45.fillcolor=255;val45=0;}} 319 | if(button46.IsPressed()){if(button46.getbuttoncolor()==255){button46.fillcolor=0;val46=1;}else{button46.fillcolor=255;val46=0;}} 320 | if(button47.IsPressed()){if(button47.getbuttoncolor()==255){button47.fillcolor=0;val47=1;}else{button47.fillcolor=255;val47=0;}} 321 | if(button48.IsPressed()){if(button48.getbuttoncolor()==255){button48.fillcolor=0;val48=1;}else{button48.fillcolor=255;val48=0;}} 322 | if(button49.IsPressed()){if(button49.getbuttoncolor()==255){button49.fillcolor=0;val49=1;}else{button49.fillcolor=255;val49=0;}} 323 | if(button50.IsPressed()){if(button50.getbuttoncolor()==255){button50.fillcolor=0;val50=1;}else{button50.fillcolor=255;val50=0;}} 324 | if(button51.IsPressed()){if(button51.getbuttoncolor()==255){button51.fillcolor=0;val51=1;}else{button51.fillcolor=255;val51=0;}} 325 | if(button52.IsPressed()){if(button52.getbuttoncolor()==255){button52.fillcolor=0;val52=1;}else{button52.fillcolor=255;val52=0;}} 326 | if(button53.IsPressed()){if(button53.getbuttoncolor()==255){button53.fillcolor=0;val53=1;}else{button53.fillcolor=255;val53=0;}} 327 | if(button54.IsPressed()){if(button54.getbuttoncolor()==255){button54.fillcolor=0;val54=1;}else{button54.fillcolor=255;val54=0;}} 328 | if(button55.IsPressed()){if(button55.getbuttoncolor()==255){button55.fillcolor=0;val55=1;}else{button55.fillcolor=255;val55=0;}} 329 | if(button56.IsPressed()){if(button56.getbuttoncolor()==255){button56.fillcolor=0;val56=1;}else{button56.fillcolor=255;val56=0;}} 330 | if(button57.IsPressed()){if(button57.getbuttoncolor()==255){button57.fillcolor=0;val57=1;}else{button57.fillcolor=255;val57=0;}} 331 | if(button58.IsPressed()){if(button58.getbuttoncolor()==255){button58.fillcolor=0;val58=1;}else{button58.fillcolor=255;val58=0;}} 332 | if(button59.IsPressed()){if(button59.getbuttoncolor()==255){button59.fillcolor=0;val59=1;}else{button59.fillcolor=255;val59=0;}} 333 | if(button60.IsPressed()){if(button60.getbuttoncolor()==255){button60.fillcolor=0;val60=1;}else{button60.fillcolor=255;val60=0;}} 334 | if(button61.IsPressed()){if(button61.getbuttoncolor()==255){button61.fillcolor=0;val61=1;}else{button61.fillcolor=255;val61=0;}} 335 | if(button62.IsPressed()){if(button62.getbuttoncolor()==255){button62.fillcolor=0;val62=1;}else{button62.fillcolor=255;val62=0;}} 336 | if(button63.IsPressed()){if(button63.getbuttoncolor()==255){button63.fillcolor=0;val63=1;}else{button63.fillcolor=255;val63=0;}} 337 | if(button64.IsPressed()){if(button64.getbuttoncolor()==255){button64.fillcolor=0;val64=1;}else{button64.fillcolor=255;val64=0;}} 338 | } 339 | 340 | String make() 341 | { 342 | String s=""; 343 | s=s+"B"+str(val1)+str(val2)+str(val3)+str(val4)+str(val5)+str(val6)+str(val7)+str(val8)+","; 344 | s=s+"B"+str(val9)+str(val10)+str(val11)+str(val12)+str(val13)+str(val14)+str(val15)+str(val16)+","; 345 | s=s+"B"+str(val17)+str(val18)+str(val19)+str(val20)+str(val21)+str(val22)+str(val23)+str(val24)+","; 346 | s=s+"B"+str(val25)+str(val26)+str(val27)+str(val28)+str(val29)+str(val30)+str(val31)+str(val32)+","; 347 | s=s+"B"+str(val33)+str(val34)+str(val35)+str(val36)+str(val37)+str(val38)+str(val39)+str(val40)+","; 348 | s=s+"B"+str(val41)+str(val42)+str(val43)+str(val44)+str(val45)+str(val46)+str(val47)+str(val48)+","; 349 | s=s+"B"+str(val49)+str(val50)+str(val51)+str(val52)+str(val53)+str(val54)+str(val55)+str(val56)+","; 350 | s=s+"B"+str(val57)+str(val58)+str(val59)+str(val60)+str(val61)+str(val62)+str(val63)+str(val64)+","; 351 | return s; 352 | } -------------------------------------------------------------------------------- /examples/matrix16x8/matrix16x8.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for our I2C LED Backpacks 3 | 4 | Designed specifically to work with the Adafruit 16x8 LED Matrix backpacks 5 | ----> http://www.adafruit.com/products/2035 6 | ----> http://www.adafruit.com/products/2036 7 | ----> http://www.adafruit.com/products/2037 8 | ----> http://www.adafruit.com/products/2038 9 | ----> http://www.adafruit.com/products/2039 10 | ----> http://www.adafruit.com/products/2040 11 | ----> http://www.adafruit.com/products/2041 12 | ----> http://www.adafruit.com/products/2042 13 | ----> http://www.adafruit.com/products/2043 14 | ----> http://www.adafruit.com/products/2044 15 | ----> http://www.adafruit.com/products/2052 16 | 17 | These displays use I2C to communicate, 2 pins are required to 18 | interface. There are multiple selectable I2C addresses. For backpacks 19 | with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks 20 | with 3 Address Select pins: 0x70 thru 0x77 21 | 22 | Adafruit invests time and resources providing this open source code, 23 | please support Adafruit and open-source hardware by purchasing 24 | products from Adafruit! 25 | 26 | Written by Limor Fried/Ladyada for Adafruit Industries. 27 | BSD license, all text above must be included in any redistribution 28 | ****************************************************/ 29 | 30 | #include 31 | #include 32 | #include "Adafruit_LEDBackpack.h" 33 | 34 | Adafruit_8x16matrix matrix = Adafruit_8x16matrix(); 35 | 36 | void setup() { 37 | Serial.begin(9600); 38 | Serial.println("16x8 LED Matrix Test"); 39 | 40 | matrix.begin(0x70); // pass in the address 41 | } 42 | 43 | static const uint8_t PROGMEM 44 | smile_bmp[] = 45 | { B00111100, 46 | B01000010, 47 | B10100101, 48 | B10000001, 49 | B10100101, 50 | B10011001, 51 | B01000010, 52 | B00111100 }, 53 | neutral_bmp[] = 54 | { B00111100, 55 | B01000010, 56 | B10100101, 57 | B10000001, 58 | B10111101, 59 | B10000001, 60 | B01000010, 61 | B00111100 }, 62 | frown_bmp[] = 63 | { B00111100, 64 | B01000010, 65 | B10100101, 66 | B10000001, 67 | B10011001, 68 | B10100101, 69 | B01000010, 70 | B00111100 }; 71 | 72 | void loop() { 73 | 74 | matrix.clear(); 75 | matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON); 76 | matrix.writeDisplay(); 77 | delay(500); 78 | 79 | matrix.clear(); 80 | matrix.drawBitmap(0, 8, neutral_bmp, 8, 8, LED_ON); 81 | matrix.writeDisplay(); 82 | delay(500); 83 | 84 | matrix.clear(); 85 | matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_ON); 86 | matrix.writeDisplay(); 87 | delay(500); 88 | 89 | matrix.clear(); // clear display 90 | matrix.drawPixel(0, 0, LED_ON); 91 | matrix.writeDisplay(); // write the changes we just made to the display 92 | delay(500); 93 | 94 | matrix.clear(); 95 | matrix.drawLine(0,0, 7,15, LED_ON); 96 | matrix.writeDisplay(); // write the changes we just made to the display 97 | delay(500); 98 | 99 | matrix.clear(); 100 | matrix.drawRect(0,0, 8,16, LED_ON); 101 | matrix.fillRect(2,2, 4,12, LED_ON); 102 | matrix.writeDisplay(); // write the changes we just made to the display 103 | delay(500); 104 | 105 | matrix.clear(); 106 | matrix.drawCircle(3,8, 3, LED_ON); 107 | matrix.writeDisplay(); // write the changes we just made to the display 108 | delay(500); 109 | 110 | matrix.setTextSize(2); 111 | matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely 112 | matrix.setTextColor(LED_ON); 113 | for (int8_t x=0; x>=-64; x--) { 114 | matrix.clear(); 115 | matrix.setCursor(x,0); 116 | matrix.print("Hello"); 117 | matrix.writeDisplay(); 118 | delay(100); 119 | } 120 | 121 | matrix.setTextSize(1); 122 | matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely 123 | matrix.setTextColor(LED_ON); 124 | matrix.setRotation(1); 125 | for (int8_t x=7; x>=-36; x--) { 126 | matrix.clear(); 127 | matrix.setCursor(x,0); 128 | matrix.print("World"); 129 | matrix.writeDisplay(); 130 | delay(100); 131 | } 132 | matrix.setRotation(0); 133 | } 134 | -------------------------------------------------------------------------------- /examples/matrix8x8/matrix8x8.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for our I2C LED Backpacks 3 | 4 | Designed specifically to work with the Adafruit LED Matrix backpacks 5 | ----> http://www.adafruit.com/products/872 6 | ----> http://www.adafruit.com/products/871 7 | ----> http://www.adafruit.com/products/870 8 | 9 | These displays use I2C to communicate, 2 pins are required to 10 | interface. There are multiple selectable I2C addresses. For backpacks 11 | with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks 12 | with 3 Address Select pins: 0x70 thru 0x77 13 | 14 | Adafruit invests time and resources providing this open source code, 15 | please support Adafruit and open-source hardware by purchasing 16 | products from Adafruit! 17 | 18 | Written by Limor Fried/Ladyada for Adafruit Industries. 19 | BSD license, all text above must be included in any redistribution 20 | ****************************************************/ 21 | 22 | #include 23 | #include 24 | #include "Adafruit_LEDBackpack.h" 25 | 26 | Adafruit_8x8matrix matrix = Adafruit_8x8matrix(); 27 | 28 | void setup() { 29 | Serial.begin(9600); 30 | Serial.println("8x8 LED Matrix Test"); 31 | 32 | matrix.begin(0x70); // pass in the address 33 | } 34 | 35 | static const uint8_t PROGMEM 36 | smile_bmp[] = 37 | { B00111100, 38 | B01000010, 39 | B10100101, 40 | B10000001, 41 | B10100101, 42 | B10011001, 43 | B01000010, 44 | B00111100 }, 45 | neutral_bmp[] = 46 | { B00111100, 47 | B01000010, 48 | B10100101, 49 | B10000001, 50 | B10111101, 51 | B10000001, 52 | B01000010, 53 | B00111100 }, 54 | frown_bmp[] = 55 | { B00111100, 56 | B01000010, 57 | B10100101, 58 | B10000001, 59 | B10011001, 60 | B10100101, 61 | B01000010, 62 | B00111100 }; 63 | 64 | void loop() { 65 | matrix.clear(); 66 | matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON); 67 | matrix.writeDisplay(); 68 | delay(500); 69 | 70 | matrix.clear(); 71 | matrix.drawBitmap(0, 0, neutral_bmp, 8, 8, LED_ON); 72 | matrix.writeDisplay(); 73 | delay(500); 74 | 75 | matrix.clear(); 76 | matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_ON); 77 | matrix.writeDisplay(); 78 | delay(500); 79 | 80 | matrix.clear(); // clear display 81 | matrix.drawPixel(0, 0, LED_ON); 82 | matrix.writeDisplay(); // write the changes we just made to the display 83 | delay(500); 84 | 85 | matrix.clear(); 86 | matrix.drawLine(0,0, 7,7, LED_ON); 87 | matrix.writeDisplay(); // write the changes we just made to the display 88 | delay(500); 89 | 90 | matrix.clear(); 91 | matrix.drawRect(0,0, 8,8, LED_ON); 92 | matrix.fillRect(2,2, 4,4, LED_ON); 93 | matrix.writeDisplay(); // write the changes we just made to the display 94 | delay(500); 95 | 96 | matrix.clear(); 97 | matrix.drawCircle(3,3, 3, LED_ON); 98 | matrix.writeDisplay(); // write the changes we just made to the display 99 | delay(500); 100 | 101 | matrix.setTextSize(1); 102 | matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely 103 | matrix.setTextColor(LED_ON); 104 | for (int8_t x=0; x>=-36; x--) { 105 | matrix.clear(); 106 | matrix.setCursor(x,0); 107 | matrix.print("Hello"); 108 | matrix.writeDisplay(); 109 | delay(100); 110 | } 111 | matrix.setRotation(3); 112 | for (int8_t x=7; x>=-36; x--) { 113 | matrix.clear(); 114 | matrix.setCursor(x,0); 115 | matrix.print("World"); 116 | matrix.writeDisplay(); 117 | delay(100); 118 | } 119 | matrix.setRotation(0); 120 | } 121 | -------------------------------------------------------------------------------- /examples/minimatrix16x8/minimatrix16x8.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for our I2C LED Backpacks & FeatherWings 3 | 4 | Designed specifically to work with the Adafruit 16x8 LED Matrix FeatherWing 5 | 6 | These displays use I2C to communicate, 2 pins are required to 7 | interface. There are multiple selectable I2C addresses. For backpacks 8 | with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks 9 | with 3 Address Select pins: 0x70 thru 0x77 10 | 11 | Adafruit invests time and resources providing this open source code, 12 | please support Adafruit and open-source hardware by purchasing 13 | products from Adafruit! 14 | 15 | Written by Limor Fried/Ladyada for Adafruit Industries. 16 | BSD license, all text above must be included in any redistribution 17 | ****************************************************/ 18 | 19 | #include 20 | #include 21 | #include "Adafruit_LEDBackpack.h" 22 | 23 | Adafruit_8x16minimatrix matrix = Adafruit_8x16minimatrix(); 24 | 25 | void setup() { 26 | //while (!Serial); 27 | Serial.begin(9600); 28 | Serial.println("16x8 LED Mini Matrix Test"); 29 | 30 | matrix.begin(0x70); // pass in the address 31 | } 32 | 33 | static const uint8_t PROGMEM 34 | smile_bmp[] = 35 | { B00111100, 36 | B01000010, 37 | B10100101, 38 | B10000001, 39 | B10100101, 40 | B10011001, 41 | B01000010, 42 | B00111100 }, 43 | neutral_bmp[] = 44 | { B00111100, 45 | B01000010, 46 | B10100101, 47 | B10000001, 48 | B10111101, 49 | B10000001, 50 | B01000010, 51 | B00111100 }, 52 | frown_bmp[] = 53 | { B00111100, 54 | B01000010, 55 | B10100101, 56 | B10000001, 57 | B10011001, 58 | B10100101, 59 | B01000010, 60 | B00111100 }; 61 | 62 | void loop() { 63 | 64 | matrix.clear(); 65 | matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON); 66 | matrix.writeDisplay(); 67 | delay(500); 68 | 69 | matrix.clear(); 70 | matrix.drawBitmap(0, 8, neutral_bmp, 8, 8, LED_ON); 71 | matrix.writeDisplay(); 72 | delay(500); 73 | 74 | matrix.clear(); 75 | matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_ON); 76 | matrix.writeDisplay(); 77 | delay(500); 78 | 79 | 80 | matrix.drawPixel(0, 0, LED_ON); 81 | matrix.writeDisplay(); // write the changes we just made to the display 82 | delay(500); 83 | 84 | matrix.clear(); 85 | matrix.drawLine(0,0, 7,15, LED_ON); 86 | matrix.writeDisplay(); // write the changes we just made to the display 87 | delay(500); 88 | 89 | matrix.clear(); 90 | matrix.drawRect(0,0, 8,16, LED_ON); 91 | matrix.fillRect(2,2, 4,12, LED_ON); 92 | matrix.writeDisplay(); // write the changes we just made to the display 93 | delay(500); 94 | 95 | matrix.clear(); 96 | matrix.drawCircle(3,8, 3, LED_ON); 97 | matrix.writeDisplay(); // write the changes we just made to the display 98 | delay(500); 99 | 100 | matrix.setTextSize(2); 101 | matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely 102 | matrix.setTextColor(LED_ON); 103 | for (int8_t x=0; x>=-64; x--) { 104 | matrix.clear(); 105 | matrix.setCursor(x,0); 106 | matrix.print("Hello"); 107 | matrix.writeDisplay(); 108 | delay(100); 109 | } 110 | 111 | matrix.setTextSize(1); 112 | matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely 113 | matrix.setTextColor(LED_ON); 114 | matrix.setRotation(1); 115 | for (int8_t x=7; x>=-36; x--) { 116 | matrix.clear(); 117 | matrix.setCursor(x,0); 118 | matrix.print("World"); 119 | matrix.writeDisplay(); 120 | delay(100); 121 | } 122 | matrix.setRotation(0); 123 | } -------------------------------------------------------------------------------- /examples/quadalphaanimation/quadalphaanimation.ino: -------------------------------------------------------------------------------- 1 | // This example shows how to use the alphanumeric segment names in an animation. 2 | // 3 | // Author: Jonny Bergdahl (github@bergdahl.org) 4 | // 5 | #include 6 | #include 7 | 8 | Adafruit_AlphaNum4 alpha4 = Adafruit_AlphaNum4(); 9 | 10 | /* 11 | Segment names for 14-segment alphanumeric displays. 12 | See https://learn.adafruit.com/14-segment-alpha-numeric-led-featherwing/usage 13 | 14 | -------A------- 15 | |\ | /| 16 | | \ J / | 17 | | H | K | 18 | F \ | / B 19 | | \|/ | 20 | |--G1--|--G2--| 21 | | /|\ | 22 | E / | \ C 23 | | L | N | 24 | | / M \ | 25 | |/ | \| 26 | -------D------- DP 27 | */ 28 | 29 | uint16_t animation[] { 0, ALPHANUM_SEG_A | ALPHANUM_SEG_D, 30 | 1, ALPHANUM_SEG_H | ALPHANUM_SEG_L, 31 | 1, ALPHANUM_SEG_N | ALPHANUM_SEG_K, 32 | 2, ALPHANUM_SEG_L | ALPHANUM_SEG_H, 33 | 2, ALPHANUM_SEG_K | ALPHANUM_SEG_N, 34 | 3, ALPHANUM_SEG_A | ALPHANUM_SEG_D, 35 | 3, ALPHANUM_SEG_B | ALPHANUM_SEG_C, 36 | 3, ALPHANUM_SEG_C | ALPHANUM_SEG_B, 37 | 3, ALPHANUM_SEG_D | ALPHANUM_SEG_A, 38 | 2, ALPHANUM_SEG_N | ALPHANUM_SEG_K, 39 | 2, ALPHANUM_SEG_H | ALPHANUM_SEG_L, 40 | 1, ALPHANUM_SEG_K | ALPHANUM_SEG_N, 41 | 1, ALPHANUM_SEG_L | ALPHANUM_SEG_H, 42 | 0, ALPHANUM_SEG_D | ALPHANUM_SEG_A, 43 | 0, ALPHANUM_SEG_E | ALPHANUM_SEG_F, 44 | 0, ALPHANUM_SEG_F | ALPHANUM_SEG_E }; 45 | 46 | void setup() { 47 | Serial.begin(9600); 48 | alpha4.begin(0x70); // pass in the address 49 | } 50 | 51 | void loop() { 52 | // For each step of the animation, write the value to the given digit 53 | for (int j = 0; j < sizeof(animation)/2; j = j + 2) 54 | { 55 | alpha4.clear(); 56 | alpha4.writeDigitRaw(animation[j], animation[j+1]); 57 | alpha4.writeDisplay(); 58 | delay(200); 59 | } 60 | } -------------------------------------------------------------------------------- /examples/quadalphanum/quadalphanum.ino: -------------------------------------------------------------------------------- 1 | // Demo the quad alphanumeric display LED backpack kit 2 | // scrolls through every character, then scrolls Serial 3 | // input onto the display 4 | 5 | #include 6 | #include 7 | #include "Adafruit_LEDBackpack.h" 8 | 9 | Adafruit_AlphaNum4 alpha4 = Adafruit_AlphaNum4(); 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | 14 | alpha4.begin(0x70); // pass in the address 15 | 16 | alpha4.writeDigitRaw(3, 0x0); 17 | alpha4.writeDigitRaw(0, 0xFFFF); 18 | alpha4.writeDisplay(); 19 | delay(200); 20 | alpha4.writeDigitRaw(0, 0x0); 21 | alpha4.writeDigitRaw(1, 0xFFFF); 22 | alpha4.writeDisplay(); 23 | delay(200); 24 | alpha4.writeDigitRaw(1, 0x0); 25 | alpha4.writeDigitRaw(2, 0xFFFF); 26 | alpha4.writeDisplay(); 27 | delay(200); 28 | alpha4.writeDigitRaw(2, 0x0); 29 | alpha4.writeDigitRaw(3, 0xFFFF); 30 | alpha4.writeDisplay(); 31 | delay(200); 32 | 33 | alpha4.clear(); 34 | alpha4.writeDisplay(); 35 | 36 | // display every character, 37 | for (uint8_t i='!'; i<='z'; i++) { 38 | alpha4.writeDigitAscii(0, i); 39 | alpha4.writeDigitAscii(1, i+1); 40 | alpha4.writeDigitAscii(2, i+2); 41 | alpha4.writeDigitAscii(3, i+3); 42 | alpha4.writeDisplay(); 43 | 44 | delay(300); 45 | } 46 | Serial.println("Start typing to display!"); 47 | } 48 | 49 | 50 | char displaybuffer[4] = {' ', ' ', ' ', ' '}; 51 | 52 | void loop() { 53 | while (! Serial.available()) return; 54 | 55 | char c = Serial.read(); 56 | if (! isprint(c)) return; // only printable! 57 | 58 | // scroll down display 59 | displaybuffer[0] = displaybuffer[1]; 60 | displaybuffer[1] = displaybuffer[2]; 61 | displaybuffer[2] = displaybuffer[3]; 62 | displaybuffer[3] = c; 63 | 64 | // set every digit to the buffer 65 | alpha4.writeDigitAscii(0, displaybuffer[0]); 66 | alpha4.writeDigitAscii(1, displaybuffer[1]); 67 | alpha4.writeDigitAscii(2, displaybuffer[2]); 68 | alpha4.writeDigitAscii(3, displaybuffer[3]); 69 | 70 | // write it out! 71 | alpha4.writeDisplay(); 72 | delay(200); 73 | } -------------------------------------------------------------------------------- /examples/quadalphanum_mini/quadalphanum_mini.ino: -------------------------------------------------------------------------------- 1 | // Demo the quad alphanumeric display LED backpack kit 2 | // Displays a short message and then scrolls through every character 3 | 4 | // For use with Gemma or Trinket (Attiny85) 5 | 6 | #include 7 | #include 8 | 9 | 10 | // Connect + pins to 3-5V 11 | // Connect GND to ground 12 | // Connect Data to #0 13 | // Connect Clock to #2 14 | 15 | #include 16 | #include "Adafruit_LEDBackpack.h" 17 | 18 | char *message = "Hello world! "; 19 | 20 | Adafruit_AlphaNum4 alpha4 = Adafruit_AlphaNum4(); 21 | 22 | void setup() { 23 | // This is the auto-speed doubler line, keep it in, it will 24 | // automatically double the speed when 16Mhz is selected! 25 | if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 26 | 27 | alpha4.begin(0x70); // pass in the address 28 | 29 | alpha4.writeDigitRaw(3, 0x0); 30 | alpha4.writeDigitRaw(0, 0xFFFF); 31 | alpha4.writeDisplay(); 32 | delay(200); 33 | alpha4.writeDigitRaw(0, 0x0); 34 | alpha4.writeDigitRaw(1, 0xFFFF); 35 | alpha4.writeDisplay(); 36 | delay(200); 37 | alpha4.writeDigitRaw(1, 0x0); 38 | alpha4.writeDigitRaw(2, 0xFFFF); 39 | alpha4.writeDisplay(); 40 | delay(200); 41 | alpha4.writeDigitRaw(2, 0x0); 42 | alpha4.writeDigitRaw(3, 0xFFFF); 43 | alpha4.writeDisplay(); 44 | delay(200); 45 | 46 | alpha4.clear(); 47 | alpha4.writeDisplay(); 48 | 49 | // send a message! 50 | for (uint8_t i=0; i 46 | #include 47 | #include 48 | #include "Adafruit_LEDBackpack.h" 49 | 50 | // Because the two eye matrices share the same address, only four 51 | // matrix objects are needed for the five displays: 52 | #define MATRIX_EYES 0 53 | #define MATRIX_MOUTH_LEFT 1 54 | #define MATRIX_MOUTH_MIDDLE 2 55 | #define MATRIX_MOUTH_RIGHT 3 56 | Adafruit_8x8matrix matrix[4] = { // Array of Adafruit_8x8matrix objects 57 | Adafruit_8x8matrix(), Adafruit_8x8matrix(), 58 | Adafruit_8x8matrix(), Adafruit_8x8matrix() }; 59 | 60 | // Rather than assigning matrix addresses sequentially in a loop, each 61 | // has a spot in this array. This makes it easier if you inadvertently 62 | // install one or more matrices in the wrong physical position -- 63 | // re-order the addresses in this table and you can still refer to 64 | // matrices by index above, no other code or wiring needs to change. 65 | static const uint8_t matrixAddr[] = { 0x70, 0x71, 0x72, 0x73 }; 66 | 67 | static const uint8_t PROGMEM // Bitmaps are stored in program memory 68 | blinkImg[][8] = { // Eye animation frames 69 | { B00111100, // Fully open eye 70 | B01111110, 71 | B11111111, 72 | B11111111, 73 | B11111111, 74 | B11111111, 75 | B01111110, 76 | B00111100 }, 77 | { B00000000, 78 | B01111110, 79 | B11111111, 80 | B11111111, 81 | B11111111, 82 | B11111111, 83 | B01111110, 84 | B00111100 }, 85 | { B00000000, 86 | B00000000, 87 | B00111100, 88 | B11111111, 89 | B11111111, 90 | B11111111, 91 | B00111100, 92 | B00000000 }, 93 | { B00000000, 94 | B00000000, 95 | B00000000, 96 | B00111100, 97 | B11111111, 98 | B01111110, 99 | B00011000, 100 | B00000000 }, 101 | { B00000000, // Fully closed eye 102 | B00000000, 103 | B00000000, 104 | B00000000, 105 | B10000001, 106 | B01111110, 107 | B00000000, 108 | B00000000 } }, 109 | mouthImg[][24] = { // Mouth animation frames 110 | { B00000000, B00000000, B00000000, // Mouth position A 111 | B00000000, B00000000, B00000000, 112 | B01111111, B11111111, B11111110, 113 | B00000000, B00000000, B00000000, 114 | B00000000, B00000000, B00000000, 115 | B00000000, B00000000, B00000000, 116 | B00000000, B00000000, B00000000, 117 | B00000000, B00000000, B00000000 }, 118 | { B00000000, B00000000, B00000000, // Mouth position B 119 | B00000000, B00000000, B00000000, 120 | B00111111, B11111111, B11111100, 121 | B00000111, B00000000, B11100000, 122 | B00000000, B11111111, B00000000, 123 | B00000000, B00000000, B00000000, 124 | B00000000, B00000000, B00000000, 125 | B00000000, B00000000, B00000000 }, 126 | { B00000000, B00000000, B00000000, // Mouth position C 127 | B00000000, B00000000, B00000000, 128 | B00111111, B11111111, B11111100, 129 | B00001000, B00000000, B00010000, 130 | B00000110, B00000000, B01100000, 131 | B00000001, B11000011, B10000000, 132 | B00000000, B00111100, B00000000, 133 | B00000000, B00000000, B00000000 }, 134 | { B00000000, B00000000, B00000000, // Mouth position D 135 | B00000000, B00000000, B00000000, 136 | B00111111, B11111111, B11111100, 137 | B00100000, B00000000, B00000100, 138 | B00010000, B00000000, B00001000, 139 | B00001100, B00000000, B00110000, 140 | B00000011, B10000001, B11000000, 141 | B00000000, B01111110, B00000000 }, 142 | { B00000000, B00000000, B00000000, // Mouth position E 143 | B00000000, B00111100, B00000000, 144 | B00011111, B11000011, B11111000, 145 | B00000011, B10000001, B11000000, 146 | B00000000, B01111110, B00000000, 147 | B00000000, B00000000, B00000000, 148 | B00000000, B00000000, B00000000, 149 | B00000000, B00000000, B00000000 }, 150 | { B00000000, B00111100, B00000000, // Mouth position F 151 | B00000000, B11000011, B00000000, 152 | B00001111, B00000000, B11110000, 153 | B00000001, B00000000, B10000000, 154 | B00000000, B11000011, B00000000, 155 | B00000000, B00111100, B00000000, 156 | B00000000, B00000000, B00000000, 157 | B00000000, B00000000, B00000000 } }; 158 | 159 | uint8_t 160 | blinkIndex[] = { 1, 2, 3, 4, 3, 2, 1 }, // Blink bitmap sequence 161 | blinkCountdown = 100, // Countdown to next blink (in frames) 162 | gazeCountdown = 75, // Countdown to next eye movement 163 | gazeFrames = 50, // Duration of eye movement (smaller = faster) 164 | mouthPos = 0, // Current image number for mouth 165 | mouthCountdown = 10; // Countdown to next mouth change 166 | int8_t 167 | eyeX = 3, eyeY = 3, // Current eye position 168 | newX = 3, newY = 3, // Next eye position 169 | dX = 0, dY = 0; // Distance from prior to new position 170 | 171 | void setup() { 172 | 173 | // Seed random number generator from an unused analog input: 174 | randomSeed(analogRead(A0)); 175 | 176 | // Initialize each matrix object: 177 | for(uint8_t i=0; i<4; i++) { 178 | matrix[i].begin(matrixAddr[i]); 179 | // If using 'small' (1.2") displays vs. 'mini' (0.8"), enable this: 180 | // matrix[i].setRotation(3); 181 | } 182 | } 183 | 184 | void loop() { 185 | 186 | // Draw eyeball in current state of blinkyness (no pupil). Note that 187 | // only one eye needs to be drawn. Because the two eye matrices share 188 | // the same address, the same data will be received by both. 189 | matrix[MATRIX_EYES].clear(); 190 | // When counting down to the next blink, show the eye in the fully- 191 | // open state. On the last few counts (during the blink), look up 192 | // the corresponding bitmap index. 193 | matrix[MATRIX_EYES].drawBitmap(0, 0, 194 | blinkImg[ 195 | (blinkCountdown < sizeof(blinkIndex)) ? // Currently blinking? 196 | blinkIndex[blinkCountdown] : // Yes, look up bitmap # 197 | 0 // No, show bitmap 0 198 | ], 8, 8, LED_ON); 199 | // Decrement blink counter. At end, set random time for next blink. 200 | if(--blinkCountdown == 0) blinkCountdown = random(5, 180); 201 | 202 | // Add a pupil (2x2 black square) atop the blinky eyeball bitmap. 203 | // Periodically, the pupil moves to a new position... 204 | if(--gazeCountdown <= gazeFrames) { 205 | // Eyes are in motion - draw pupil at interim position 206 | matrix[MATRIX_EYES].fillRect( 207 | newX - (dX * gazeCountdown / gazeFrames), 208 | newY - (dY * gazeCountdown / gazeFrames), 209 | 2, 2, LED_OFF); 210 | if(gazeCountdown == 0) { // Last frame? 211 | eyeX = newX; eyeY = newY; // Yes. What's new is old, then... 212 | do { // Pick random positions until one is within the eye circle 213 | newX = random(7); newY = random(7); 214 | dX = newX - 3; dY = newY - 3; 215 | } while((dX * dX + dY * dY) >= 10); // Thank you Pythagoras 216 | dX = newX - eyeX; // Horizontal distance to move 217 | dY = newY - eyeY; // Vertical distance to move 218 | gazeFrames = random(3, 15); // Duration of eye movement 219 | gazeCountdown = random(gazeFrames, 120); // Count to end of next movement 220 | } 221 | } else { 222 | // Not in motion yet -- draw pupil at current static position 223 | matrix[MATRIX_EYES].fillRect(eyeX, eyeY, 2, 2, LED_OFF); 224 | } 225 | 226 | // Draw mouth, switch to new random image periodically 227 | drawMouth(mouthImg[mouthPos]); 228 | if(--mouthCountdown == 0) { 229 | mouthPos = random(6); // Random image 230 | // If the 'neutral' position was chosen, there's a 1-in-5 chance we'll 231 | // select a longer hold time. This gives the appearance of periodic 232 | // pauses in speech (e.g. between sentences, etc.). 233 | mouthCountdown = ((mouthPos == 0) && (random(5) == 0)) ? 234 | random(10, 40) : // Longer random duration 235 | random(2, 8); // Shorter random duration 236 | } 237 | 238 | // Refresh all of the matrices in one quick pass 239 | for(uint8_t i=0; i<4; i++) matrix[i].writeDisplay(); 240 | 241 | delay(20); // ~50 FPS 242 | } 243 | 244 | // Draw mouth image across three adjacent displays 245 | void drawMouth(const uint8_t *img) { 246 | for(uint8_t i=0; i<3; i++) { 247 | matrix[MATRIX_MOUTH_LEFT + i].clear(); 248 | matrix[MATRIX_MOUTH_LEFT + i].drawBitmap(i * -8, 0, img, 24, 8, LED_ON); 249 | } 250 | } 251 | 252 | -------------------------------------------------------------------------------- /examples/sevenseg/sevenseg.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for our I2C LED Backpacks 3 | 4 | Designed specifically to work with the Adafruit LED 7-Segment backpacks 5 | ----> http://www.adafruit.com/products/881 6 | ----> http://www.adafruit.com/products/880 7 | ----> http://www.adafruit.com/products/879 8 | ----> http://www.adafruit.com/products/878 9 | 10 | These displays use I2C to communicate, 2 pins are required to 11 | interface. There are multiple selectable I2C addresses. For backpacks 12 | with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks 13 | with 3 Address Select pins: 0x70 thru 0x77 14 | 15 | Adafruit invests time and resources providing this open source code, 16 | please support Adafruit and open-source hardware by purchasing 17 | products from Adafruit! 18 | 19 | Written by Limor Fried/Ladyada for Adafruit Industries. 20 | BSD license, all text above must be included in any redistribution 21 | ****************************************************/ 22 | 23 | #include // Enable this line if using Arduino Uno, Mega, etc. 24 | #include 25 | #include "Adafruit_LEDBackpack.h" 26 | 27 | Adafruit_7segment matrix = Adafruit_7segment(); 28 | 29 | void setup() { 30 | #ifndef __AVR_ATtiny85__ 31 | Serial.begin(9600); 32 | Serial.println("7 Segment Backpack Test"); 33 | #endif 34 | matrix.begin(0x70); 35 | } 36 | 37 | void loop() { 38 | // try to print a number thats too long 39 | matrix.print(10000, DEC); 40 | matrix.writeDisplay(); 41 | delay(500); 42 | 43 | // print a hex number 44 | matrix.print(0xBEEF, HEX); 45 | matrix.writeDisplay(); 46 | delay(500); 47 | 48 | // print a floating point 49 | matrix.print(12.34); 50 | matrix.writeDisplay(); 51 | delay(500); 52 | 53 | // print a string message 54 | matrix.print("7SEG"); 55 | matrix.writeDisplay(); 56 | delay(10000); 57 | 58 | // print with print/println 59 | for (uint16_t counter = 0; counter < 9999; counter++) { 60 | matrix.println(counter); 61 | matrix.writeDisplay(); 62 | delay(10); 63 | } 64 | 65 | // method #2 - draw each digit 66 | uint16_t blinkcounter = 0; 67 | boolean drawDots = false; 68 | for (uint16_t counter = 0; counter < 9999; counter ++) { 69 | matrix.writeDigitNum(0, (counter / 1000), drawDots); 70 | matrix.writeDigitNum(1, (counter / 100) % 10, drawDots); 71 | matrix.drawColon(drawDots); 72 | matrix.writeDigitNum(3, (counter / 10) % 10, drawDots); 73 | matrix.writeDigitNum(4, counter % 10, drawDots); 74 | 75 | blinkcounter+=50; 76 | if (blinkcounter < 500) { 77 | drawDots = false; 78 | } else if (blinkcounter < 1000) { 79 | drawDots = true; 80 | } else { 81 | blinkcounter = 0; 82 | } 83 | matrix.writeDisplay(); 84 | delay(10); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /examples/wavface/wavface.ino: -------------------------------------------------------------------------------- 1 | // 'wavface' example sketch for Adafruit I2C 8x8 LED backpacks 2 | // and Wave Shield: 3 | // 4 | // www.adafruit.com/products/870 www.adafruit.com/products/1049 5 | // www.adafruit.com/products/871 www.adafruit.com/products/1050 6 | // www.adafruit.com/products/872 www.adafruit.com/products/1051 7 | // www.adafruit.com/products/959 www.adafruit.com/products/1052 8 | // www.adafruit.com/products/94 9 | // 10 | // Requires Adafruit_LEDBackpack, Adafruit_GFX libraries and WaveHC 11 | // libraries. 12 | // 13 | // This sketch shows animation roughly synchronized to prerecorded 14 | // speech. It's fairly complex and may be overwhelming to novice 15 | // programmers, who may want to start with the 'matrix8x8' example 16 | // and then 'roboface' before working through this code. Also, much 17 | // of the comments relating to the face animation have been stripped 18 | // here for brevity...refer to the 'roboface' sketch if you have any 19 | // questions how that part works. 20 | // 21 | // Additional hardware required: sounds are triggered using three 22 | // normally-open momentary buttons connected to Digital pins 6, 7, 8 23 | // and GND. (e.g. www.adafruit.com/products/1009 ) 24 | // 25 | // Adafruit invests time and resources providing this open source code, 26 | // please support Adafruit and open-source hardware by purchasing 27 | // products from Adafruit! 28 | // 29 | // Written by P. Burgess for Adafruit Industries, parts adapted from 30 | // 'PiSpeakHC' sketch included with WaveHC library. 31 | // BSD license, all text above must be included in any redistribution. 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include "Adafruit_LEDBackpack.h" 39 | 40 | // These WAV files should be in the root level of the SD card: 41 | static const char PROGMEM 42 | wav0[] = "beware_i.wav", 43 | wav1[] = "ihunger.wav", 44 | wav2[] = "run_cowd.wav"; 45 | static const char * const wavname[] PROGMEM = { wav0, wav1, wav2 }; 46 | // PROGMEM makes frequent appearances throughout this code, reason being that 47 | // the SD card library requires gobs of precious RAM (leaving very little to 48 | // our own sketch). PROGMEM lets us put fixed data into program flash memory, 49 | // which is considerably more spacious. String tables are paritcularly nasty. 50 | // See www.arduino.cc/en/Reference/PROGMEM for more info. 51 | 52 | SdReader card; // This object holds the information for the card 53 | FatVolume vol; // This holds the information for the partition on the card 54 | FatReader root; // This holds the information for the volumes root directory 55 | FatReader file; // This object represent the WAV file for a phrase 56 | WaveHC wave; // A single wave object -- only one sound is played at a time 57 | 58 | // Because the two eye matrices share the same address, only four 59 | // matrix objects are needed for the five displays: 60 | #define MATRIX_EYES 0 61 | #define MATRIX_MOUTH_LEFT 1 62 | #define MATRIX_MOUTH_MIDDLE 2 63 | #define MATRIX_MOUTH_RIGHT 3 64 | Adafruit_8x8matrix matrix[4] = { // Array of Adafruit_8x8matrix objects 65 | Adafruit_8x8matrix(), Adafruit_8x8matrix(), 66 | Adafruit_8x8matrix(), Adafruit_8x8matrix() }; 67 | 68 | // Rather than assigning matrix addresses sequentially in a loop, each 69 | // has a spot in this array. This makes it easier if you inadvertently 70 | // install one or more matrices in the wrong physical position -- 71 | // re-order the addresses in this table and you can still refer to 72 | // matrices by index above, no other code or wiring needs to change. 73 | static const uint8_t PROGMEM matrixAddr[] = { 0x70, 0x71, 0x72, 0x73 }; 74 | 75 | static const uint8_t PROGMEM // Bitmaps are stored in program memory 76 | blinkImg[][8] = { // Eye animation frames 77 | { B00111100, // Fully open eye 78 | B01111110, 79 | B11111111, 80 | B11111111, 81 | B11111111, 82 | B11111111, 83 | B01111110, 84 | B00111100 }, 85 | { B00000000, 86 | B01111110, 87 | B11111111, 88 | B11111111, 89 | B11111111, 90 | B11111111, 91 | B01111110, 92 | B00111100 }, 93 | { B00000000, 94 | B00000000, 95 | B00111100, 96 | B11111111, 97 | B11111111, 98 | B11111111, 99 | B00111100, 100 | B00000000 }, 101 | { B00000000, 102 | B00000000, 103 | B00000000, 104 | B00111100, 105 | B11111111, 106 | B01111110, 107 | B00011000, 108 | B00000000 }, 109 | { B00000000, // Fully closed eye 110 | B00000000, 111 | B00000000, 112 | B00000000, 113 | B10000001, 114 | B01111110, 115 | B00000000, 116 | B00000000 } }, 117 | mouthImg[][24] = { // Mouth animation frames 118 | { B00000000, B00000000, B00000000, // Mouth position A 119 | B00000000, B00000000, B00000000, 120 | B01111111, B11111111, B11111110, 121 | B00000000, B00000000, B00000000, 122 | B00000000, B00000000, B00000000, 123 | B00000000, B00000000, B00000000, 124 | B00000000, B00000000, B00000000, 125 | B00000000, B00000000, B00000000 }, 126 | { B00000000, B00000000, B00000000, // Mouth position B 127 | B00000000, B00000000, B00000000, 128 | B00111111, B11111111, B11111100, 129 | B00000111, B00000000, B11100000, 130 | B00000000, B11111111, B00000000, 131 | B00000000, B00000000, B00000000, 132 | B00000000, B00000000, B00000000, 133 | B00000000, B00000000, B00000000 }, 134 | { B00000000, B00000000, B00000000, // Mouth position C 135 | B00000000, B00000000, B00000000, 136 | B00111111, B11111111, B11111100, 137 | B00001000, B00000000, B00010000, 138 | B00000110, B00000000, B01100000, 139 | B00000001, B11000011, B10000000, 140 | B00000000, B00111100, B00000000, 141 | B00000000, B00000000, B00000000 }, 142 | { B00000000, B00000000, B00000000, // Mouth position D 143 | B00000000, B00000000, B00000000, 144 | B00111111, B11111111, B11111100, 145 | B00100000, B00000000, B00000100, 146 | B00010000, B00000000, B00001000, 147 | B00001100, B00000000, B00110000, 148 | B00000011, B10000001, B11000000, 149 | B00000000, B01111110, B00000000 }, 150 | { B00000000, B00000000, B00000000, // Mouth position E 151 | B00000000, B00111100, B00000000, 152 | B00011111, B11000011, B11111000, 153 | B00000011, B10000001, B11000000, 154 | B00000000, B01111110, B00000000, 155 | B00000000, B00000000, B00000000, 156 | B00000000, B00000000, B00000000, 157 | B00000000, B00000000, B00000000 }, 158 | { B00000000, B00111100, B00000000, // Mouth position F 159 | B00000000, B11000011, B00000000, 160 | B00001111, B00000000, B11110000, 161 | B00000001, B00000000, B10000000, 162 | B00000000, B11000011, B00000000, 163 | B00000000, B00111100, B00000000, 164 | B00000000, B00000000, B00000000, 165 | B00000000, B00000000, B00000000 } }; 166 | 167 | // Animation sequences corresponding to each WAV. First number in 168 | // each pair is a mouth bitmap index. Second number is the hold 169 | // time (in frames). 255 marks end of list. 170 | // There is no 'magic' here, the software is NOT deriving mouth 171 | // position from the sound...the tables were determined by hand, 172 | // just as animators do it. Further explanation here: 173 | // http://www.idleworm.com/how/anm/03t/talk1.shtml 174 | 175 | static const uint8_t PROGMEM 176 | seq1[] = { 0, 2, 2, 5, 5, 3, 3, 7, // "Beware, I live!" 177 | 4, 5, 3, 4, 2, 5, 4, 3, 178 | 3, 4, 1, 5, 3, 5, 255 }, 179 | seq2[] = { 0, 1, 3, 5, 1, 5, 4, 2, // "I hunger!" 180 | 3, 2, 1, 2, 4, 4, 1, 3, 181 | 4, 2, 255 }, 182 | seq3[] = { 0, 1, 1, 2, 3, 6, 2, 5, // "Run, coward!" 183 | 0, 1, 4, 4, 5, 2, 1, 5, 184 | 3, 6, 1, 4, 255 }; 185 | static const uint8_t * const anim[] = { seq1, seq2, seq3 }; 186 | 187 | const uint8_t 188 | blinkIndex[] PROGMEM = { 1, 2, 3, 4, 3, 2, 1 }; // Blink bitmap sequence 189 | uint8_t 190 | blinkCountdown = 100, // Countdown to next blink (in frames) 191 | gazeCountdown = 75, // Countdown to next eye movement 192 | gazeFrames = 50, // Duration of eye movement (smaller = faster) 193 | mouthPos = 0, // Current image number for mouth 194 | mouthCountdown = 10, // Countdown to next mouth change 195 | newPos = 255, // New mouth position for current frame 196 | *seq, // Animation sequence currently being played back 197 | idx, // Current array index within animation sequence 198 | prevBtn = 99, // Button # pressed on last loop() iteration 199 | btnCount = 0; // Number of iterations same button has been held 200 | int8_t 201 | eyeX = 3, eyeY = 3, // Current eye position 202 | newX = 3, newY = 3, // Next eye position 203 | dX = 0, dY = 0; // Distance from prior to new position 204 | 205 | void setup() { 206 | 207 | Serial.begin(9600); 208 | 209 | Serial.println(F("WAV face")); 210 | 211 | if(!card.init()) Serial.println(F("Card init. failed!")); 212 | if(!vol.init(card)) Serial.println(F("No partition!")); 213 | if(!root.openRoot(vol)) Serial.println(F("Couldn't open dir")); 214 | Serial.println(F("Files found:")); 215 | root.ls(); 216 | 217 | // Seed random number generator from an unused analog input: 218 | randomSeed(analogRead(A0)); 219 | 220 | // Initialize each matrix object: 221 | for(uint8_t i=0; i<4; i++) { 222 | matrix[i].begin(pgm_read_byte(&matrixAddr[i])); 223 | // If using 'small' (1.2") displays vs. 'mini' (0.8"), enable this: 224 | // matrix[i].setRotation(3); 225 | } 226 | 227 | // Enable pull-up resistors on three button inputs. 228 | // Other end of each button then connects to GND. 229 | for(uint8_t i=6; i<=8; i++) { 230 | pinMode(i, INPUT); 231 | digitalWrite(i, HIGH); // Enable pullup 232 | } 233 | } 234 | 235 | void loop() { 236 | 237 | uint8_t i; 238 | 239 | // Draw eyeball in current state of blinkyness (no pupil). 240 | matrix[MATRIX_EYES].clear(); 241 | matrix[MATRIX_EYES].drawBitmap(0, 0, 242 | blinkImg[ 243 | (blinkCountdown < sizeof(blinkIndex)) ? // Currently blinking? 244 | pgm_read_byte(&blinkIndex[blinkCountdown]) : // Yes, look up bitmap # 245 | 0 // No, show bitmap 0 246 | ], 8, 8, LED_ON); 247 | // Decrement blink counter. At end, set random time for next blink. 248 | if(--blinkCountdown == 0) blinkCountdown = random(5, 180); 249 | 250 | if(--gazeCountdown <= gazeFrames) { 251 | // Eyes are in motion - draw pupil at interim position 252 | matrix[MATRIX_EYES].fillRect( 253 | newX - (dX * gazeCountdown / gazeFrames), 254 | newY - (dY * gazeCountdown / gazeFrames), 255 | 2, 2, LED_OFF); 256 | if(gazeCountdown == 0) { // Last frame? 257 | eyeX = newX; eyeY = newY; // Yes. What's new is old, then... 258 | do { // Pick random positions until one is within the eye circle 259 | newX = random(7); newY = random(7); 260 | dX = newX - 3; dY = newY - 3; 261 | } while((dX * dX + dY * dY) >= 10); // Thank you Pythagoras 262 | dX = newX - eyeX; // Horizontal distance to move 263 | dY = newY - eyeY; // Vertical distance to move 264 | gazeFrames = random(3, 15); // Duration of eye movement 265 | gazeCountdown = random(gazeFrames, 120); // Count to end of next movement 266 | } 267 | } else { 268 | // Not in motion yet -- draw pupil at current static position 269 | matrix[MATRIX_EYES].fillRect(eyeX, eyeY, 2, 2, LED_OFF); 270 | } 271 | 272 | // Scan buttons 6, 7, 8 looking for first button pressed... 273 | for(i=0; (i<3) && (digitalRead(i+6) == HIGH); i++); 274 | 275 | if(i < 3) { // Anything pressed? Yes! 276 | if(i == prevBtn) { // Same as last time we checked? Good! 277 | if(++btnCount == 3) { // 3 passes to 'debounce' button input 278 | playfile((char *)pgm_read_word(&wavname[i])); // Start WAV 279 | // Look up animation sequence # corresponding to this WAV... 280 | seq = (uint8_t *)pgm_read_word(&anim[i]); 281 | idx = 0; // Begin at first byte of data 282 | newPos = pgm_read_byte(&seq[idx++]); // Initial mouth pos 283 | mouthCountdown = pgm_read_byte(&seq[idx++]); // Hold time for pos 284 | } 285 | } else btnCount = 0; // Different button than before - start count over 286 | prevBtn = i; 287 | } else prevBtn = 99; // No buttons pressed 288 | 289 | if(newPos != 255) { // Is the mouth in motion? 290 | if(--mouthCountdown == 0) { // Count down frames to next position 291 | newPos = pgm_read_byte(&seq[idx++]); // New mouth position 292 | if(newPos == 255) { // End of list? 293 | mouthPos = 0; // Yes, set mouth to neutral position 294 | } else { 295 | mouthPos = newPos; // Set mouth to new position 296 | mouthCountdown = pgm_read_byte(&seq[idx++]); // Read hold time 297 | } 298 | } 299 | } else mouthPos = 0; // Mouth not in motion -- set to neutral position 300 | 301 | drawMouth(mouthImg[mouthPos]); 302 | 303 | // Refresh all matrices in one quick pass 304 | for(uint8_t i=0; i<4; i++) matrix[i].writeDisplay(); 305 | 306 | delay(20); 307 | } 308 | 309 | // Draw mouth image across three adjacent displays 310 | void drawMouth(const uint8_t *img) { 311 | for(uint8_t i=0; i<3; i++) { 312 | matrix[MATRIX_MOUTH_LEFT + i].clear(); 313 | matrix[MATRIX_MOUTH_LEFT + i].drawBitmap(i * -8, 0, img, 24, 8, LED_ON); 314 | } 315 | } 316 | 317 | // Open and start playing a WAV file 318 | void playfile(const char *name) { 319 | char filename[13]; // 8.3+NUL 320 | 321 | if(wave.isplaying) wave.stop(); // Stop any currently-playing WAV 322 | 323 | strcpy_P(filename, name); // Copy name out of PROGMEM into RAM 324 | 325 | if(!file.open(root, filename)) { 326 | Serial.print(F("Couldn't open file ")); 327 | Serial.println(filename); 328 | return; 329 | } 330 | if(!wave.create(file)) { 331 | Serial.println(F("Not a valid WAV")); 332 | return; 333 | } 334 | wave.play(); 335 | } 336 | 337 | -------------------------------------------------------------------------------- /examples/wavface/wavs/beware_i.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_LED_Backpack/c4ec1328fda9e4cbf355f6e407346347b4d207e2/examples/wavface/wavs/beware_i.wav -------------------------------------------------------------------------------- /examples/wavface/wavs/ihunger.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_LED_Backpack/c4ec1328fda9e4cbf355f6e407346347b4d207e2/examples/wavface/wavs/ihunger.wav -------------------------------------------------------------------------------- /examples/wavface/wavs/run_cowd.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_LED_Backpack/c4ec1328fda9e4cbf355f6e407346347b4d207e2/examples/wavface/wavs/run_cowd.wav -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit LED Backpack Library 2 | version=1.5.1 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Adafruit LED Backpack Library for our 8x8 matrix and 7-segment LED backpacks 6 | paragraph=Adafruit LED Backpack Library for our 8x8 matrix and 7-segment LED backpacks 7 | category=Display 8 | depends=Adafruit GFX Library, WaveHC, RTClib, Adafruit GPS Library 9 | url=https://github.com/adafruit/Adafruit_LED_Backpack 10 | architectures=* 11 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2012 Adafruit Industries 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | --------------------------------------------------------------------------------