Hi all, I have this code fragment: ... bool HasToQuit = FALSE; MENU_Question("Quit?",&HasToQuit); if(HasToQuit == TRUE) { // I am always landing here, even if the answer is NO } ... Moreover, the compiler reports:
warning: passing argument 2 of '(u32 (*)(u32, u32))(*ptrCircle_API)[162]' makes integer from pointer without a cast expected 'u32' but argument is of type 'enum bool *'
I looked into circle.h, the forward declaration is void MENU_Question( const u8* str, bool* answer );
What is the correct way of using the MENU_Question function? I am using OS V4.61 on a STM324x Primer. Thanks for any help. Igor
The function is defined in circle_api.h for the application (CircleOS API), and circle.h for CircleOS internal uses. I supposed you implement it into an application.
The API functions with 2 parameters are defined by the generic prototype, in circle_api.h : typedef u32( *tCircleFunc2 )( u32 param1, u32 param2 );
It seems there is a little mistake in circle_api.h, int the MENU_QUESTION definition #define MENU_Question(a,b) ((tCircleFunc2)(Circle_API [MENU_QUESTION_ID])) ((u32)(a),(bool*)(b)) /* void MENU_Question( u8* str, bool* answer ); */
If you want to suppress the warning, change the line before, by : #define MENU_Question(a,b) ((tCircleFunc2)(Circle_API [MENU_QUESTION_ID])) ((u32)(a),(u32)(b)) /* void MENU_Question( u8* str, bool* answer ); */
Just another remark, the MENU_Question just set the corresponding menu, so the function does not block until the response, it immediately gives the hand back. The variable HasToQuit will only change after the user action.
Thanks. I have corrected the declaration in circle_api.h, that's fine. I also see now that the MENU_Question() is a non-blocking function. So I deployed it like this:
In fact, the HasToQuit variable changes, but the MENU_Question does not gives the hand back to your application, but to the OS. So you think that HasToQuit is true, but check with a watch. I think that MENU_Question is not appropriate (it is used for CircleOS internal use, like configuration menu).
Dear yrt, thanks. For a longer time, I was still not able to get this working, but now I found the reason why.
My symptoms were the following: whatever I did, the visual behaviour of the menus was fine but the callback function actually called was always the FIRST one in the list. Then I realized what my problem was.
I always declared the tMenu structure as 'const', as I though this is the correct way to do things (the tMenu struct should no change, should it?). But I was wrong:
const tMenu MyMenu = // THIS IS WRONG //if you do this, you will always end up calling Item1Handler { 1, " Menu title", 2, 0, 0, 0, 0, 0, 0, { { "Item1 ", Item1Handler, Application_Handler, 0 }, { "Item2", Item2Handler, Application_Handler, 0 }, } };
tMenu MyMenu = // THIS IS CORRECT (no 'const' modifier) { ... };
Maybe just my ignorance is C. Hope it helps others too.
Some parameters in the menu are not constants because internally used by CircleOS : x and y position, selected items.... It concerns 0 values in the menu declaration. (see the tMenu declaration)