touch-detect-grid

bradzilla84/touch-adafruit/touch-detect-grid

Make a Grid of touch events.( Usefull for making Button grids..Keypads...Ect...)(Trigger different Pages/Events based on what button was Pressed)
touch-detect-grid
@/touch-detect-grid
Make a Grid of touch events.( Usefull for making Button grids..Keypads...Ect...)(Trigger different Pages/Events based on what button was Pressed)
Xnumber
X Input from touch Map.
Ynumber
Y Input from touch Map.
XGridNumbernumber
Number or Blocks/Buttons in the X Direction.
YGridNumbernumber
Number or Blocks/Buttons in the Y Direction.
XMinnumber
X Min of Grid Area.
YMinnumber
Y Min of Grid Area.
XMaxnumber
X Max of Grid Area.
YMaxnumber
X Max of Grid Area.
INITpulse
Check for Touch in Grid (Connect to the Touct-Detect block OK pin to keep things fast and clean.)
touch-detect-grid
GridNumber
GridX
GridY
TouchDetected
X
Y
XGridNumber
YGridNumber
XMin
YMin
XMax
YMax
INIT
TouchDetectedpulse
Pulse on Touch Detected in Grid
GridYnumber
Grid Y the touch was detected in.
GridXnumber
Grid X the touch was detected in.
GridNumbernumber
Grid number the touch was detected in.
To use the node in your project you should have the bradzilla84/touch-adafruit library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    // The node responds only if there is an input pulse
    if (!isInputDirty<input_INIT>(ctx))
        return;
    auto grids = (getValue<input_XGridNumber>(ctx) * getValue<input_YGridNumber>(ctx));
    auto gridPixSizeX =((getValue<input_XMax>(ctx) - getValue<input_XMin>(ctx)) / getValue<input_XGridNumber>(ctx));
    auto gridPixSizeY =((getValue<input_YMax>(ctx) - getValue<input_YMin>(ctx)) / getValue<input_YGridNumber>(ctx));
    auto gridnumber = 0;
    for (int gridy = 1; gridy <= getValue<input_YGridNumber>(ctx); gridy++) {
        for (int gridx = 1; gridx <= getValue<input_XGridNumber>(ctx); gridx++) {
            gridnumber++;
            if(getValue<input_Y>(ctx) < (gridPixSizeY * gridy)){
                if(getValue<input_X>(ctx) < (gridPixSizeX * gridx)){
                    emitValue<output_TouchDetected>(ctx, 1);
                    emitValue<output_GridNumber>(ctx, gridnumber);
                    emitValue<output_GridX>(ctx, gridx);
                    emitValue<output_GridY>(ctx, gridy);
                    return;
                }
            }
          }

      }





}