Announcement

Collapse
No announcement yet.

Read winbutton in while function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • tonton81
    commented on 's reply
    you posted on the wrong thread

    Tony

  • dakman
    replied
    seems I left out the genie.DoEvents(); command...things are working somewhat OK now....

    Leave a comment:


  • James_4DSystems
    replied
    From what I can see of your posts, you are using Serial to talk to the display, and you are also using Serial to do prints to your Terminal console. That will never work, as the display will also be receiving your prints like "RH Request" and it will not understand. You cannot use the same serial port to talk to the display, and talk to something else like the Terminal.

    If you havent already, I suggest you have a read here:

    http://forum.4dsystems.com.au/forum/...and-4d-display

    Leave a comment:


  • James_4DSystems
    commented on 's reply
    Why are you wanting people to message you for a solution? Why don't you post your solution here, so if anyone encounters the same problem, then it is in the same forum thread.

  • bkz124
    replied
    Thank u all for answer but your answers wrong. I found solution on my own. Anyone who have this problem, can send me a message for solution.

    Have a nice day

    Berkcan

    Leave a comment:


  • bkz124
    replied
    Okay i avoid using goto's but now i cant send RH request every 100ms.
    Also i need help for up and down function. How to use HOLD key function? I think need magic event but i didnt find magic event code.

    Leave a comment:


  • pauleilio
    replied
    Hello,

    I don't think your goto is helping with the problem. Your code could be just looping around and unable to procees any other events. Is it possible to check this once and avoid using goto's.

    Best regards

    Paul

    Leave a comment:


  • bkz124
    replied
    I think you dont understand me. I apply your suggestion but your solition doesnt work. I changed momentary off because buttonpressed=1 until i press again. Now i can use "if" function for loop. But program read my first buttonpress. Then program write Rh request every 100ms. But if i clicked rh button again program doesnt stop. Again im saying program read only once. If my code is wrong please write correct code. Thank you again for answering.
    Code.
    if (Event.reportObject.object == GENIE_OBJ_USERBUTTON)
    {
    if(Event.reportObject.index==0)
    {
    here: // i use this code because if im not using this code show only 1 RH request
    buttonpressed=genie.GetEventData(&Event);
    if(buttonpressed==1)
    {
    Serial.println("RH Request");
    delay(100)
    goto here;
    }
    }
    }
    Please try this in your program its very simple only 2 button. if you solve problem then send me code please. I'am stuck.

    Equipment:
    Arduino Mega
    uLCD 43PT
    Last edited by bkz124; 5th July 2017, 05:36 PM.

    Leave a comment:


  • tonton81
    replied
    you cant serial read, but geteventdata returns 1(pressed) and 0(let go) you can set a variable there to say its pressed, make a global like buttonpressed=0; then have geteventdata set it when its pressed or not, then in your loop do your statements there, but DONT while loop, it wont work, you can set millis to toggle every 100ms if buttonpressed == 1 until genie gets the event for the let go

    Leave a comment:


  • bkz124
    commented on 's reply
    I need function like Serial.read();

  • bkz124
    replied
    Actually i made this program with keypad. This code working. Can u please help ??

    if(Value==53) // Button 5 - Ride Height
    {
    rha=0;

    while(rha<1) // Ride Height Signal stay in active until press another key.
    {

    keypadValue = Serial.read();
    int rhb= keypadValue;

    if(rhb==49 || rhb==50 || rhb==56 || rhb==55 || rhb==57)
    {
    rha++; //For stop the while loop
    goto start; //Return to startposition
    }

    else {
    Serial.println("Ride Height Request");
    }
    Last edited by bkz124; 4th July 2017, 10:56 PM.

    Leave a comment:


  • bkz124
    replied
    I delete all RH function and i changed.

    Code:
    if (Event.reportObject.object == GENIE_OBJ_USERBUTTON)
    {
    if(Event.reportObject.index == 0)
    {
    boolean button1=genie.GetEventData(&Event);
    if(button1==1)
    {
    counter++;
    if(counter%2==1)
    {
    Serial.println("RH request");
    }
    else
    {

    }
    }
    But i can only 1 RH request. I want RH request every 100ms. If I changed "if" to "while", i m taking RH request every 100ms but i cant stop loop now :D.

    Please can you help to change code?
    Last edited by bkz124; 4th July 2017, 08:27 PM.

    Leave a comment:


  • bkz124
    commented on 's reply
    How will i change my code?

  • bkz124
    commented on 's reply
    I change winbotton momentary to BOTH but how can i use "genie.GetEventData(&Event)" ? I dont understand.

  • tonton81
    replied
    dont run doevents within the handler. are you looking for when the user lets go? if so in workshop set the winbutton to BOTH and look for genie.GetEventData(&Event) of the userbutton event, if it's equal to 0, user let go, if its 1, user is holding it

    never run while loops in handler either

    Tony

    Leave a comment:

Working...
X