テスト

Dependencies:   DisplayApp_Base

Dependents:   LED

Committer:
dkato
Date:
Fri Sep 16 10:26:16 2016 +0000
Revision:
2:b7ffe5216cd7
Parent:
0:13c1f522bbef
Child:
3:693902c86ca0
Change to be able to set the stack size.

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 2:b7ffe5216cd7 27 * @param tsk_pri Priority of the thread function. (default: osPriorityNormal).
dkato 2:b7ffe5216cd7 28 * @param init_pri Priority of before the USB is connected. (default: osPriorityLow).
dkato 2:b7ffe5216cd7 29 * @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
dkato 0:13c1f522bbef 30 */
dkato 2:b7ffe5216cd7 31 DisplayApp(osPriority tsk_pri = osPriorityNormal, osPriority init_pri = osPriorityLow, uint32_t stack_size = DEFAULT_STACK_SIZE);
dkato 0:13c1f522bbef 32
dkato 0:13c1f522bbef 33 /** Send RGB888 data
dkato 0:13c1f522bbef 34 *
dkato 0:13c1f522bbef 35 * @param buf data buffer address
dkato 0:13c1f522bbef 36 * @param pic_width picture width
dkato 0:13c1f522bbef 37 * @param pic_height picture height
dkato 0:13c1f522bbef 38 * @return send data size
dkato 0:13c1f522bbef 39 */
dkato 0:13c1f522bbef 40 int SendRgb888(uint8_t * buf, uint32_t pic_width, uint32_t pic_height);
dkato 0:13c1f522bbef 41
dkato 0:13c1f522bbef 42 /** Send JPEG data
dkato 0:13c1f522bbef 43 *
dkato 0:13c1f522bbef 44 * @param buf data buffer address
dkato 0:13c1f522bbef 45 * @param size data size
dkato 0:13c1f522bbef 46 * @return send data size
dkato 0:13c1f522bbef 47 */
dkato 0:13c1f522bbef 48 int SendJpeg(uint8_t * buf, uint32_t size);
dkato 0:13c1f522bbef 49
dkato 0:13c1f522bbef 50 /** Attach a function to call when touch panel int
dkato 0:13c1f522bbef 51 *
dkato 0:13c1f522bbef 52 * @param fptr A pointer to a void function, or 0 to set as none
dkato 0:13c1f522bbef 53 */
dkato 0:13c1f522bbef 54 void SetCallback(void (*fptr)(void)) {
dkato 0:13c1f522bbef 55 if(fptr != NULL) {
dkato 0:13c1f522bbef 56 event.attach(fptr);
dkato 0:13c1f522bbef 57 }
dkato 0:13c1f522bbef 58 }
dkato 0:13c1f522bbef 59 /** Attach a member function to call when touch panel int
dkato 0:13c1f522bbef 60 *
dkato 0:13c1f522bbef 61 * @param tptr pointer to the object to call the member function on
dkato 0:13c1f522bbef 62 * @param mptr pointer to the member function to be called
dkato 0:13c1f522bbef 63 */
dkato 0:13c1f522bbef 64 template<typename T>
dkato 0:13c1f522bbef 65 void SetCallback(T* tptr, void (T::*mptr)(void)) {
dkato 0:13c1f522bbef 66 if((mptr != NULL) && (tptr != NULL)) {
dkato 0:13c1f522bbef 67 event.attach(tptr, mptr);
dkato 0:13c1f522bbef 68 }
dkato 0:13c1f522bbef 69 }
dkato 0:13c1f522bbef 70 /** Get the maximum number of simultaneous touches
dkato 0:13c1f522bbef 71 *
dkato 0:13c1f522bbef 72 * @return The maximum number of simultaneous touches.
dkato 0:13c1f522bbef 73 */
dkato 0:13c1f522bbef 74 int GetMaxTouchNum(void);
dkato 0:13c1f522bbef 75
dkato 0:13c1f522bbef 76 /** Get the coordinates
dkato 0:13c1f522bbef 77 *
dkato 0:13c1f522bbef 78 * @param touch_buff_num The number of structure p_touch.
dkato 0:13c1f522bbef 79 * @param p_touch Touch position information.
dkato 0:13c1f522bbef 80 * @return The number of touch points.
dkato 0:13c1f522bbef 81 */
dkato 0:13c1f522bbef 82 int GetCoordinates(int touch_buff_num, touch_pos_t * p_touch);
dkato 0:13c1f522bbef 83
dkato 0:13c1f522bbef 84 private:
dkato 0:13c1f522bbef 85 typedef enum {
dkato 0:13c1f522bbef 86 POS_SEQ_INIT,
dkato 0:13c1f522bbef 87 POS_SEQ_START,
dkato 0:13c1f522bbef 88 POS_SEQ_X,
dkato 0:13c1f522bbef 89 POS_SEQ_X_POS,
dkato 0:13c1f522bbef 90 POS_SEQ_X_M,
dkato 0:13c1f522bbef 91 POS_SEQ_C,
dkato 0:13c1f522bbef 92 POS_SEQ_Y,
dkato 0:13c1f522bbef 93 POS_SEQ_Y_POS,
dkato 0:13c1f522bbef 94 POS_SEQ_Y_M,
dkato 0:13c1f522bbef 95 POS_SEQ_END,
dkato 0:13c1f522bbef 96 } pos_seq_t;
dkato 0:13c1f522bbef 97
dkato 0:13c1f522bbef 98 Thread displayThread;
dkato 0:13c1f522bbef 99 USBSerial * pPcApp;
dkato 0:13c1f522bbef 100 pos_seq_t pos_seq;
dkato 0:13c1f522bbef 101 int pos_x;
dkato 0:13c1f522bbef 102 int pos_y;
dkato 2:b7ffe5216cd7 103 osPriority change_pri;
dkato 0:13c1f522bbef 104 FunctionPointer event;
dkato 0:13c1f522bbef 105
dkato 0:13c1f522bbef 106 void touch_int_callback(void);
dkato 0:13c1f522bbef 107 void display_app_process();
dkato 0:13c1f522bbef 108 static void display_app_process_static(void const * arg);
dkato 0:13c1f522bbef 109 void SendHeader(uint32_t size);
dkato 0:13c1f522bbef 110 void SendData(uint8_t * buf, uint32_t size);
dkato 0:13c1f522bbef 111 };
dkato 0:13c1f522bbef 112 #endif