DiplayApp library

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DisplayApp.h Source File

DisplayApp.h

Go to the documentation of this file.
00001 /**************************************************************************//**
00002 * @file          DisplayApp.h
00003 * @brief         DisplayApp API
00004 ******************************************************************************/
00005 
00006 #ifndef DISPLAY_APP_H
00007 #define DISPLAY_APP_H
00008 
00009 #include "mbed.h"
00010 #include "rtos.h"
00011 #include "USBSerial.h"
00012 
00013 /** A class to communicate a DisplayApp
00014  *
00015  */
00016 class DisplayApp {
00017 public:
00018     /** Touch position structure */
00019     typedef struct {
00020         uint32_t x;      /**< The position of the x-coordinate. */
00021         uint32_t y;      /**< The position of the y-coordinate. */
00022         bool     valid;  /**< Whether a valid data.. */
00023     } touch_pos_t;
00024 
00025     /** Constructor: Initializes DisplayApp.
00026      *
00027      * @param   tsk_pri        Priority of the thread function. (default: osPriorityNormal).
00028      * @param   init_pri       Priority of before the USB is connected. (default: osPriorityLow).
00029      * @param   stack_size     stack size (in bytes) requirements for the thread function. (default: 2048).
00030      */
00031     DisplayApp(osPriority tsk_pri = osPriorityNormal, uint32_t stack_size = 2048);
00032 
00033     /** Send RGB888 data
00034      *
00035      * @param buf data buffer address
00036      * @param pic_width picture width
00037      * @param pic_height picture height
00038      * @return send data size
00039      */
00040     int SendRgb888(uint8_t * buf, uint32_t pic_width, uint32_t pic_height);
00041 
00042     /** Send JPEG data
00043      *
00044      * @param buf data buffer address
00045      * @param size data size
00046      * @return send data size
00047      */
00048     int SendJpeg(uint8_t * buf, uint32_t size);
00049 
00050     /** Attach a function to call whenever a serial interrupt is generated
00051      *
00052      * @param func A pointer to a void function, or 0 to set as none
00053      */
00054     void SetCallback(Callback<void()> func);
00055 
00056     /** Attach a function to call when touch panel int
00057      *
00058      * @param obj pointer to the object to call the member function on
00059      * @param method pointer to the member function to be called
00060      */
00061     template<typename T>
00062     void SetCallback(T* obj, void (T::*method)()) {
00063         // Underlying call thread safe
00064         SetCallback(callback(obj, method));
00065     }
00066 
00067     /** Attach a member function to call when touch panel int
00068      *
00069      * @param obj pointer to the object to call the member function on
00070      * @param method pointer to the member function to be called
00071      */
00072     template<typename T>
00073     void SetCallback(T* obj, void (*method)(T*)) {
00074         // Underlying call thread safe
00075         SetCallback(callback(obj, method));
00076     }
00077     /** Get the maximum number of simultaneous touches 
00078      * 
00079      * @return The maximum number of simultaneous touches.
00080      */
00081     int GetMaxTouchNum(void);
00082 
00083    /** Get the coordinates
00084      *
00085      * @param touch_buff_num The number of structure p_touch.
00086      * @param p_touch Touch position information.
00087      * @return The number of touch points.
00088      */
00089     int GetCoordinates(int touch_buff_num, touch_pos_t * p_touch);
00090 
00091 private:
00092     typedef enum {
00093         POS_SEQ_INIT,
00094         POS_SEQ_START,
00095         POS_SEQ_X,
00096         POS_SEQ_X_POS,
00097         POS_SEQ_X_M,
00098         POS_SEQ_C,
00099         POS_SEQ_Y,
00100         POS_SEQ_Y_POS,
00101         POS_SEQ_Y_M,
00102         POS_SEQ_END,
00103     } pos_seq_t;
00104 
00105     USBSerial PcApp;
00106     Thread displayThread;
00107     pos_seq_t pos_seq;
00108     int pos_x;
00109     int pos_y;
00110     Callback<void()> event;
00111 
00112     void touch_int_callback(void);
00113     void display_app_process();
00114     void SendHeader(uint32_t size);
00115     void SendData(uint8_t * buf, uint32_t size);
00116 };
00117 #endif