see https://developer.mbed.org/users/okini3939/notebook/graphic-poi/

Dependencies:   IAP RAM_DISK USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
okini3939
Date:
Thu Dec 01 06:31:12 2016 +0000
Parent:
1:dc6da812295a
Commit message:
fix padding bmp;

Changed in this revision

RAM_DISK.lib Show annotated file Show diff for this revision Revisions of this file
file.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/RAM_DISK.lib	Thu Dec 01 02:01:22 2016 +0000
+++ b/RAM_DISK.lib	Thu Dec 01 06:31:12 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/okini3939/code/RAM_DISK/#69984d40fc4b
+https://developer.mbed.org/users/okini3939/code/RAM_DISK/#5b6b3320c4f4
--- a/file.cpp	Thu Dec 01 02:01:22 2016 +0000
+++ b/file.cpp	Thu Dec 01 06:31:12 2016 +0000
@@ -3,8 +3,6 @@
 #include "IAP.h"
 #include "file.h"
 
-//http://www.umekkii.jp/data/computer/file_format/bitmap.cgi
-
 //USBMSD_Ram msd;
 IAP iap;
 extern DigitalOut led;
@@ -15,7 +13,7 @@
 int count = 0;
 int sector = 0;
 
-int parseBmp (const uint8_t *buf) {
+int parseBmp (const uint8_t *buf, int len) {
     int i, n = 0;
 
     if (modeBmp == 0) {
@@ -39,10 +37,10 @@
         led = 0;
         __disable_irq();
         iap.prepare(FLASH_SECTOR + sector, FLASH_SECTOR + sector);
-        iap.write((char*)buf, sector_start_adress[FLASH_SECTOR + sector] + 512 * count, 512);
+        iap.write((char*)buf, sector_start_adress[FLASH_SECTOR + sector] + 512 * count, len);
         __enable_irq();
-        count ++;
-        filesize -= 512;
+        count += len / 512;
+        filesize -= len;
 
         if (filesize <= 0 || count >= (FLASH_SECTOR_SIZE / 512)) {
             modeBmp = 0;
@@ -57,7 +55,7 @@
     return 0;
 }
 
-void parseFat(int sector, const uint8_t *buf) {
+void parseFat(int sector, const uint8_t *buf, int len) {
     int i;
 
     if (sector == 2) {
@@ -75,7 +73,7 @@
     if (sector > 2) {
         // data
         if (parseSector && sector >= parseSector) {
-            if (parseBmp(buf)) {
+            if (parseBmp(buf, len)) {
                 parseSector = 0;
             }
         } else {
--- 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");