A board support package for the LPC4088 Display Module.

Dependencies:   DM_HttpServer DM_USBHost

Dependents:   lpc4088_displaymodule_emwin lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI ... more

Fork of DMSupport by EmbeddedArtists AB

Committer:
embeddedartists
Date:
Tue Feb 17 10:41:48 2015 +0100
Revision:
31:d47cffcb0a3e
Parent:
28:8ae20cb0b943
Child:
33:8a0a99d54bf8
- Added function get current BIOS version
- Added function to allocate consequtive frame buffers
- Removed printouts that slowed down the touch controller
- Replaced wait_ms with Thread::wait in MCIFileSystem
- Changed CardDetect pin for MCIFileSystem
- Added (but disabled) extra pins for measurements
- Updated the DM_USBHost library (see version history there for changes)
- Updated EthernetInterface library to get TARGET_LPC4088_DM support
- Updated to latest versions of mbed, mbed-rpc, mbed-rtos and USBDevice libs

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 22:1a58a518435c 1 /*
embeddedartists 22:1a58a518435c 2 * Copyright 2014 Embedded Artists AB
embeddedartists 22:1a58a518435c 3 *
embeddedartists 22:1a58a518435c 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 22:1a58a518435c 5 * you may not use this file except in compliance with the License.
embeddedartists 22:1a58a518435c 6 * You may obtain a copy of the License at
embeddedartists 22:1a58a518435c 7 *
embeddedartists 22:1a58a518435c 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 22:1a58a518435c 9 *
embeddedartists 22:1a58a518435c 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 22:1a58a518435c 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 22:1a58a518435c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 22:1a58a518435c 13 * See the License for the specific language governing permissions and
embeddedartists 22:1a58a518435c 14 * limitations under the License.
embeddedartists 22:1a58a518435c 15 */
embeddedartists 22:1a58a518435c 16
embeddedartists 22:1a58a518435c 17 #include "mbed.h"
embeddedartists 22:1a58a518435c 18 #include "BiosTouch.h"
embeddedartists 22:1a58a518435c 19 #include "BiosLoader.h"
embeddedartists 22:1a58a518435c 20 #include "DMBoard.h"
embeddedartists 22:1a58a518435c 21 #include "bios.h"
embeddedartists 22:1a58a518435c 22 #include "meas.h"
embeddedartists 22:1a58a518435c 23
embeddedartists 22:1a58a518435c 24 /******************************************************************************
embeddedartists 22:1a58a518435c 25 * Defines and typedefs
embeddedartists 22:1a58a518435c 26 *****************************************************************************/
embeddedartists 22:1a58a518435c 27
embeddedartists 26:a65fbb4bde5c 28 #define NUM_COORDS 5
embeddedartists 26:a65fbb4bde5c 29 #define NUM_MAILS 10
embeddedartists 26:a65fbb4bde5c 30 typedef struct {
embeddedartists 26:a65fbb4bde5c 31 touch_coordinate_t touch[NUM_COORDS];
embeddedartists 26:a65fbb4bde5c 32 int num;
embeddedartists 26:a65fbb4bde5c 33 } touch_mail_t;
embeddedartists 26:a65fbb4bde5c 34
embeddedartists 22:1a58a518435c 35 #define SIG_NEW_DATA 0x1
embeddedartists 22:1a58a518435c 36 class TouchHandler {
embeddedartists 22:1a58a518435c 37 public:
embeddedartists 22:1a58a518435c 38 TouchHandler(bios_header_t* bios, void* biosData, int num) :
embeddedartists 22:1a58a518435c 39 _latest(NULL), _touchIRQ(P2_25), _bios(bios),
embeddedartists 26:a65fbb4bde5c 40 _biosData(biosData), _points(num),
embeddedartists 26:a65fbb4bde5c 41 _listener(NULL), _lostData(0),
embeddedartists 26:a65fbb4bde5c 42 _dbgAdded(0), _dbgRemoved(0) {}
embeddedartists 22:1a58a518435c 43 void handleTouchInterrupt();
embeddedartists 26:a65fbb4bde5c 44 void handleNewData(touch_coordinate_t* coord, int num);
embeddedartists 28:8ae20cb0b943 45 void changeTouchInterrupt(bool enable, touch_irq_trigger_t trigger);
embeddedartists 22:1a58a518435c 46 TouchPanel::TouchError read(touch_coordinate_t* coord, int num);
embeddedartists 22:1a58a518435c 47 void run();
embeddedartists 22:1a58a518435c 48 FunctionPointer* setListener(FunctionPointer* listener);
embeddedartists 22:1a58a518435c 49 private:
embeddedartists 26:a65fbb4bde5c 50 Mail<touch_mail_t, NUM_MAILS> _mailbox;
embeddedartists 22:1a58a518435c 51 Mutex _mutex;
embeddedartists 22:1a58a518435c 52 touch_coordinate_t* _latest;
embeddedartists 22:1a58a518435c 53 InterruptIn _touchIRQ;
embeddedartists 22:1a58a518435c 54 bios_header_t* _bios;
embeddedartists 22:1a58a518435c 55 void* _biosData;
embeddedartists 22:1a58a518435c 56 int _points;
embeddedartists 22:1a58a518435c 57 FunctionPointer* _listener;
embeddedartists 26:a65fbb4bde5c 58 uint32_t _lostData;
embeddedartists 26:a65fbb4bde5c 59 uint32_t _dbgAdded;
embeddedartists 26:a65fbb4bde5c 60 uint32_t _dbgRemoved;
embeddedartists 22:1a58a518435c 61 };
embeddedartists 22:1a58a518435c 62
embeddedartists 22:1a58a518435c 63 /******************************************************************************
embeddedartists 22:1a58a518435c 64 * Local variables
embeddedartists 22:1a58a518435c 65 *****************************************************************************/
embeddedartists 22:1a58a518435c 66
embeddedartists 22:1a58a518435c 67 /******************************************************************************
embeddedartists 22:1a58a518435c 68 * Private Functions
embeddedartists 22:1a58a518435c 69 *****************************************************************************/
embeddedartists 22:1a58a518435c 70
embeddedartists 22:1a58a518435c 71 BiosTouch::BiosTouch() :
embeddedartists 22:1a58a518435c 72 _initialized(false),
embeddedartists 22:1a58a518435c 73 _haveInfo(false),
embeddedartists 22:1a58a518435c 74 _poweredOn(false),
embeddedartists 22:1a58a518435c 75 //_touchIRQ(P2_25),
embeddedartists 22:1a58a518435c 76 _bios(NULL),
embeddedartists 22:1a58a518435c 77 _biosData(NULL),
embeddedartists 22:1a58a518435c 78 _handlerThread(NULL),
embeddedartists 22:1a58a518435c 79 _handler(NULL),
embeddedartists 22:1a58a518435c 80 _supportsTouch(false)
embeddedartists 22:1a58a518435c 81 {
embeddedartists 22:1a58a518435c 82 }
embeddedartists 22:1a58a518435c 83
embeddedartists 22:1a58a518435c 84 BiosTouch::~BiosTouch()
embeddedartists 22:1a58a518435c 85 {
embeddedartists 22:1a58a518435c 86 // _bios and _biosData are deallocated by BiosLoader
embeddedartists 22:1a58a518435c 87
embeddedartists 22:1a58a518435c 88 if (_handlerThread != NULL) {
embeddedartists 22:1a58a518435c 89 delete _handlerThread;
embeddedartists 22:1a58a518435c 90 _handlerThread = NULL;
embeddedartists 22:1a58a518435c 91 }
embeddedartists 22:1a58a518435c 92 if (_handler != NULL) {
embeddedartists 22:1a58a518435c 93 delete _handler;
embeddedartists 22:1a58a518435c 94 _handler = NULL;
embeddedartists 22:1a58a518435c 95 }
embeddedartists 22:1a58a518435c 96 }
embeddedartists 22:1a58a518435c 97
embeddedartists 22:1a58a518435c 98 // Function called from the BIOS
embeddedartists 28:8ae20cb0b943 99 static void touchIrqEnabler(uint32_t arg, bool enable, touch_irq_trigger_t trigger)
embeddedartists 22:1a58a518435c 100 {
embeddedartists 28:8ae20cb0b943 101 ((TouchHandler*)arg)->changeTouchInterrupt(enable, trigger);
embeddedartists 26:a65fbb4bde5c 102 }
embeddedartists 26:a65fbb4bde5c 103
embeddedartists 26:a65fbb4bde5c 104 // Function called from the BIOS
embeddedartists 26:a65fbb4bde5c 105 static void touchNewData(uint32_t arg, touch_coordinate_t* coords, int num)
embeddedartists 26:a65fbb4bde5c 106 {
embeddedartists 26:a65fbb4bde5c 107 ((TouchHandler*)arg)->handleNewData(coords, num);
embeddedartists 22:1a58a518435c 108 }
embeddedartists 22:1a58a518435c 109
embeddedartists 22:1a58a518435c 110 static void touchTask(void const* args)
embeddedartists 22:1a58a518435c 111 {
embeddedartists 22:1a58a518435c 112 ((TouchHandler*)args)->run();
embeddedartists 22:1a58a518435c 113 }
embeddedartists 22:1a58a518435c 114
embeddedartists 22:1a58a518435c 115
embeddedartists 22:1a58a518435c 116 void TouchHandler::run()
embeddedartists 22:1a58a518435c 117 {
embeddedartists 22:1a58a518435c 118 RtosLog* log = DMBoard::instance().logger();
embeddedartists 26:a65fbb4bde5c 119
embeddedartists 22:1a58a518435c 120 _latest = (touch_coordinate_t*)malloc(_points*sizeof(touch_coordinate_t));
embeddedartists 22:1a58a518435c 121 if (_latest == NULL) {
embeddedartists 22:1a58a518435c 122 log->printf("Failed to allocate memory for touch events\n");
embeddedartists 22:1a58a518435c 123 mbed_die();
embeddedartists 22:1a58a518435c 124 }
embeddedartists 22:1a58a518435c 125 memset(_latest, 0, _points*sizeof(touch_coordinate_t));
embeddedartists 22:1a58a518435c 126 while(true) {
embeddedartists 26:a65fbb4bde5c 127 osEvent evt = _mailbox.get(osWaitForever);
embeddedartists 26:a65fbb4bde5c 128 if (evt.status == osEventMail) {
embeddedartists 26:a65fbb4bde5c 129 touch_mail_t* mail = (touch_mail_t*)evt.value.p;
embeddedartists 26:a65fbb4bde5c 130 memcpy(_latest, mail->touch, mail->num * sizeof(touch_coordinate_t));
embeddedartists 26:a65fbb4bde5c 131 _mailbox.free(mail);
embeddedartists 26:a65fbb4bde5c 132 _dbgRemoved++;
embeddedartists 31:d47cffcb0a3e 133 //if (_points == 1) {
embeddedartists 31:d47cffcb0a3e 134 // log->printf("{%3d,%3d,%d} at %u/%u, with %u lost\n",
embeddedartists 31:d47cffcb0a3e 135 // _latest[0].x,
embeddedartists 31:d47cffcb0a3e 136 // _latest[0].y,
embeddedartists 31:d47cffcb0a3e 137 // _latest[0].z,
embeddedartists 31:d47cffcb0a3e 138 // _dbgRemoved, _dbgAdded,
embeddedartists 31:d47cffcb0a3e 139 // _lostData);
embeddedartists 31:d47cffcb0a3e 140 //} else {
embeddedartists 31:d47cffcb0a3e 141 // log->printf("{%d,%d,%d,%d,%d} at %u/%u, with %u lost\n",
embeddedartists 31:d47cffcb0a3e 142 // _latest[0].z,
embeddedartists 31:d47cffcb0a3e 143 // _latest[1].z,
embeddedartists 31:d47cffcb0a3e 144 // _latest[2].z,
embeddedartists 31:d47cffcb0a3e 145 // _latest[3].z,
embeddedartists 31:d47cffcb0a3e 146 // _latest[4].z,
embeddedartists 31:d47cffcb0a3e 147 // _dbgRemoved, _dbgAdded,
embeddedartists 31:d47cffcb0a3e 148 // _lostData);
embeddedartists 31:d47cffcb0a3e 149 //}
embeddedartists 26:a65fbb4bde5c 150 } else {
embeddedartists 26:a65fbb4bde5c 151 log->printf("got non-mail event: 0x%x\n", evt.status);
embeddedartists 26:a65fbb4bde5c 152 continue;
embeddedartists 26:a65fbb4bde5c 153 }
embeddedartists 26:a65fbb4bde5c 154 _mutex.lock();
embeddedartists 26:a65fbb4bde5c 155 FunctionPointer* fp = _listener;
embeddedartists 26:a65fbb4bde5c 156 _mutex.unlock();
embeddedartists 26:a65fbb4bde5c 157
embeddedartists 26:a65fbb4bde5c 158 if (fp != NULL) {
embeddedartists 26:a65fbb4bde5c 159 fp->call();
embeddedartists 26:a65fbb4bde5c 160 }
embeddedartists 22:1a58a518435c 161 }
embeddedartists 22:1a58a518435c 162 }
embeddedartists 22:1a58a518435c 163
embeddedartists 22:1a58a518435c 164 TouchPanel::TouchError TouchHandler::read(touch_coordinate_t* coord, int num)
embeddedartists 22:1a58a518435c 165 {
embeddedartists 22:1a58a518435c 166 if (num > _points || num < 1) {
embeddedartists 22:1a58a518435c 167 return TouchPanel::TouchError_InvalidParam;
embeddedartists 22:1a58a518435c 168 }
embeddedartists 22:1a58a518435c 169 _mutex.lock();
embeddedartists 22:1a58a518435c 170 memcpy(coord, _latest, num*sizeof(touch_coordinate_t));
embeddedartists 22:1a58a518435c 171 _mutex.unlock();
embeddedartists 22:1a58a518435c 172
embeddedartists 22:1a58a518435c 173 return TouchPanel::TouchError_Ok;
embeddedartists 22:1a58a518435c 174 }
embeddedartists 22:1a58a518435c 175
embeddedartists 22:1a58a518435c 176 void TouchHandler::handleTouchInterrupt()
embeddedartists 22:1a58a518435c 177 {
embeddedartists 26:a65fbb4bde5c 178 _bios->touchIrqHandler(_biosData);
embeddedartists 26:a65fbb4bde5c 179 }
embeddedartists 26:a65fbb4bde5c 180
embeddedartists 26:a65fbb4bde5c 181 void TouchHandler::handleNewData(touch_coordinate_t* coord, int num)
embeddedartists 26:a65fbb4bde5c 182 {
embeddedartists 26:a65fbb4bde5c 183 touch_mail_t* mail = _mailbox.alloc(0);
embeddedartists 26:a65fbb4bde5c 184 if (mail == NULL) {
embeddedartists 26:a65fbb4bde5c 185 //DMBoard::instance().logger()->printf("Lost touch event\n");
embeddedartists 26:a65fbb4bde5c 186 _lostData++;
embeddedartists 26:a65fbb4bde5c 187 } else {
embeddedartists 26:a65fbb4bde5c 188 _dbgAdded++;
embeddedartists 26:a65fbb4bde5c 189 mail->num = (num < NUM_COORDS) ? num : NUM_COORDS;
embeddedartists 26:a65fbb4bde5c 190 memcpy(&mail->touch, coord, mail->num*sizeof(touch_coordinate_t));
embeddedartists 26:a65fbb4bde5c 191 _mailbox.put(mail);
embeddedartists 22:1a58a518435c 192 }
embeddedartists 22:1a58a518435c 193 }
embeddedartists 22:1a58a518435c 194
embeddedartists 28:8ae20cb0b943 195 void TouchHandler::changeTouchInterrupt(bool enable, touch_irq_trigger_t trigger)
embeddedartists 22:1a58a518435c 196 {
embeddedartists 28:8ae20cb0b943 197 switch (trigger) {
embeddedartists 28:8ae20cb0b943 198 case TOUCH_IRQ_RISING_EDGE:
embeddedartists 28:8ae20cb0b943 199 if (enable) {
embeddedartists 28:8ae20cb0b943 200 _touchIRQ.rise(this, &TouchHandler::handleTouchInterrupt);
embeddedartists 28:8ae20cb0b943 201 } else {
embeddedartists 28:8ae20cb0b943 202 _touchIRQ.rise(NULL);
embeddedartists 28:8ae20cb0b943 203 }
embeddedartists 28:8ae20cb0b943 204 break;
embeddedartists 28:8ae20cb0b943 205
embeddedartists 28:8ae20cb0b943 206 case TOUCH_IRQ_FALLING_EDGE:
embeddedartists 28:8ae20cb0b943 207 if (enable) {
embeddedartists 28:8ae20cb0b943 208 _touchIRQ.fall(this, &TouchHandler::handleTouchInterrupt);
embeddedartists 28:8ae20cb0b943 209 } else {
embeddedartists 28:8ae20cb0b943 210 _touchIRQ.fall(NULL);
embeddedartists 28:8ae20cb0b943 211 }
embeddedartists 28:8ae20cb0b943 212 break;
embeddedartists 28:8ae20cb0b943 213
embeddedartists 28:8ae20cb0b943 214 case TOUCH_IRQ_HIGH_LEVEL:
embeddedartists 28:8ae20cb0b943 215 case TOUCH_IRQ_LOW_LEVEL:
embeddedartists 28:8ae20cb0b943 216 default:
embeddedartists 28:8ae20cb0b943 217 DMBoard::instance().logger()->printf("BIOS requests unknown trigger type %d\n", trigger);
embeddedartists 28:8ae20cb0b943 218 break;
embeddedartists 22:1a58a518435c 219 }
embeddedartists 22:1a58a518435c 220 }
embeddedartists 22:1a58a518435c 221
embeddedartists 22:1a58a518435c 222 FunctionPointer* TouchHandler::setListener(FunctionPointer* listener)
embeddedartists 22:1a58a518435c 223 {
embeddedartists 22:1a58a518435c 224 _mutex.lock();
embeddedartists 22:1a58a518435c 225 FunctionPointer* old = _listener;
embeddedartists 22:1a58a518435c 226 _listener = listener;
embeddedartists 22:1a58a518435c 227 _mutex.unlock();
embeddedartists 22:1a58a518435c 228 return old;
embeddedartists 22:1a58a518435c 229 }
embeddedartists 22:1a58a518435c 230
embeddedartists 22:1a58a518435c 231
embeddedartists 22:1a58a518435c 232 /******************************************************************************
embeddedartists 22:1a58a518435c 233 * Public Functions
embeddedartists 22:1a58a518435c 234 *****************************************************************************/
embeddedartists 22:1a58a518435c 235
embeddedartists 22:1a58a518435c 236 BiosTouch::TouchError BiosTouch::init()
embeddedartists 22:1a58a518435c 237 {
embeddedartists 22:1a58a518435c 238 TouchError result = TouchError_Ok;
embeddedartists 22:1a58a518435c 239 if (!_initialized) {
embeddedartists 22:1a58a518435c 240 do {
embeddedartists 22:1a58a518435c 241 if (BiosLoader::instance().params(&_bios, &_biosData) != DMBoard::Ok) {
embeddedartists 22:1a58a518435c 242 result = TouchError_ConfigError;
embeddedartists 22:1a58a518435c 243 break;
embeddedartists 22:1a58a518435c 244 }
embeddedartists 22:1a58a518435c 245
embeddedartists 28:8ae20cb0b943 246 result = (TouchError)_bios->touchInformation(_biosData, &_supportsTouch, &_supportsTouchCalibration, &_touchNumFingers);
embeddedartists 22:1a58a518435c 247 if (result != TouchError_Ok) {
embeddedartists 22:1a58a518435c 248 break;
embeddedartists 22:1a58a518435c 249 }
embeddedartists 22:1a58a518435c 250 _haveInfo = true;
embeddedartists 22:1a58a518435c 251
embeddedartists 22:1a58a518435c 252 // is it supported at all?
embeddedartists 22:1a58a518435c 253 if (!_supportsTouch) {
embeddedartists 22:1a58a518435c 254 result = TouchError_TouchNotSupported;
embeddedartists 22:1a58a518435c 255 break;
embeddedartists 22:1a58a518435c 256 }
embeddedartists 22:1a58a518435c 257
embeddedartists 28:8ae20cb0b943 258 _handler = new TouchHandler(_bios, _biosData, _touchNumFingers);
embeddedartists 22:1a58a518435c 259
embeddedartists 26:a65fbb4bde5c 260 result = (TouchError)_bios->touchInit(_biosData, touchIrqEnabler, (uint32_t)_handler, touchNewData, (uint32_t)_handler);
embeddedartists 22:1a58a518435c 261 if (result != TouchError_Ok) {
embeddedartists 22:1a58a518435c 262 break;
embeddedartists 22:1a58a518435c 263 }
embeddedartists 22:1a58a518435c 264
embeddedartists 22:1a58a518435c 265 result = (TouchError)_bios->touchPowerUp(_biosData);
embeddedartists 22:1a58a518435c 266 if (result != TouchError_Ok) {
embeddedartists 22:1a58a518435c 267 break;
embeddedartists 22:1a58a518435c 268 }
embeddedartists 22:1a58a518435c 269
embeddedartists 22:1a58a518435c 270 _handlerThread = new Thread(touchTask, _handler);
embeddedartists 22:1a58a518435c 271
embeddedartists 22:1a58a518435c 272 _initialized = true;
embeddedartists 22:1a58a518435c 273 } while(0);
embeddedartists 22:1a58a518435c 274
embeddedartists 22:1a58a518435c 275 if (!_initialized) {
embeddedartists 22:1a58a518435c 276 if (_handler != NULL) {
embeddedartists 22:1a58a518435c 277 delete _handler;
embeddedartists 22:1a58a518435c 278 _handler = NULL;
embeddedartists 22:1a58a518435c 279 }
embeddedartists 22:1a58a518435c 280 }
embeddedartists 22:1a58a518435c 281 }
embeddedartists 22:1a58a518435c 282 return result;
embeddedartists 22:1a58a518435c 283 }
embeddedartists 22:1a58a518435c 284
embeddedartists 22:1a58a518435c 285 BiosTouch::TouchError BiosTouch::read(touch_coordinate_t &coord)
embeddedartists 22:1a58a518435c 286 {
embeddedartists 22:1a58a518435c 287 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 288 if (!_initialized) {
embeddedartists 22:1a58a518435c 289 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 290 } else {
embeddedartists 22:1a58a518435c 291 err = _handler->read(&coord, 1);
embeddedartists 22:1a58a518435c 292 }
embeddedartists 22:1a58a518435c 293 return err;
embeddedartists 22:1a58a518435c 294 }
embeddedartists 22:1a58a518435c 295
embeddedartists 22:1a58a518435c 296 BiosTouch::TouchError BiosTouch::read(touch_coordinate_t* coord, int num)
embeddedartists 22:1a58a518435c 297 {
embeddedartists 22:1a58a518435c 298 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 299 if (!_initialized) {
embeddedartists 22:1a58a518435c 300 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 301 } else {
embeddedartists 22:1a58a518435c 302 err = _handler->read(coord, num);
embeddedartists 22:1a58a518435c 303 }
embeddedartists 22:1a58a518435c 304 return err;
embeddedartists 22:1a58a518435c 305 }
embeddedartists 22:1a58a518435c 306
embeddedartists 22:1a58a518435c 307 BiosTouch::TouchError BiosTouch::info(bool* resistive, int* maxPoints, bool* calibrated)
embeddedartists 22:1a58a518435c 308 {
embeddedartists 22:1a58a518435c 309 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 310 if (!_haveInfo) {
embeddedartists 22:1a58a518435c 311 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 312 } else {
embeddedartists 22:1a58a518435c 313 *maxPoints = _touchNumFingers;
embeddedartists 22:1a58a518435c 314 *calibrated = _supportsTouchCalibration;
embeddedartists 22:1a58a518435c 315 }
embeddedartists 22:1a58a518435c 316 return err;
embeddedartists 22:1a58a518435c 317 }
embeddedartists 22:1a58a518435c 318
embeddedartists 22:1a58a518435c 319 bool BiosTouch::isTouchSupported()
embeddedartists 22:1a58a518435c 320 {
embeddedartists 22:1a58a518435c 321 #if defined(DM_BOARD_USE_TOUCH)
embeddedartists 22:1a58a518435c 322 if (_haveInfo) {
embeddedartists 22:1a58a518435c 323 return _supportsTouch;
embeddedartists 22:1a58a518435c 324 }
embeddedartists 22:1a58a518435c 325 #endif
embeddedartists 22:1a58a518435c 326 return false;
embeddedartists 22:1a58a518435c 327 }
embeddedartists 22:1a58a518435c 328
embeddedartists 22:1a58a518435c 329 BiosTouch::TouchError BiosTouch::calibrateStart()
embeddedartists 22:1a58a518435c 330 {
embeddedartists 22:1a58a518435c 331 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 332 if (!_initialized) {
embeddedartists 22:1a58a518435c 333 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 334 } else {
embeddedartists 22:1a58a518435c 335 err = (TouchError)_bios->touchCalibrateStart(_biosData);
embeddedartists 22:1a58a518435c 336 }
embeddedartists 22:1a58a518435c 337 return err;
embeddedartists 22:1a58a518435c 338 }
embeddedartists 22:1a58a518435c 339
embeddedartists 22:1a58a518435c 340 BiosTouch::TouchError BiosTouch::getNextCalibratePoint(uint16_t* x, uint16_t* y, bool* last)
embeddedartists 22:1a58a518435c 341 {
embeddedartists 22:1a58a518435c 342 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 343 if (!_initialized) {
embeddedartists 22:1a58a518435c 344 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 345 } else {
embeddedartists 22:1a58a518435c 346 err = (TouchError)_bios->touchGetNextCalibPoint(_biosData, x, y, last);
embeddedartists 22:1a58a518435c 347 }
embeddedartists 22:1a58a518435c 348 return err;
embeddedartists 22:1a58a518435c 349 }
embeddedartists 22:1a58a518435c 350
embeddedartists 22:1a58a518435c 351 BiosTouch::TouchError BiosTouch::waitForCalibratePoint(bool* morePoints, uint32_t timeout)
embeddedartists 22:1a58a518435c 352 {
embeddedartists 22:1a58a518435c 353 TouchError err = TouchError_Ok;
embeddedartists 22:1a58a518435c 354 if (!_initialized) {
embeddedartists 22:1a58a518435c 355 err = TouchError_NoInit;
embeddedartists 22:1a58a518435c 356 } else {
embeddedartists 22:1a58a518435c 357 err = (TouchError)_bios->touchWaitForCalibratePoint(_biosData, morePoints, timeout);
embeddedartists 22:1a58a518435c 358 }
embeddedartists 22:1a58a518435c 359 return err;
embeddedartists 22:1a58a518435c 360 }
embeddedartists 22:1a58a518435c 361
embeddedartists 22:1a58a518435c 362 FunctionPointer* BiosTouch::setListener(FunctionPointer* listener)
embeddedartists 22:1a58a518435c 363 {
embeddedartists 22:1a58a518435c 364 if (_initialized) {
embeddedartists 22:1a58a518435c 365 return _handler->setListener(listener);
embeddedartists 22:1a58a518435c 366 }
embeddedartists 22:1a58a518435c 367 return NULL;
embeddedartists 22:1a58a518435c 368 }