|
| 1 | +/************************************************************************************** |
| 2 | + * This example redefines some characters of an alphanumeric display. |
| 3 | + * |
| 4 | + * Written by Gaston Williams |
| 5 | + * April 30, 2020 |
| 6 | + * |
| 7 | + * Based on code written by |
| 8 | + * Priyanka Makin @ SparkFun Electronics |
| 9 | + * Original Creation Date: February 26, 2020 |
| 10 | + * |
| 11 | + * SparkFun labored with love to create this code. Feel like supporting open source hardware? |
| 12 | + * Buy a board from SparkFun! https://www.sparkfun.com/products/16426 |
| 13 | + * |
| 14 | + * This code is beerware; if you see me (or any other SparkFun employee) at the |
| 15 | + * local, and you've found our code helpful, please buy us a round! |
| 16 | + * |
| 17 | + * Hardware Connections: |
| 18 | + * Attach Red Board to computer using micro-B USB cable. |
| 19 | + * Attach Qwiic Alphanumeric board to Red Board using Qwiic cable. |
| 20 | + * Don't close any of the address jumpers so that it defaults to address 0x70. |
| 21 | + * |
| 22 | + * Distributed as-is; no warranty is given. |
| 23 | + *****************************************************************************************/ |
| 24 | +#include <SparkFun_Alphanumeric_Display.h> |
| 25 | +HT16K33 display; |
| 26 | + |
| 27 | +void setup() { |
| 28 | + Serial.begin(115200); |
| 29 | + Serial.println("Qwiic Alphanumeric examples"); |
| 30 | + Wire.begin(); //Join I2C bus |
| 31 | + |
| 32 | + //check if display will acknowledge |
| 33 | + if (display.begin() == false) |
| 34 | + { |
| 35 | + Serial.println("Device did not acknowledge! Freezing."); |
| 36 | + while(1); |
| 37 | + } |
| 38 | + Serial.println("Display acknowledged."); |
| 39 | + |
| 40 | + //Just for demo purposes, show original characters before change |
| 41 | + display.print("cafe"); |
| 42 | + delay(500); |
| 43 | + display.print("size"); |
| 44 | + |
| 45 | + |
| 46 | + //Update a, e, f, s and z to new characters |
| 47 | + //This change is not permanent, and lasts only for this program. |
| 48 | + |
| 49 | + //Define 14 segment bits: nmlkjihgfedcba |
| 50 | + display.defineChar('a', 0b01000001011000); |
| 51 | + display.defineChar('e', 0b10000001011000); |
| 52 | + display.defineChar('f', 0b01010101000000); |
| 53 | + //Also can use constants SEG_A - SEG_N to define characters |
| 54 | + display.defineChar('s', SEG_L | SEG_I | SEG_D); // 0b00100100001000 |
| 55 | + display.defineChar('z', SEG_N | SEG_G | SEG_D); // 0b10000001001000 |
| 56 | +} |
| 57 | + |
| 58 | +void loop() |
| 59 | +{ |
| 60 | + //Show the new characters |
| 61 | + delay(500); |
| 62 | + display.print("cafe"); |
| 63 | + delay(500); |
| 64 | + display.print("size"); |
| 65 | +} |
0 commit comments