see https://developer.mbed.org/users/okini3939/notebook/graphic-poi/
Dependencies: IAP RAM_DISK USBDevice mbed
Diff: main.cpp
- Revision:
- 2:d50445fa62da
- Parent:
- 0:49512863ec9b
--- a/main.cpp Thu Dec 01 02:01:22 2016 +0000 +++ b/main.cpp Thu Dec 01 06:31:12 2016 +0000 @@ -21,7 +21,7 @@ DigitalIn button(P0_1); SPI spi(P0_21, P0_22, P1_15); -void dotsStar (int *buf, int num) { +void dotStar (int *buf, int num) { int i; // start frame @@ -41,13 +41,16 @@ } } -void dotsStar_off () { +void dotStar_off () { int i; for (i = 0; i < 4; i ++) { spi.write(0); } - for (i = 0; i < LED_NUM * 4; i ++) { + for (i = 0; i < LED_NUM; i ++) { + spi.write((7<<5) | LED_GLOBAL); + spi.write(0); + spi.write(0); spi.write(0); } for (i = 0; i < 4; i ++) { @@ -73,8 +76,12 @@ } a += 3; } + for (; x < LED_NUM; x ++) { + led_buf[x] = 0; + } + a = ((a + 3) / 4) * 4; // padding DBG("%d %d %d/%d\r\n", a, y, header->width, header->height); - dotsStar(led_buf, header->width < LED_NUM ? header->width : LED_NUM); + dotStar(led_buf, LED_NUM); y ++; if (y >= header->height) { y = 0; @@ -111,7 +118,7 @@ c = ((i + color) % 7) + 1; led_buf[i] = (c & 4 ? 0xff0000 : 0) | (c & 2 ? 0xff00 : 0) | (c & 1 ? 0xff : 0); } - dotsStar(led_buf, LED_NUM); + dotStar(led_buf, LED_NUM); led = !led; wait_ms(500); @@ -133,7 +140,7 @@ wait_ms(10); spi.frequency(LED_FREQ); - dotsStar_off(); + dotStar_off(); if (usb_vbus) { DBG("usb\r\n");