We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 447dcff commit 4542b5aCopy full SHA for 4542b5a
pio/seven_segment/pio_7_segment_library/7_segment_lib.c
@@ -30,12 +30,15 @@ static const uint8_t segments[] = {
30
};
31
32
33
-// converts an integer into a 32-bit word representing up to four 7-segment digits
+// Simple example of how to convert a positive integer into a 32-bit word
34
+// representing up to four 7-segment digits. Could be extended to handle
35
+// negative numbers.
36
//
37
uint32_t int_to_seven_segment (int num) {
38
uint32_t word = 0;
- if (num > 9999) {
- // argument exceeds 4 digits: display an 'E' symbol
39
+ if (num > 9999 || num < 0) {
40
+ // number out of range, display 'E' symbol
41
+ // EDBGACF.
42
word = 0b11011010
43
} else {
44
if (num == 0) {
0 commit comments