Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
DisplayApp.h
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: DEFAULT_STACK_SIZE). 00030 */ 00031 DisplayApp(osPriority tsk_pri = osPriorityNormal, uint32_t stack_size = DEFAULT_STACK_SIZE); 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 char Getgetc(); 00092 00093 private: 00094 typedef enum { 00095 POS_SEQ_INIT, 00096 POS_SEQ_START, 00097 POS_SEQ_X, 00098 POS_SEQ_X_POS, 00099 POS_SEQ_X_M, 00100 POS_SEQ_C, 00101 POS_SEQ_Y, 00102 POS_SEQ_Y_POS, 00103 POS_SEQ_Y_M, 00104 POS_SEQ_END, 00105 } pos_seq_t; 00106 00107 USBSerial PcApp; 00108 Thread displayThread; 00109 pos_seq_t pos_seq; 00110 int pos_x; 00111 int pos_y; 00112 Callback<void()> event; 00113 00114 void touch_int_callback(void); 00115 void display_app_process(); 00116 void SendHeader(uint32_t size); 00117 void SendData(uint8_t * buf, uint32_t size); 00118 }; 00119 #endif
Generated on Wed Jul 20 2022 12:06:51 by
1.7.2