Announcement

Collapse
No announcement yet.

Form 0 not displaying correctly after running Arduino code to disable some buttons

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

  • Form 0 not displaying correctly after running Arduino code to disable some buttons

    I have an Arduino Uno connected to an uLCD-35DT Diablo display.
    Whenever I run the code below to disable buttons on Form 1 the display on Form 0 does some funny things and does not look normal. If I switch to a different form and back to Form 0 to refresh the display this fixes the issue with Form 0.
    I have uploaded screen images,
    Form 0 Before Buttons are disabled.jpg - shows what Form 0 should normally look like.
    Form 0 After Buttons are disabled.jpg - shows what happens to Form 0 after the buttons on Form 1 are disabled.

    Below is the code I use to disable the buttons on Form 1.

    // disable all watering time select buttons other than 5 min
    if(T5Disable_Watering_Buttons == 1 & (Start_Watering == 1 || Start_Watering_Sequence == 1))
    {
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 3, -1); // if the 5min watering button is selected and watering is started then diable the 10 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 4, -1); // if the 5min watering button is selected and watering is started then diable the 15 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 5, -1); // if the 5min watering button is selected and watering is started then diable the 20 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 6, -1); // if the 5min watering button is selected and watering is started then diable the 25 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 7, -1); // if the 5min watering button is selected and watering is started then diable the 30 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 8, -1); // if the 5min watering button is selected and watering is started then diable the 35 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 9, -1); // if the 5min watering button is selected and watering is started then diable the 40 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 10, -1); // if the 5min watering button is selected and watering is started then diable the 45 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 11, -1); // if the 5min watering button is selected and watering is started then diable the 50 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 12, -1); // if the 5min watering button is selected and watering is started then diable the 55 min time button
    genie.WriteObject(GENIE_OBJ_WINBUTTON, 13, -1); // if the 5min watering button is selected and watering is started then diable the 60 min time button
    T5Disable_Watering_Buttons = 0;

    If I comment out the above code the issue disappears.
    Attached also is the Visie Genie project.

    Does anyone know why this could be occurring?

    Attached Files

  • #2
    Hi Rob,

    A quick look on the if statement, it seems that you are missing one '&' logical operator there. It should be:
    Code:
    if(T5Disable_Watering_Buttons == 1 && (Start_Watering == 1 || Start_Watering_Sequence == 1))
    To get a better picture of the whole problem, could you please post your complete Arduino source?

    Thanks and kind regards,
    Sherwin

    Comment


    • RobC
      RobC commented
      Editing a comment
      Hi Sherwin,
      Thanks for your help.
      I take your point, however the code as I have written it will still work with a single &. This is because I am not performing any arithmetic operations with the integers.
      I am only performing logical operations with the integers and the integers will only ever have a value of "1" or "0", nothing else.
      I tried changing the background colour on Form 0 from grey to black to see if this made a difference. It did not make any difference.
      Attached is the source code.

      I did try the code with the double && and i did not make any difference. Still seeing the same effect.

      Just to let you know I get around the problem by doing a screen refresh using the following code:
      genie.WriteObject(GENIE_OBJ_FORM, 1, 0); // Force a refresh of Form 0, when the buttons are disabled Form 0 goes patchy in it's appearance
      genie.WriteObject(GENIE_OBJ_FORM, 0, 0); // Force a refresh of Form 0, when the buttons are disabled Form 0 goes patchy in it's appearance
      Last edited by RobC; 1 week ago. Reason: added extra comments about screen refresh

  • #3
    Rather than manually disabling all the other time buttons, why not just put all the time buttons in the same Matrix so that only one can be on at a time? That would eliminate a lot of code for you and would just let the display handle it.

    -K

    Comment


    • RobC
      RobC commented
      Editing a comment
      Hi Kad,
      Thanks for your help. I have already setup the buttons in a matrix. What I should have said is that I wanted to not display the buttons after the watering sequence has started.

    • kad
      kad commented
      Editing a comment
      Got it.

  • #4
    Arduino source doe attached.
    Attached Files

    Comment


    • #5
      Hi Rob,

      I tested your ViSi-Genie project with GTX tool. I found nothing wrong when I disable Winbutton 3 to 13 at Form1 while on Form0.

      Looking at the attached Arduino source, the if statement logical condition is not changed to:
      Code:
      // disable all watering time select buttons other than 5 min
      if(T5Disable_Watering_Buttons == 1 && (Start_Watering == 1 || Start_Watering_Sequence == 1))
      Attached is the modified Arduino source.

      Kind regards,
      Sherwin
      Attached Files

      Comment


      • #6
        Hi Sherwin
        I tried your sketch. It does not make any difference, I still see the same effects.
        It's got me beat, so I am just going with the screen refresh solution I mentioned before.

        Comment


        • sherwin4D
          sherwin4D commented
          Editing a comment
          Hi Rob,

          Glad you found a workaround. Thanks for the update.

          Best regards,
          -Sherwin
      Working...
      X