Most-Pressed Algorithm

The mTouch Framework can be configured to only allow a single mTouch sensor to be activated at a time, if desired. If a matrix is being implemented, the matrix sensors will be separated from the non-matrixed sensors and only the non-matrixed sensors will be limited to one-pressed-at-a-time.

How It Works

The mTouch Framework will scan all sensors as normal. When a new set of readings is available, the framework will first perform some logic to determine which row and which column is the most pressed of the matrix. If both a row and column are activated, the state machine for the sensors will begin debouncing the result. After the required number of repeated results, the matrix coordinate-output will be updated.

Most-Pressed Algorithm Configuration

  1. Configure the matrix'd sensors to be scanned as normal sensors in the mTouch_config.h file. We will be defining index ranges for the rows and columns, so when configuring the MTOUCH_SENSORx list, make sure to place the matrix sensors as a continuous group starting at 0 or place at the very end with no 'normal' sensors after it. Within the matrix list, the rows should be grouped together and the columns should be grouped together.
  2. At the bottom of mTouch_config.h is the 'Decoding' section which contains the matrix configuration options.
    1. Uncomment MTOUCH_MOST_PRESSED_ONLY to enable the most-pressed algorithm on normal mTouch sensors.
      • Matrix sensors are automatically compared against fellow row and column sensors to find the most-pressed. This will not affect them.
      • Proximity sensors use a separate decode state machine and, so, are also excluded from this algorithm. This means you can have a matrix decoding normally, a proximity sensor providing constant data, and several 'normal' mTouch sensors that may only be activated one-at-a-time based on the highest shift value.
    2. Define MTOUCH_MOST_PRESSED_THRESHOLD with the number of counts that the most pressed sensor must be above the second-most-pressed sensor to activate the algorithm. If this value is set to 10 and the two most-pressed sensors shifts are only different by 5 counts, no sensors will be activated.

Example

 #define MTOUCH_MOST_PRESSED_ONLY
 #define MTOUCH_MOST_PRESSED_THRESHOLD   10

Most-Pressed Output

There are no special API or output macros for the most-pressed algorithm. Treat them as normal sensors.