テスト

Dependencies:   mbed-os-lychee DisplayApp

Files at this revision

API Documentation at this revision

Comitter:
kobukai0415
Date:
Tue Dec 04 00:32:52 2018 +0000
Commit message:
???

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
DisplayApp.lib Show annotated file Show diff for this revision Revisions of this file
README.md 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
mbed-gr-libs.lib Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Tue Dec 04 00:32:52 2018 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DisplayApp.lib	Tue Dec 04 00:32:52 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/kobukai0415/code/DisplayApp/#4f51598a41e7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Tue Dec 04 00:32:52 2018 +0000
@@ -0,0 +1,57 @@
+# Getting started with Blinky on mbed OS
+
+This guide reviews the steps required to get Blinky working on an mbed OS platform.
+
+Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
+
+## Import the example application
+
+From the command-line, import the example:
+
+```
+mbed import mbed-os-example-blinky
+cd mbed-os-example-blinky
+```
+
+### Now compile
+
+Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5:
+
+```
+mbed compile -m K64F -t ARM
+```
+
+Your PC may take a few minutes to compile your code. At the end, you see the following result:
+
+```
+[snip]
++----------------------------+-------+-------+------+
+| Module                     | .text | .data | .bss |
++----------------------------+-------+-------+------+
+| Misc                       | 13939 |    24 | 1372 |
+| core/hal                   | 16993 |    96 |  296 |
+| core/rtos                  |  7384 |    92 | 4204 |
+| features/FEATURE_IPV4      |    80 |     0 |  176 |
+| frameworks/greentea-client |  1830 |    60 |   44 |
+| frameworks/utest           |  2392 |   512 |  292 |
+| Subtotals                  | 42618 |   784 | 6384 |
++----------------------------+-------+-------+------+
+Allocated Heap: unknown
+Allocated Stack: unknown
+Total Static RAM memory (data + bss): 7168 bytes
+Total RAM memory (data + bss + heap + stack): 7168 bytes
+Total Flash memory (text + data + misc): 43402 bytes
+Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin
+```
+
+### Program your board
+
+1. Connect your mbed device to the computer over USB.
+1. Copy the binary file to the mbed device.
+1. Press the reset button to start the program.
+
+The LED on your platform turns on and off.
+
+## Troubleshooting
+
+If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 04 00:32:52 2018 +0000
@@ -0,0 +1,285 @@
+
+#include "mbed.h"
+#include "DisplayApp.h"
+#include "EasyAttach_CameraAndLCD.h"
+#include "JPEG_Converter.h"
+#include "dcache-control.h"
+#include "DisplayApp.h"
+#include "FATFileSystem.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+void DisplayApp::display_app_process() {
+    int data;
+    int pos_x_wk;
+    int pos_wk;
+    int flag;
+    
+    int blink_on = 0;
+    int blink_flag = 0;
+    
+    while (!PcApp.configured()) {
+        Thread::wait(100);
+    }
+
+    while (1) {
+        
+        /*受信処理/**/
+        if (PcApp.readable()) {
+            data = PcApp.getc();
+            if (data == '4' or data == '5') {                
+                flag = 1;   //走行処理
+                blink_on = 1;
+             
+             /*   
+            } else if (data == '1') {
+                flag = 3;   //撮影処理
+                                
+            } else if (data == '3') {
+                flag = 4;   //音声出力処理
+                               
+            } else if (data == '2') {
+                flag = 5;   //ライト点灯処理                
+            }
+            */
+            
+        /*走行処理*/
+            if(data == '4'){
+                    led1 = !led1;
+            }else if (data == '5'){
+                    blink_flag = 1;
+                if(blink_on == 1 and blink_flag == 1){
+                    led2 = !led2;
+                }
+                wait(0.3);
+        }
+            
+                
+                
+#if 0            
+        } else if (pos_seq == POS_SEQ_Y) {
+            pos_seq = POS_SEQ_Y_POS;
+            pos_wk = 0;
+        } else {
+            pos_seq = POS_SEQ_INIT;
+        }
+    } 
+    
+    else if (data == '-') {
+        if (pos_seq == POS_SEQ_X_POS) {
+            pos_seq = POS_SEQ_X_M;
+        } else if (pos_seq == POS_SEQ_Y_POS) {
+            pos_seq = POS_SEQ_Y_M;
+        } else {
+            pos_seq = POS_SEQ_INIT;
+        }
+            } else if ((data >= '0') && (data <= '9')) {
+                if ((pos_seq == POS_SEQ_X_POS) || (pos_seq == POS_SEQ_Y_POS)) {
+                    pos_wk = (pos_wk * 10) + (data - '0');
+                } else if ((pos_seq == POS_SEQ_X_M) && (data == '1')) {
+                    pos_wk = -1;
+                } else if ((pos_seq == POS_SEQ_Y_M) && (data == '1')) {
+                    pos_wk = -1;
+                } else {
+                    pos_seq = POS_SEQ_INIT;
+                }
+            } else if (data == ',') {
+                if ((pos_seq == POS_SEQ_X_POS) || (pos_seq == POS_SEQ_X_M)) {
+                    pos_x_wk = pos_wk;
+                    pos_seq = POS_SEQ_C;
+                } else {
+                    pos_seq = POS_SEQ_INIT;
+                }
+            } else if (data == '}') {
+                if ((pos_seq == POS_SEQ_Y_POS) || (pos_seq == POS_SEQ_Y_M)) {
+                    pos_seq = POS_SEQ_END;
+                    if ((pos_x != pos_x_wk) || (pos_y != pos_wk)) {
+                        pos_x = pos_x_wk;
+                        pos_y = pos_wk;
+                        if (event) {
+                            event.call();
+                        }
+                    }
+                } else {
+                    pos_seq = POS_SEQ_INIT;
+                }
+            } else {
+                pos_seq = POS_SEQ_INIT;
+            }
+        } else {
+            Thread::wait(10);
+        }
+    }
+#endif
+}
+
+void DisplayApp::DisplayApp(osPriority tsk_pri, uint32_t stack_size) : 
+  PcApp(0x1f00, 0x2012, 0x0001, false), displayThread(tsk_pri, stack_size) {
+    displayThread.start(callback(this, &DisplayApp::display_app_process));
+}
+
+void DisplayApp::SendHeader(uint32_t size) {
+    uint8_t headder_data[12] = {0xFF,0xFF,0xAA,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+    headder_data[8]  = (uint8_t)((uint32_t)size >> 0);
+    headder_data[9]  = (uint8_t)((uint32_t)size >> 8);
+    headder_data[10] = (uint8_t)((uint32_t)size >> 16);
+    headder_data[11] = (uint8_t)((uint32_t)size >> 24);
+    PcApp.writeBlock((uint8_t *)headder_data, sizeof(headder_data));
+}
+
+void DisplayApp::SendData(uint8_t * buf, uint32_t size) {
+    int send_size;
+    int send_index = 0;
+
+    while (size > 0) {
+        if (size > MAX_PACKET_SIZE_EPBULK) {
+            send_size = MAX_PACKET_SIZE_EPBULK;
+        } else {
+            send_size = size;
+        }
+        PcApp.writeBlock(&buf[send_index], send_size);
+        send_index += send_size;
+        size -= send_size;
+    }
+}
+
+int DisplayApp::SendRgb888(uint8_t * buf, uint32_t pic_width, uint32_t pic_height) {
+    uint32_t offset_size = 54;
+    uint32_t buf_stride = (((pic_width * 4u) + 31u) & ~31u);
+    uint32_t pic_size = buf_stride * pic_height;
+    uint32_t total_size = pic_size + offset_size;
+    uint8_t wk_bitmap_buf[54];
+    int wk_idx = 0;
+
+    if (!PcApp.configured()) {
+        return 0;
+    }
+    if (PcApp._putc(0) == 0) {  // terminal connect check
+        return 0;
+    }
+    SendHeader(total_size);
+
+    /* BITMAPFILEHEADER */
+    wk_bitmap_buf[wk_idx++] = 'B';
+    wk_bitmap_buf[wk_idx++] = 'M';
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(total_size >> 0);   /* bfSize */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(total_size >> 8);   /* bfSize */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(total_size >> 16);  /* bfSize */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(total_size >> 24);  /* bfSize */
+    wk_bitmap_buf[wk_idx++] = 0;  /* bfReserved1 */
+    wk_bitmap_buf[wk_idx++] = 0;  /* bfReserved1 */
+    wk_bitmap_buf[wk_idx++] = 0;  /* bfReserved2 */
+    wk_bitmap_buf[wk_idx++] = 0;  /* bfReserved2 */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(offset_size >> 0);   /* bfOffBits */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(offset_size >> 8);   /* bfOffBits */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(offset_size >> 16);  /* bfOffBits */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(offset_size >> 24);  /* bfOffBits */
+
+    /* BITMAPINFOHEADER */
+    wk_bitmap_buf[wk_idx++] = 40; /* biSize */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biSize */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biSize */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biSize */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(pic_width >> 0);    /* biWidth */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(pic_width >> 8);    /* biWidth */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(pic_width >> 16);   /* biWidth */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(pic_width >> 24);   /* biWidth */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)((-(long)pic_height) >> 0);   /* biHeight */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)((-(long)pic_height) >> 8);   /* biHeight */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)((-(long)pic_height) >> 16);  /* biHeight */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)((-(long)pic_height) >> 24);  /* biHeight */
+    wk_bitmap_buf[wk_idx++] = 1;  /* biPlanes */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biPlanes */
+    wk_bitmap_buf[wk_idx++] = 32; /* biBitCount */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biBitCount */
+
+    wk_bitmap_buf[wk_idx++] = 0;  /* biCopmression */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biCopmression */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biCopmression */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biCopmression */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(pic_size >> 0);   /* biSizeImage */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(pic_size >> 8);   /* biSizeImage */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(pic_size >> 16);  /* biSizeImage */
+    wk_bitmap_buf[wk_idx++] = (uint8_t)(pic_size >> 24);  /* biSizeImage */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biXPixPerMeter */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biXPixPerMeter */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biXPixPerMeter */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biXPixPerMeter */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biYPixPerMeter */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biYPixPerMeter */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biYPixPerMeter */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biYPixPerMeter */
+
+    wk_bitmap_buf[wk_idx++] = 0;  /* biClrUsed */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biClrUsed */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biClrUsed */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biClrUsed */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biCirImportant */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biCirImportant */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biCirImportant */
+    wk_bitmap_buf[wk_idx++] = 0;  /* biCirImportant */
+    PcApp.writeBlock(wk_bitmap_buf, wk_idx);
+
+    SendData(buf, pic_size);
+    wk_idx += pic_size;
+
+    return wk_idx;
+};
+
+void DisplayApp::SetCallback(Callback<void()> func) {
+    event = func;
+}
+
+int DisplayApp::SendJpeg(uint8_t * buf, uint32_t size) {
+    if (!PcApp.configured()) {
+        return 0;
+    }
+    if (PcApp._putc(0) == 0) {  // terminal connect check
+        return 0;
+    }
+    
+    SendHeader(size);
+    SendData(buf, size);
+
+    return size;
+}
+
+int DisplayApp::GetMaxTouchNum(void) {
+    return 1;
+}
+
+int DisplayApp::GetCoordinates(int touch_buff_num, touch_pos_t * p_touch) {
+    touch_pos_t * wk_touch;
+    int count = 0;
+    int x = pos_x;
+    int y = pos_y;
+
+    if (touch_buff_num > 0) {
+        count = 0;
+        wk_touch        = &p_touch[0];
+        wk_touch->valid = false;
+        wk_touch->x     = 0;
+        wk_touch->y     = 0;
+        if (x >= 0) {
+            count = 1;
+            wk_touch->valid = true;
+            wk_touch->x = (uint32_t)x;
+        }
+        if (y >= 0) {
+            count = 1;
+            wk_touch->valid = true;
+            wk_touch->y = (uint32_t)y;
+        }
+    }
+
+    return count;
+}
+
+char DisplayApp::Getgetc()
+{
+    return PcApp.getc();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-gr-libs.lib	Tue Dec 04 00:32:52 2018 +0000
@@ -0,0 +1,1 @@
+https://github.com/d-kato/mbed-gr-libs/#18632c50ffce8a6311ee3f55ec8ae250117d0ff7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Tue Dec 04 00:32:52 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/dkato/code/mbed-os-lychee/#f782d9c66c49