diff --git a/AlphanumericUserGuide/SparkFun Alphanumeric Display.odt b/AlphanumericUserGuide/SparkFun Alphanumeric Display.odt new file mode 100644 index 0000000..02888ea Binary files /dev/null and b/AlphanumericUserGuide/SparkFun Alphanumeric Display.odt differ diff --git a/AlphanumericUserGuide/SparkFun Alphanumeric Display.pdf b/AlphanumericUserGuide/SparkFun Alphanumeric Display.pdf new file mode 100644 index 0000000..a9e341c Binary files /dev/null and b/AlphanumericUserGuide/SparkFun Alphanumeric Display.pdf differ diff --git a/examples/Example11_SegmentNames.ino b/examples/Example11_SegmentNames.ino new file mode 100644 index 0000000..6c42165 --- /dev/null +++ b/examples/Example11_SegmentNames.ino @@ -0,0 +1,70 @@ + +/******************************************************************************************* + * This is based on the SparkFun Example 2 for the Spark-X + * alphanumeric display. + * This version cycles through the names, displaying a name + * and illuminating the corresponding segment on the next + * digit. Since the displays have 4 digits, we can show two + * at a time. + * Hardware Connections: + * + * Attach Red Board to computer using micro-B USB cable. + * Attach Qwiic Alphanumeric board to Red Board using Qwiic cable. + * + * I wrote this for my own use, but have decided to release + * it as "user contributed" to the general community. + * + * Written by Clark Jones, and released as "beerware", as-is, + * with abolutely no guarantees. + *****************************************************************************************/ +#include + +#include //Click here to get the library: http://librarymanager/All#Alphanumeric_Display by SparkFun +HT16K33 display; + +uint8_t currChar; +unsigned long nextDisplay; + +void setup() +{ + Serial.begin(115200); + Serial.println("Qwiic Alphanumeric examples"); + Wire.begin(); //Join I2C bus + + //check if display will acknowledge + if (display.begin() == false) + { + Serial.println("Device did not acknowledge! Freezing."); + while(1); + } + Serial.println("Display acknowledged."); + + currChar = 'A'; + nextDisplay = 0; +} + +void loop() +{ + unsigned long nowTime; + nowTime = millis(); + // Rather than using the millis() value, delay(2000) could have + // been used, but if other things were going on, this allows + // for them to happen, thus being better "style". + if ( nowTime >= nextDisplay ) { + nextDisplay = nowTime + 2000; + display.clear(); + display.printChar(currChar, 0); + display.illuminateSegment(currChar, 1); + Serial.print("Displaying segment "); + Serial.print(currChar); + currChar++; + display.printChar(currChar, 2); + display.illuminateSegment(currChar,3); + Serial.print(" and segment "); + Serial.println(currChar); + currChar++; + display.updateDisplay(); + if ( currChar > 'N' ) + currChar = 'A'; // Cycle around + }; // nowTime >= nextDisplay +} diff --git a/examples/Example12_ShowChars.ino b/examples/Example12_ShowChars.ino new file mode 100644 index 0000000..aa90fde --- /dev/null +++ b/examples/Example12_ShowChars.ino @@ -0,0 +1,83 @@ +/**************************************************************** + * This sketch will run through the poossible values that the + * Spark-X Alphanumeric Displays (SparkFun SPX-16391, SPX-16425, + * SPX-16426, and SPX-16427) can display, so that the user can + * easily see an example of each letter. + * + * The first two digits will be the hexadecimal ASCII value, and + * the fourth digit will actually display the character. + * + * Furthermore, a message is sent to the serial monitor stating + * what character is being displayed. + * + * I wrote this for my own use, but have decided to release + * it as "user contributed" to the general community. + * + * Written by Clark Jones, and released as "beerware", as-is, + * with abolutely no guarantees. + */ + +#include +#include + +HT16K33 display; + +unsigned long nextDisplayTime; + +uint8_t showingChar; + +void setup() { + Serial.begin(115200); + Serial.println("Qwiic Alphanumeric examples"); + Wire.begin(); //Join I2C bus + + //check if display will acknowledge + if (display.begin() == false) + { + Serial.println("Device did not acknowledge! Freezing."); + while(1); + } + Serial.println("Display acknowledged."); + + nextDisplayTime = 0; + showingChar = '!'; +} + +void loop() { + unsigned long nowTime; + nowTime = millis(); + if ( nowTime >= nextDisplayTime ) { + nextDisplayTime = nowTime + 2000; + display.clear(); + char hexUpper, hexLower; + byte temp; + temp = showingChar >> 4; // faster than dividing by 16 + if ( temp <= 9 ) { + hexUpper = '0' + temp; + } else { + hexUpper = 'A' + temp - 10; + }; + temp = showingChar & 0x0F; + if ( temp <= 9 ) { + hexLower = '0' + temp; + } else { + hexLower = 'A' + temp - 10; + }; + display.printChar( hexUpper, 0 ); + display.printChar( hexLower, 1 ); + display.printChar( (char)showingChar, 3 ); + display.updateDisplay(); + Serial.print( "Showing character '" ); + Serial.print( (char)showingChar ); + Serial.print( "' (0x" ); + Serial.print( hexUpper ); + Serial.print( hexLower ); + Serial.println( ")" ); + showingChar++; + if ( showingChar > '~' ) { + showingChar = '!'; + } + + }; // nowTime >= nextDisplayTime + +} diff --git a/examples/Example13_QuickTest.ino b/examples/Example13_QuickTest.ino new file mode 100644 index 0000000..f8b644e --- /dev/null +++ b/examples/Example13_QuickTest.ino @@ -0,0 +1,103 @@ +/*************************************************************** + * This is intended as a "quick functionality test" of the + * Spark-X Alphanumeric Displays (SparkFun SPX-16391, SPX-16425, + * SPX-16426, and SPX-16427). + * + * The sketch will illuminate one segment on each digit, with + * each digit showing a different segment, cycling through all + * 14 segments twice, then illuminating the colon and then the + * decimal, before pausing briefly with a blank display then + * repeating the process. + * + * By the way, the reason for having the four digits "out of + * step", so to speak, is that it proves that each is being + * independantly addressed. + * + * Note that as it stands, it is intended to test only one + * display unit at a time, with the default address on the + * unit. However, it can easily be expanded to relax these + * restrictions, and can also be modified for use as a + * "power-on self test" at the beginning of a more complex + * sketch. + * + * I wrote this for my own use, but have decided to release + * it as "user contributed" to the general community. + * + * Written by Clark Jones, and released as "beerware", as-is, + * with absolutely no guarantees. + */ + + #include + #include + + HT16K33 display; + + uint8_t segSequence[14]{ + // This is necessary because of the order that the segments + // are assigned letters -- it's easier for a human to view + // them and verify that all are working if they appear to + // "rotate". + 'A', // top + 'B', // upper right + 'C', // lower right + 'D', // bottom + 'E', // lower left + 'F', // upper left + 'J', // upper middle vertical + 'K', // upper right diagonal + 'I', // middle right horizontal + 'L', // lower right diagonal + 'M', // lower middle vertical + 'N', // lower left diagonal + 'G', // middle left horizontal + 'H' // upper left diagonal + }; + +int currStep; +unsigned long nextDisplayTime; + +void setup() { + Serial.begin(115200); + Serial.println("Qwiic Alphanumeric examples"); + Wire.begin(); //Join I2C bus + + //check if display will acknowledge + if (display.begin() == false) + { + Serial.println("Device did not acknowledge! Freezing."); + while(1); + } + Serial.println("Display acknowledged."); + + currStep = 0; + nextDisplayTime = 0; +}; // setup() + +void loop() { + unsigned long nowTime; + nowTime = millis(); + if ( nowTime >= nextDisplayTime ) { + nextDisplayTime = nowTime + 250; + display.clear(); + if ( currStep < 28 ) { + // Display segments + // Notice that these will "wrap around" on segSequence + display.illuminateSegment( segSequence[ currStep % 14 ], 0); + display.illuminateSegment( segSequence[ ( currStep + 1 ) % 14 ], 1 ); + display.illuminateSegment( segSequence[ ( currStep + 2 ) % 14 ], 2 ); + display.illuminateSegment( segSequence[ ( currStep + 3 ) % 14 ], 3 ); + } else if ( currStep == 28 ) { + display.colonOn(); + } else if ( currStep == 29 ) { + display.decimalOn(); + } else { + // Two things to notice: this generates a brief blank time + // and by setting currStep to -1 it will then get + // incremented to 0 + currStep = -1; + }; + display.updateDisplay(); + currStep++; + }; // nowTime >= nextDisplayTime + +}; // loop()