seven segment library for mbed

Dependencies:   mbed sseg

7segment library for mbed

Committer:
morecat_lab
Date:
Sun Dec 01 06:02:35 2013 +0000
Revision:
0:94af69b1b614
seven segment library for mbed ( came from 7segduino)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
morecat_lab 0:94af69b1b614 1 /*** Hello 7seg
morecat_lab 0:94af69b1b614 2
morecat_lab 0:94af69b1b614 3 7seg module logical_name LPC1114 PIN
morecat_lab 0:94af69b1b614 4 SEG-A(11) dp1 1
morecat_lab 0:94af69b1b614 5 SEG-B(7) dp2 2
morecat_lab 0:94af69b1b614 6 SEG-C(4) dp4 4
morecat_lab 0:94af69b1b614 7 SEG-D(2) dp26 (was dp5) 26
morecat_lab 0:94af69b1b614 8 SEG-E(1) dp6 6
morecat_lab 0:94af69b1b614 9 SEG-F(10) dp9 9
morecat_lab 0:94af69b1b614 10 SEG-G(5) dp10 10
morecat_lab 0:94af69b1b614 11 SEG-DP(3) dp11 11
morecat_lab 0:94af69b1b614 12
morecat_lab 0:94af69b1b614 13 DIG-1(12) dp13 13
morecat_lab 0:94af69b1b614 14 DIG-2 (9) dp17 17
morecat_lab 0:94af69b1b614 15 DIG-3 (8) dp18 18
morecat_lab 0:94af69b1b614 16 DIG-4 (6) dp25 25
morecat_lab 0:94af69b1b614 17
morecat_lab 0:94af69b1b614 18 */
morecat_lab 0:94af69b1b614 19
morecat_lab 0:94af69b1b614 20 #include "mbed.h"
morecat_lab 0:94af69b1b614 21 #include "Sseg.h"
morecat_lab 0:94af69b1b614 22
morecat_lab 0:94af69b1b614 23 Sseg mySseg = Sseg(dp1, dp2, dp4, dp26, dp6, dp9, dp10, dp11, dp13, dp17, dp18, dp25);
morecat_lab 0:94af69b1b614 24
morecat_lab 0:94af69b1b614 25 DigitalOut myled1(LED1);
morecat_lab 0:94af69b1b614 26 DigitalOut myled2(LED2);
morecat_lab 0:94af69b1b614 27
morecat_lab 0:94af69b1b614 28 char hello[] = {
morecat_lab 0:94af69b1b614 29 0x00,
morecat_lab 0:94af69b1b614 30 0x00,
morecat_lab 0:94af69b1b614 31 0x00,
morecat_lab 0:94af69b1b614 32 0x00,
morecat_lab 0:94af69b1b614 33 0x6e, // 0b01101110, // H
morecat_lab 0:94af69b1b614 34 0x9e, // 0b10011110, // E
morecat_lab 0:94af69b1b614 35 0x1c, // 0b00011100, // L
morecat_lab 0:94af69b1b614 36 0x1c, // 0b00011100, // L
morecat_lab 0:94af69b1b614 37 0x3a, // 0b00111010, // o
morecat_lab 0:94af69b1b614 38 0x00, // 0b00000000, //
morecat_lab 0:94af69b1b614 39 NUM_PAT_7, // 7
morecat_lab 0:94af69b1b614 40 0xb6, // 0b10110110, // S
morecat_lab 0:94af69b1b614 41 NUM_PAT_E, // E
morecat_lab 0:94af69b1b614 42 0xf6, // 0b11110110, // G
morecat_lab 0:94af69b1b614 43 0x01, // 0b00000001 // .
morecat_lab 0:94af69b1b614 44 };
morecat_lab 0:94af69b1b614 45
morecat_lab 0:94af69b1b614 46 #define OVERWRAP(a, x) (((x) < sizeof(a)) ? (a[(x)]) : a[((x) - sizeof(a))])
morecat_lab 0:94af69b1b614 47
morecat_lab 0:94af69b1b614 48 int main() {
morecat_lab 0:94af69b1b614 49 mySseg.setKcommon();
morecat_lab 0:94af69b1b614 50 mySseg.begin();
morecat_lab 0:94af69b1b614 51
morecat_lab 0:94af69b1b614 52 // mySseg.writeRawData(NUM_PAT_0, NUM_PAT_1, NUM_PAT_2, NUM_PAT_3);
morecat_lab 0:94af69b1b614 53 // mySseg.writeRawData(NUM_PAT_4, NUM_PAT_5, NUM_PAT_6, NUM_PAT_7);
morecat_lab 0:94af69b1b614 54 // mySseg.writeRawData(NUM_PAT_8, NUM_PAT_9, NUM_PAT_A, NUM_PAT_B);
morecat_lab 0:94af69b1b614 55 // mySseg.writeRawData(NUM_PAT_C, NUM_PAT_D, NUM_PAT_E, NUM_PAT_F);
morecat_lab 0:94af69b1b614 56
morecat_lab 0:94af69b1b614 57 // mySseg.writeRawData(0x01, 0x02, 0x04, 0x08);
morecat_lab 0:94af69b1b614 58 // mySseg.writeRawData(0x10, 0x20, 0x40, 0x80);
morecat_lab 0:94af69b1b614 59
morecat_lab 0:94af69b1b614 60 // mySseg.writeNum(1, 2, 0xa, 4);
morecat_lab 0:94af69b1b614 61
morecat_lab 0:94af69b1b614 62 myled1 = 1;
morecat_lab 0:94af69b1b614 63 myled2 = 0;
morecat_lab 0:94af69b1b614 64
morecat_lab 0:94af69b1b614 65 while(1) {
morecat_lab 0:94af69b1b614 66 for (int p = 0 ; p < sizeof(hello) ; p++) {
morecat_lab 0:94af69b1b614 67 myled1 = (myled1 == 0) ? 1 : 0;
morecat_lab 0:94af69b1b614 68 myled2 = (myled2 == 0) ? 1 : 0;
morecat_lab 0:94af69b1b614 69 mySseg.writeRawData(
morecat_lab 0:94af69b1b614 70 OVERWRAP(hello, p),
morecat_lab 0:94af69b1b614 71 OVERWRAP(hello, p+1),
morecat_lab 0:94af69b1b614 72 OVERWRAP(hello, p+2),
morecat_lab 0:94af69b1b614 73 OVERWRAP(hello, p+3));
morecat_lab 0:94af69b1b614 74
morecat_lab 0:94af69b1b614 75 mySseg.updateWithDelay(200);
morecat_lab 0:94af69b1b614 76 }
morecat_lab 0:94af69b1b614 77
morecat_lab 0:94af69b1b614 78 }
morecat_lab 0:94af69b1b614 79 }