Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. change color with a gesture 1D
Qt 6.11 is out! See what's new in the release blog

change color with a gesture 1D

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 252 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VenAle17
    wrote on last edited by
    #1

    Hi all,
    i have this situation:

    void Luce::gesture(int result)
    {
    
        int valore[1000]= {0};
        for (int i = 0;i< 1001;i++) {
          valore[i] = result;
        }
    
         int primo = valore[0];
         int ultimo = valore[999];
         qDebug()<< primo << ultimo << endl;
         if (primo != ultimo)
         {
           on_pushButton_released();
         }
    
         else {
             return;
         }
    }
    
    

    I create this program that receives data (result) from a serial port.
    i want to create this gesture:
    if result is a decreasing data (so 'primo', the first value, is higher than 'ultimo', the last data of my array) my led has to change color. It should appears like a hand that get close and closer to the range sensor.
    I wrote this and compiled, but the program close forcefully and crashed.
    Any idea of why and how can i resolve it?
    Thanks to everybody.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VenAle17
      wrote on last edited by
      #2

      i worked on it and i change the code:

      int valore[100]= {0};
      int prev = 0 ;
      int next= 0 ;
      
      for (int i = 0;i< 100;i++)
          {
              if(i == 0)
                  {
                      next= prev;
                      valore[i] = 0;
                     //qDebug()<< "this is  if"<<endl;
                  }
              else {
                  valore[i] = result;  
                  prev = valore[i-1];
                  next = valore[i];             // qDebug()<< " this is else"<<endl;
      
                      if( prev > next)
                      {
                          qDebug()<<"this is my if 2"<<endl;
                          on_pushButton_released();
                      }
              }
          }
      
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved