New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
menu buttons #161
Comments
Thanks. What about your m2tk library? Do you have any plans to update it? |
well, yes, m2tk... plan is there, time is missing :-( U8g2 and M2tk are both very time consuming. At the moment i concentrate on U8g2 only. |
Ciao Oliver |
I'm also trying to find a way to alter setting of my device, using a thumbstick and think that the example menu suits my needs, except there's no way to assign other controls than pushbutton with it. |
Giuseppe, you can of course reopen the issue... You can just remove u8x8_debounce.c and write your own "u8x8_GetMenuEvent" procedure. uint8_t u8x8_GetMenuEvent(u8x8_t *u8x8) |
Ciao Oliver |
Yes, we can. I kinda understand what should be done. As far as I understand, we should make variable "c" equal one of the following letters: n, p, s, h, x (as given in example) in our own code, depending on the thumbstick direction. |
this is only an example for a linux system. It is just important that the function returns these constants like U8X8_MSG_GPIO_MENU_NEXT or U8X8_MSG_GPIO_MENU_PREV. It should be like this;
So you job is only to detect the movement direction of the thumbstick (or any other device) All in all there are six events predefined: Oliver |
This is my function: I've renamed debounce .c file and added the above function to my code. At compiling I get this notice: ^` Should I use U8X8_PIN_MENU_PREV or U8X8_MSG_GPIO_MENU_PREV inside .ino sketch? |
Added "else { return 0; }" and the notice is gone. Now I need to find a way of how to call that u8x8_GetMenuEvent(u8x8_t *u8x8) function and what arguments should I pass to it. By now, I'm having this error: http://i.imgur.com/4cZpXG5.png |
Of course you should call this function with &u8x8 object (or u8g2.GetU8x8(), u8x8.GetU8x8()). joyD should be a global variable instead. One more point: You should not only check for "joyD>100". This will obviously fire a lot of events whenever this condition is true. Instead you may want to stop returning events and wait until joyD becomes <= 100. Only after joyD is > 100 again, the next event will be sent. As i said, this is not so easy and not scope of u8g2... ... i personally suggest to draw a state diagramm first (https://en.wikipedia.org/wiki/State_diagram)... |
Thanks, Oli. I'll deal with repeats later. That's not a problem at all. P.S. I'm still thinking about m2tk. Is it compatible with u8g2 library? |
Guys, This is the way I manage the joystick `` void myMenu () {
byte joyRead() {
}`` |
Basically you can also pass "NULL", because your replacement does not use the u8x8 structure. However if you call one of the u8x8-user function, u8x8 will automatically be passed. But since you do not use this, you can just ignore this. So finally: Just pass NULL and do not worry about the argument.
hmm, but you did not use NULL, right?
I am working on this, but progress is very slow... |
I've tried to modify debounce.c this way (tnx Alex): uint8_t u8x8_GetMenuEvent(u8x8_t *u8x8) Saving the modified file to src folder doesn't sort any effect..I can still browse up/down the same way as before (left scrolls down, up scrolls up because in those directions pins are drived low).. |
Sometimes you have to restart the IDE to force a full rebuild. |
Thanks for support, I finally gave up. Regards Giuseppe |
I'm looking for similar solution. I have a rotary encoder and want to navigate through menu list. |
I have always considered the menu functions as a simple add on. A menu system, which supports rotary encoder, buttons at digital or analog input or even remote controllers, should be extra lib. |
Hello, I modified u8x8_debounce.c and it works fine!, In my case I dont have more pins for the buttons and I use 3 buttons with a combination of resistor on the analog port, if you like,let tale me know! <#include "u8x8.h" /* State B + cnt State B State C */
// *testear_boton = 0; #ifdef __unix__xxxxxx_THIS_IS_DISABLED #include <stdio.h> #else /* unix */ #define U8X8_DEBOUNCE_WAIT 2 pragma weak u8x8_GetMenuEvent#endif #endif /* unix */> |
I have a library and an object for my rotary encoder. But I am not able to use the object in the GetMenuEvent() function. I tried to follow olis suggestion:
and
I edited the debounce.c to something like this:
I also tried renaming the debounce.c to a .cpp file, but this breaks the other menu functions:
removing debounce.c and defining the function in the .ino and wrapping it with
isn't working either. The compiler complains about not definied functions. I am a bit lost dealing with the .c files so any advice would be highly appreciated Kind Regards Triscus |
hmmm redefinition and declaration as extern "C" should work... |
so the definition can be done in an .ino file? |
yes, i think so. But Arduino IDE may do some extra modification, which i do not know. |
@tomivm already had the solution in his reply, but I wasn't able to adapt it. Declaring the function in the u8x8_debounce.c as weak and redefine it in the ino (without extern "C") seems to work now: Editing u8x8_debcounce.c:
Function in .ino (where
|
I'm using psp analog stick and capacitive touch pads in my device.
A separate function is used to read pad's state, which is stored in pad[i] array. I've tried to point to pad[0], pad[1] and so on in the "begin" section for menu buttons, without any luck.
Is there any way to use variables as menu triggers in thу library?
The text was updated successfully, but these errors were encountered: