This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

draw two point an uniline on lcd of stm32f429

hi all membres i want draw on the lcd of stm32f429Zit two point and after that i want draw a uniline between this two point i try with this code but i got only 1 point can anyone help me ?

void drawtwopoint()
{  TP_STATE* TP_State;

int i=0;
        int xx[2],yy[2] ;
  while (1)
  { TP_State = IOE_TP_GetState();
    if((!TP_State->TouchDetected) && ((TP_State->Y < 245) && (TP_State->Y >= 3)))
    {TP_State = IOE_TP_GetState();
      if((TP_State->X >= 237) || (TP_State->X < 3))
      {}
      else
      {
          while (i!=2)

          {
          xx[i]= TP_State->X;
        yy[i] = TP_State->Y;
        LCD_DrawFullCircle(xx[i] ,yy[i], 6);
                i=i+1;
        }
       LCD_DrawUniLine(xx[0] ,yy[0],xx[1],yy[1]);
         }
          }
    }
}

Parents
  • int i=0;
    int xx[2],yy[2];
    
    while (i!=2) {
        TP_State = IOE_TP_GetState();
    
        if (TP_State->TouchDetected) {
            xx[i]=TP_State->X;
            yy[i]=TP_State->Y;
            if ((TP_State->X >= 237) || (TP_State->X < 3)) {
            } else {
                LCD_DrawFullCircle(TP_State->X, TP_State->Y ,6);
                i=i+1;
            }
        }
        if (!TP_State->TouchDetected)     <=== what use is this for?
            continue;
    }
    LCD_DrawUniLine(xx[0],yy[0],xx[1],yy[1]);
    

    Notice that the part with the continue doesn't do anything - remove the two lines and the while statement will still repeat.

    And why do you have your "negated" logic where the if statement leads to a dummy empty block with the real code in the else block?
    Why check if x is too close to the border - why not instead if x is not too close to the border? Then the if block will do the job and no else part will be needed.
    If the goal is to test "should I draw", then it's obviously better to test for that, instead of testing for "should I not draw"...

Reply
  • int i=0;
    int xx[2],yy[2];
    
    while (i!=2) {
        TP_State = IOE_TP_GetState();
    
        if (TP_State->TouchDetected) {
            xx[i]=TP_State->X;
            yy[i]=TP_State->Y;
            if ((TP_State->X >= 237) || (TP_State->X < 3)) {
            } else {
                LCD_DrawFullCircle(TP_State->X, TP_State->Y ,6);
                i=i+1;
            }
        }
        if (!TP_State->TouchDetected)     <=== what use is this for?
            continue;
    }
    LCD_DrawUniLine(xx[0],yy[0],xx[1],yy[1]);
    

    Notice that the part with the continue doesn't do anything - remove the two lines and the while statement will still repeat.

    And why do you have your "negated" logic where the if statement leads to a dummy empty block with the real code in the else block?
    Why check if x is too close to the border - why not instead if x is not too close to the border? Then the if block will do the job and no else part will be needed.
    If the goal is to test "should I draw", then it's obviously better to test for that, instead of testing for "should I not draw"...

Children
No data