Migration from emWin to TouchGFX
I'm currently switching from the emWin 5 graphics library to TouchGFX and have a question.
I have an IMAGE widget that reacts to an event: 1) click (calls a function to play sound) and 2) release (calls a function to send data to change status: SET_STOP_WORK, SET_WORK).
The IMAGE widget can display 3 pictures, depending on the state, bmSTOP_WORK.png, bmPAUSE_WORK.png, bmIS_WORKING.png. To display these pictures, the function is used:
void IMAGE_SetBitmap(IMAGE_Handle hWin, const GUI_BITMAP * pBitmap);
The pBitmap pointer receives the address of the corresponding picture, depending on the state. These images are precompiled into "C code" as a separate src file.
Code Main_window:
const GUI_BITMAP *pBitmap = &bmSTOP_WORK;
// Init widget
case WM_INIT_DIALOG::
hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_4);
IMAGE_SetBitmap(hItem, pBitmap);
// Paint widget - update
case WM_PAINT:
hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_4);
IMAGE_SetBitmap(hItem, pBitmap);
Code Receive_Task:
// ...
if (rxStatus != (Status_t) fValue) {
rxStatus = (Status_t) fValue;
if (rxStatus == IS_STOP_WORK) {
pBitmap = &bmSTOP_WORK;
} else if (rxStatus == IS_PAUSE_WORK) {
pBitmap = &bmPAUSE_WORK;
} else if (rxStatus == IS_WORKING) {
pBitmap = &bmIS_WORKING;
}
}
// ...
How to implement a similar mechanism with TouchGFX?
I will appreciate your help.
