テスト

Dependencies:   DisplayApp_Base

Dependents:   LED

Committer:
dkato
Date:
Thu Sep 15 02:58:33 2016 +0000
Revision:
0:13c1f522bbef
Child:
2:b7ffe5216cd7
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:13c1f522bbef 1 /**************************************************************************//**
dkato 0:13c1f522bbef 2 * @file DisplayApp.h
dkato 0:13c1f522bbef 3 * @brief DisplayApp API
dkato 0:13c1f522bbef 4 ******************************************************************************/
dkato 0:13c1f522bbef 5
dkato 0:13c1f522bbef 6 #ifndef DISPLAY_APP_H
dkato 0:13c1f522bbef 7 #define DISPLAY_APP_H
dkato 0:13c1f522bbef 8
dkato 0:13c1f522bbef 9 #include "mbed.h"
dkato 0:13c1f522bbef 10 #include "rtos.h"
dkato 0:13c1f522bbef 11 #include "USBSerial.h"
dkato 0:13c1f522bbef 12
dkato 0:13c1f522bbef 13 /** A class to communicate a DisplayApp
dkato 0:13c1f522bbef 14 *
dkato 0:13c1f522bbef 15 */
dkato 0:13c1f522bbef 16 class DisplayApp {
dkato 0:13c1f522bbef 17 public:
dkato 0:13c1f522bbef 18 /** Touch position structure */
dkato 0:13c1f522bbef 19 typedef struct {
dkato 0:13c1f522bbef 20 uint32_t x; /**< The position of the x-coordinate. */
dkato 0:13c1f522bbef 21 uint32_t y; /**< The position of the y-coordinate. */
dkato 0:13c1f522bbef 22 bool valid; /**< Whether a valid data.. */
dkato 0:13c1f522bbef 23 } touch_pos_t;
dkato 0:13c1f522bbef 24
dkato 0:13c1f522bbef 25 /** Constructor: Initializes DisplayApp.
dkato 0:13c1f522bbef 26 *
dkato 0:13c1f522bbef 27 */
dkato 0:13c1f522bbef 28 DisplayApp();
dkato 0:13c1f522bbef 29
dkato 0:13c1f522bbef 30 /** Send RGB888 data
dkato 0:13c1f522bbef 31 *
dkato 0:13c1f522bbef 32 * @param buf data buffer address
dkato 0:13c1f522bbef 33 * @param pic_width picture width
dkato 0:13c1f522bbef 34 * @param pic_height picture height
dkato 0:13c1f522bbef 35 * @return send data size
dkato 0:13c1f522bbef 36 */
dkato 0:13c1f522bbef 37 int SendRgb888(uint8_t * buf, uint32_t pic_width, uint32_t pic_height);
dkato 0:13c1f522bbef 38
dkato 0:13c1f522bbef 39 /** Send JPEG data
dkato 0:13c1f522bbef 40 *
dkato 0:13c1f522bbef 41 * @param buf data buffer address
dkato 0:13c1f522bbef 42 * @param size data size
dkato 0:13c1f522bbef 43 * @return send data size
dkato 0:13c1f522bbef 44 */
dkato 0:13c1f522bbef 45 int SendJpeg(uint8_t * buf, uint32_t size);
dkato 0:13c1f522bbef 46
dkato 0:13c1f522bbef 47 /** Attach a function to call when touch panel int
dkato 0:13c1f522bbef 48 *
dkato 0:13c1f522bbef 49 * @param fptr A pointer to a void function, or 0 to set as none
dkato 0:13c1f522bbef 50 */
dkato 0:13c1f522bbef 51 void SetCallback(void (*fptr)(void)) {
dkato 0:13c1f522bbef 52 if(fptr != NULL) {
dkato 0:13c1f522bbef 53 event.attach(fptr);
dkato 0:13c1f522bbef 54 }
dkato 0:13c1f522bbef 55 }
dkato 0:13c1f522bbef 56 /** Attach a member function to call when touch panel int
dkato 0:13c1f522bbef 57 *
dkato 0:13c1f522bbef 58 * @param tptr pointer to the object to call the member function on
dkato 0:13c1f522bbef 59 * @param mptr pointer to the member function to be called
dkato 0:13c1f522bbef 60 */
dkato 0:13c1f522bbef 61 template<typename T>
dkato 0:13c1f522bbef 62 void SetCallback(T* tptr, void (T::*mptr)(void)) {
dkato 0:13c1f522bbef 63 if((mptr != NULL) && (tptr != NULL)) {
dkato 0:13c1f522bbef 64 event.attach(tptr, mptr);
dkato 0:13c1f522bbef 65 }
dkato 0:13c1f522bbef 66 }
dkato 0:13c1f522bbef 67 /** Get the maximum number of simultaneous touches
dkato 0:13c1f522bbef 68 *
dkato 0:13c1f522bbef 69 * @return The maximum number of simultaneous touches.
dkato 0:13c1f522bbef 70 */
dkato 0:13c1f522bbef 71 int GetMaxTouchNum(void);
dkato 0:13c1f522bbef 72
dkato 0:13c1f522bbef 73 /** Get the coordinates
dkato 0:13c1f522bbef 74 *
dkato 0:13c1f522bbef 75 * @param touch_buff_num The number of structure p_touch.
dkato 0:13c1f522bbef 76 * @param p_touch Touch position information.
dkato 0:13c1f522bbef 77 * @return The number of touch points.
dkato 0:13c1f522bbef 78 */
dkato 0:13c1f522bbef 79 int GetCoordinates(int touch_buff_num, touch_pos_t * p_touch);
dkato 0:13c1f522bbef 80
dkato 0:13c1f522bbef 81 private:
dkato 0:13c1f522bbef 82 typedef enum {
dkato 0:13c1f522bbef 83 POS_SEQ_INIT,
dkato 0:13c1f522bbef 84 POS_SEQ_START,
dkato 0:13c1f522bbef 85 POS_SEQ_X,
dkato 0:13c1f522bbef 86 POS_SEQ_X_POS,
dkato 0:13c1f522bbef 87 POS_SEQ_X_M,
dkato 0:13c1f522bbef 88 POS_SEQ_C,
dkato 0:13c1f522bbef 89 POS_SEQ_Y,
dkato 0:13c1f522bbef 90 POS_SEQ_Y_POS,
dkato 0:13c1f522bbef 91 POS_SEQ_Y_M,
dkato 0:13c1f522bbef 92 POS_SEQ_END,
dkato 0:13c1f522bbef 93 } pos_seq_t;
dkato 0:13c1f522bbef 94
dkato 0:13c1f522bbef 95 Thread displayThread;
dkato 0:13c1f522bbef 96 USBSerial * pPcApp;
dkato 0:13c1f522bbef 97 pos_seq_t pos_seq;
dkato 0:13c1f522bbef 98 int pos_x;
dkato 0:13c1f522bbef 99 int pos_y;
dkato 0:13c1f522bbef 100 FunctionPointer event;
dkato 0:13c1f522bbef 101
dkato 0:13c1f522bbef 102 void touch_int_callback(void);
dkato 0:13c1f522bbef 103 void display_app_process();
dkato 0:13c1f522bbef 104 static void display_app_process_static(void const * arg);
dkato 0:13c1f522bbef 105 void SendHeader(uint32_t size);
dkato 0:13c1f522bbef 106 void SendData(uint8_t * buf, uint32_t size);
dkato 0:13c1f522bbef 107 };
dkato 0:13c1f522bbef 108 #endif