Created
September 22, 2011 06:53
-
-
Save schappim/1234206 to your computer and use it in GitHub Desktop.
Digit Shield Example Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Display the value 123: | |
DigitShield.setValue(123); | |
// Display the value 64 with leading zeros: | |
DigitShield.setLeadingZeros(true); | |
DigitShield.setValue(64); | |
// Display the value of pi with 2 decimal places | |
DigitShield.setPrecision(2); | |
DigitShield.setValue(3.14159265); | |
// Display the value 0.012. Floating point values less than 1.0 will have a zero before the decimal point. | |
DigitShield.setPrecision(3); | |
DigitShield.setValue(.012); | |
// Display the value 43 with leading zeros and one decimal place. | |
DigitShield.setLeadingZeros(true); | |
DigitShield.setPrecision(1); | |
DigitShield.setValue(43); | |
// Access the digits and decimal points directly. Digits are numbered 1-4 from left to right. For example, to display the score of a game. | |
DigitShield.setDigit(1, 7); | |
DigitShield.setDigit(4, 3); | |
DigitShield.setDecimalPoint(2, true); | |
// Error conditions: if the value cannot be displayed because it will not fit on the display, this error is indicated by lighting all 4 decimal points. The following cases are all error conditions: | |
DigitShield.setValue(10000); // too large | |
DigitShield.setPrecision(3); | |
DigitShield.setValue(83.1415); // not enough room | |
DigitShield.setValue(-32); // cannot display negative numbers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment