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
Diff: Application/AppColorPicker.cpp
- Revision:
- 17:6e2abf107800
- Parent:
- 11:265884fa7fdd
- Child:
- 21:0038059e3a8f
diff -r feb669462368 -r 6e2abf107800 Application/AppColorPicker.cpp --- a/Application/AppColorPicker.cpp Mon Mar 09 14:24:54 2015 +0000 +++ b/Application/AppColorPicker.cpp Fri Mar 20 14:25:46 2015 +0100 @@ -19,16 +19,14 @@ #include "EthernetInterface.h" #include "AppColorPicker.h" #include "lpc_swim_font.h" -#include "basic_image_data.h" + /****************************************************************************** * Defines and typedefs *****************************************************************************/ -#define BOX_SIDE 192 //256 +#define BOX_SIDE 192 -#define BTN_WIDTH 65 -#define BTN_HEIGHT 40 #define BTN_OFF 20 /****************************************************************************** @@ -66,11 +64,8 @@ uint16_t r, g, b; uint16_t rx = BOX_SIDE/32; - //uint16_t gx = BOX_SIDE/64; uint16_t bx = BOX_SIDE/32; - //uint16_t ry = BOX_SIDE/32; uint16_t gy = BOX_SIDE/64; - //uint16_t by = BOX_SIDE/32; uint16_t color; for (int x = 0; x < BOX_SIDE; x++) { r = (x/rx); @@ -83,8 +78,8 @@ } } - _btn = new ImageButton(_win->fb, _win->xpmax - BTN_OFF - BTN_WIDTH, _win->ypmax - BTN_OFF - BTN_HEIGHT, BTN_WIDTH, BTN_HEIGHT); - _btn->loadImages(img_ok, img_size_ok); + _btn = new ImageButton(_win->fb, _win->xpmax - BTN_OFF - _resOk->width(), _win->ypmax - BTN_OFF - _resOk->height(), _resOk->width(), _resOk->height()); + _btn->loadImages(_resOk); _btn->draw(); // Copy everything onto the back buffer @@ -96,8 +91,19 @@ *****************************************************************************/ AppColorPicker::AppColorPicker() : _disp(NULL), _win(NULL), _colorwin(NULL), - _fb(NULL), _fb2(NULL), _btn(NULL) + _fb(NULL), _fb2(NULL), _btn(NULL), _resOk(NULL) { + if (DMBoard::instance().display()->width() == 480) { + _resultX = 350; + _resultY = 70; + _resultW = 80; + _resultH = 80; + } else { + _resultW = 80*2; + _resultH = 80*2; + _resultX = 350; + _resultY = (DMBoard::instance().display()->height() - (_resultH + 50))/2; + } } AppColorPicker::~AppColorPicker() @@ -143,9 +149,9 @@ COLOR_T c = ((x/(BOX_SIDE/32))<<11) | ((y/(BOX_SIDE/64))<<5) | ((0x1f-(x/(BOX_SIDE/32)))<<0); if (c != lastColor) { swim_set_fill_color(_win, c); - swim_put_box(_win, 350, 70, 430, 150); + swim_put_box(_win, _resultX, _resultY, _resultX+_resultW, _resultY+_resultH); sprintf(buf, "0x%04x ", c); - swim_put_text_xy(_win, buf, 350, 160); + swim_put_text_xy(_win, buf, _resultX, _resultY+_resultH+10); // Swap what is shown and what is drawn on if (showingFB2) { @@ -197,4 +203,7 @@ return true; } - +void AppColorPicker::addResource(Resources id, Resource* res) +{ + _resOk = res; +}