![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Labmbed device drivers
Diff: main.cpp
- Revision:
- 1:04e1ee8faa04
- Parent:
- 0:416329806e55
- Child:
- 2:caa0e6b2b436
--- a/main.cpp Wed Jan 11 11:19:03 2017 +0000 +++ b/main.cpp Wed Jan 11 17:03:19 2017 +0000 @@ -19,7 +19,7 @@ } void setleds(int ledall) { - led_bits = ledall; + led_bits = ledall; // update global LED status spi.write((led_bits & 0x03ff) | ((led_bits & 0xa800) >> 1) | ((led_bits & 0x5400) << 1)); lat = 1; // latch pulse start lat = 0; // latch pulse end @@ -30,9 +30,9 @@ ledno = (8 - ledno) * 2; // offset of led state in 'led_bits' ledstate = ledstate & 0x0003; // limit led state ledstate = ledstate << ledno; - int statemask = 0x0003; - statemask = ((statemask << ledno) ^ 0xffff); - led_bits = ((led_bits & statemask) | ledstate); + int statemask = 0x0003; // mask used to clear led state + statemask = ((statemask << ledno) ^ 0xffff); // shift and invert statemask + led_bits = ((led_bits & statemask) | ledstate); // clear and set led state setleds(led_bits); } @@ -80,26 +80,12 @@ initleds(); while(1) { - - setled (5,2); - setled (6,1); - setled (7,3); - - int led = readled(6); - lcd.printf(" \n"); - lcd.printf("LED6 = %d\n", led); - wait(3); - - setleds(0x5555); - led = readleds(); - lcd.printf(" \n"); - lcd.printf("LEDs = %d\n", led); - wait(3); - - float temp = readtemp(); - lcd.printf(" \n"); - lcd.printf("Temp = %f\n", temp); - wait(3); - + int a,b; + for (b = 0; b < 4; b++ ) { + for (a = 1; a < 17; a++ ) { + setled (a,b); + wait(.5); + } + } } }