A basic graphics package for the LPC4088 Display Module.
Dependents: lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more
Fork of DMBasicGUI by
Revision 4:a73760d09423, committed 2014-12-19
- Comitter:
- embeddedartists
- Date:
- Fri Dec 19 16:40:30 2014 +0100
- Parent:
- 3:3fabfe3339b8
- Child:
- 5:f4de114c31c3
- Commit message:
- - Fixed bug in AppTouchCalibration (return values not correctly handled)
- Added support to ImageButton for images from c-array
Changed in this revision
--- a/Application/AppTouchCalibration.cpp Fri Dec 19 09:12:51 2014 +0100 +++ b/Application/AppTouchCalibration.cpp Fri Dec 19 16:40:30 2014 +0100 @@ -90,7 +90,7 @@ int point = 0; do { - if (!_touch->calibrateStart()) { + if (_touch->calibrateStart() != TouchPanel::TouchError_Ok) { showStatus("Failed to start calibration\n"); break; } @@ -99,7 +99,7 @@ // erase old location drawMarker(x, y, true); } - if (!_touch->getNextCalibratePoint(&x, &y, &lastPoint)) { + if (_touch->getNextCalibratePoint(&x, &y, &lastPoint) != TouchPanel::TouchError_Ok) { showStatus("Failed to get calibration point\n"); break; } @@ -108,7 +108,7 @@ showStatus("Last calibration point. After this the data will"); showStatus("be saved, which can take a couple of seconds!", 1); } - if (!_touch->waitForCalibratePoint(&morePoints, 0)) { + if (_touch->waitForCalibratePoint(&morePoints, 0) != TouchPanel::TouchError_Ok) { showStatus("Failed to get user click\n"); break; }
--- a/Application/ImageButton.cpp Fri Dec 19 09:12:51 2014 +0100 +++ b/Application/ImageButton.cpp Fri Dec 19 16:40:30 2014 +0100 @@ -62,6 +62,31 @@ return true; } +bool ImageButton::loadImages(const unsigned char* imgUp, unsigned int imgUpSize, + const unsigned char* imgDown, unsigned int imgDownSize) +{ + if (_imgUp.pixels != NULL) { + free(_imgUp.pixels); + _imgUp.pixels = NULL; + } + if (_imgDown.pixels != NULL) { + free(_imgDown.pixels); + _imgDown.pixels = NULL; + } + if (Image::decode(imgUp, imgUpSize, Image::RES_16BIT, &_imgUp) != 0) { + DMBoard::instance().logger()->printf("Failed to load %s\n", imgUp); + return false; + } + if (imgDown != NULL) { + if (Image::decode(imgDown, imgDownSize, Image::RES_16BIT, &_imgDown) == 0) { + DMBoard::instance().logger()->printf("Failed to load %s\n", imgDown); + return false; + } + } + return true; +} + + void ImageButton::draw() { if (_pressed) {
--- a/Application/ImageButton.h Fri Dec 19 09:12:51 2014 +0100 +++ b/Application/ImageButton.h Fri Dec 19 16:40:30 2014 +0100 @@ -42,6 +42,17 @@ /** Loads the mandatory "normal" state image and the optional "pressed" state image * + * @param imgUp the file with the image for the normal state + * @param imgDown the file with the image for the pressed state (or NULL to use the same) + * + * @returns + * true on success + * false on failure + */ + bool loadImages(const char* imgUp, const char* imgDown = 0); + + /** Loads the mandatory "normal" state image and the optional "pressed" state image + * * @param imgUp the image for the normal state * @param imgDown the image for the pressed state (or NULL to use the same) * @@ -49,7 +60,8 @@ * true on success * false on failure */ - bool loadImages(const char* imgUp, const char* imgDown = 0); + bool loadImages(const unsigned char* imgUp, unsigned int imgUpSize, + const unsigned char* imgDown = 0, unsigned int imgDownSize = 0); /** Draws the button */