Yoshitaka Kuwata
/
7segMbed
seven segment library for mbed
7segment library for mbed
Revision 0:94af69b1b614, committed 2013-12-01
- Comitter:
- morecat_lab
- Date:
- Sun Dec 01 06:02:35 2013 +0000
- Commit message:
- seven segment library for mbed ( came from 7segduino)
Changed in this revision
diff -r 000000000000 -r 94af69b1b614 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Dec 01 06:02:35 2013 +0000 @@ -0,0 +1,79 @@ +/*** Hello 7seg + + 7seg module logical_name LPC1114 PIN + SEG-A(11) dp1 1 + SEG-B(7) dp2 2 + SEG-C(4) dp4 4 + SEG-D(2) dp26 (was dp5) 26 + SEG-E(1) dp6 6 + SEG-F(10) dp9 9 + SEG-G(5) dp10 10 + SEG-DP(3) dp11 11 + + DIG-1(12) dp13 13 + DIG-2 (9) dp17 17 + DIG-3 (8) dp18 18 + DIG-4 (6) dp25 25 + + */ + +#include "mbed.h" +#include "Sseg.h" + +Sseg mySseg = Sseg(dp1, dp2, dp4, dp26, dp6, dp9, dp10, dp11, dp13, dp17, dp18, dp25); + +DigitalOut myled1(LED1); +DigitalOut myled2(LED2); + +char hello[] = { + 0x00, + 0x00, + 0x00, + 0x00, + 0x6e, // 0b01101110, // H + 0x9e, // 0b10011110, // E + 0x1c, // 0b00011100, // L + 0x1c, // 0b00011100, // L + 0x3a, // 0b00111010, // o + 0x00, // 0b00000000, // + NUM_PAT_7, // 7 + 0xb6, // 0b10110110, // S + NUM_PAT_E, // E + 0xf6, // 0b11110110, // G + 0x01, // 0b00000001 // . +}; + +#define OVERWRAP(a, x) (((x) < sizeof(a)) ? (a[(x)]) : a[((x) - sizeof(a))]) + +int main() { + mySseg.setKcommon(); + mySseg.begin(); + + // mySseg.writeRawData(NUM_PAT_0, NUM_PAT_1, NUM_PAT_2, NUM_PAT_3); + // mySseg.writeRawData(NUM_PAT_4, NUM_PAT_5, NUM_PAT_6, NUM_PAT_7); + // mySseg.writeRawData(NUM_PAT_8, NUM_PAT_9, NUM_PAT_A, NUM_PAT_B); + // mySseg.writeRawData(NUM_PAT_C, NUM_PAT_D, NUM_PAT_E, NUM_PAT_F); + + // mySseg.writeRawData(0x01, 0x02, 0x04, 0x08); + // mySseg.writeRawData(0x10, 0x20, 0x40, 0x80); + + // mySseg.writeNum(1, 2, 0xa, 4); + + myled1 = 1; + myled2 = 0; + + while(1) { + for (int p = 0 ; p < sizeof(hello) ; p++) { + myled1 = (myled1 == 0) ? 1 : 0; + myled2 = (myled2 == 0) ? 1 : 0; + mySseg.writeRawData( + OVERWRAP(hello, p), + OVERWRAP(hello, p+1), + OVERWRAP(hello, p+2), + OVERWRAP(hello, p+3)); + + mySseg.updateWithDelay(200); + } + + } +}
diff -r 000000000000 -r 94af69b1b614 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Dec 01 06:02:35 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file
diff -r 000000000000 -r 94af69b1b614 sseg.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sseg.lib Sun Dec 01 06:02:35 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/morecat_lab/code/sseg/#6bf4ee8ee342