DiplayApp library

Dependents:   mbed-os_Watson-IoT_ZXing_sample mbed-os_Watson-IoT_ZXing_sample GR-Boads_Camera_DisplayApp GR-Boads_Camera_DisplayApp ... more

For Windows PC

For Mac

Serial setting

You need to connect your PC and MicroUSB Connector(RZ/A1 Ch.0).

/media/uploads/dkato/usb0_and_button.jpg

Troubleshooting!

If your PC isn't Windows10, you need to install the specified driver from the below URL.
https://os.mbed.com/handbook/USBSerial

Unfortunately, since that is "Unsigned driver", you cannot install as is depending on your Windows version. Since the setting method is different for each PC, please search with "Unsigned driver" keyword on the search site.

トラブルシューティング!

Windows10以外ご使用の場合、ドライバのインストールが必要となります。下記サイトのからドライバーをダウンロードできます。
https://os.mbed.com/handbook/USBSerial

但し、「署名なしドライバ」となっていますので、お使いのWindowsバージョンによってはそのままインストールすることはできません。お使いのPC毎に設定方法が異なるため、検索サイトで「署名なしドライバ」で検索してください。

Files at this revision

API Documentation at this revision

Comitter:
dkato
Date:
Thu May 18 06:50:51 2017 +0000
Parent:
2:b7ffe5216cd7
Child:
4:3c46efbe6d21
Commit message:
Fix compiler warning.

Changed in this revision

DisplayApp.cpp Show annotated file Show diff for this revision Revisions of this file
DisplayApp.h Show annotated file Show diff for this revision Revisions of this file
--- a/DisplayApp.cpp	Fri Sep 16 10:26:16 2016 +0000
+++ b/DisplayApp.cpp	Thu May 18 06:50:51 2017 +0000
@@ -68,7 +68,9 @@
                     if ((pos_x != pos_x_wk) || (pos_y != pos_wk)) {
                         pos_x = pos_x_wk;
                         pos_y = pos_wk;
-                        event.call();
+                        if (event) {
+                            event.call();
+                        }
                     }
                 } else {
                     pos_seq = POS_SEQ_INIT;
@@ -82,11 +84,9 @@
     }
 }
 
-/* static */void DisplayApp::display_app_process_static(void const * arg) {
-    ((DisplayApp *)arg)->display_app_process();
-}
-
-DisplayApp::DisplayApp(osPriority tsk_pri, osPriority init_pri, uint32_t stack_size) : change_pri(tsk_pri), displayThread(DisplayApp::display_app_process_static, (void *)this, init_pri, stack_size) {
+DisplayApp::DisplayApp(osPriority tsk_pri, osPriority init_pri, uint32_t stack_size) : change_pri(tsk_pri), displayThread(init_pri, stack_size) {
+//    displayThread.start(this, &DisplayApp::display_app_process);
+    displayThread.start(callback(this, &DisplayApp::display_app_process));
 }
 
 void DisplayApp::SendHeader(uint32_t size) {
@@ -198,6 +198,10 @@
     return wk_idx;
 };
 
+void DisplayApp::SetCallback(Callback<void()> func) {
+    event = func;
+}
+
 int DisplayApp::SendJpeg(uint8_t * buf, uint32_t size) {
     if (pPcApp == NULL) {
         return 0;
--- a/DisplayApp.h	Fri Sep 16 10:26:16 2016 +0000
+++ b/DisplayApp.h	Thu May 18 06:50:51 2017 +0000
@@ -47,25 +47,32 @@
      */
     int SendJpeg(uint8_t * buf, uint32_t size);
 
+    /** Attach a function to call whenever a serial interrupt is generated
+     *
+     * @param func A pointer to a void function, or 0 to set as none
+     */
+    void SetCallback(Callback<void()> func);
+
     /** Attach a function to call when touch panel int
      *
-     *  @param fptr A pointer to a void function, or 0 to set as none
+     * @param obj pointer to the object to call the member function on
+     * @param method pointer to the member function to be called
      */
-    void SetCallback(void (*fptr)(void)) {
-        if(fptr != NULL) {
-            event.attach(fptr);
-        }
+    template<typename T>
+    void SetCallback(T* obj, void (T::*method)()) {
+        // Underlying call thread safe
+        SetCallback(callback(obj, method));
     }
+
     /** Attach a member function to call when touch panel int
      *
-     *  @param tptr pointer to the object to call the member function on
-     *  @param mptr pointer to the member function to be called
+     * @param obj pointer to the object to call the member function on
+     * @param method pointer to the member function to be called
      */
     template<typename T>
-    void SetCallback(T* tptr, void (T::*mptr)(void)) {
-        if((mptr != NULL) && (tptr != NULL)) {
-            event.attach(tptr, mptr);
-        }
+    void SetCallback(T* obj, void (*method)(T*)) {
+        // Underlying call thread safe
+        SetCallback(callback(obj, method));
     }
     /** Get the maximum number of simultaneous touches 
      * 
@@ -95,17 +102,16 @@
         POS_SEQ_END,
     } pos_seq_t;
 
+    osPriority change_pri;
     Thread displayThread;
     USBSerial * pPcApp;
     pos_seq_t pos_seq;
     int pos_x;
     int pos_y;
-    osPriority change_pri;
-    FunctionPointer event;
+    Callback<void()> event;
 
     void touch_int_callback(void);
     void display_app_process();
-    static void display_app_process_static(void const * arg);
     void SendHeader(uint32_t size);
     void SendData(uint8_t * buf, uint32_t size);
 };