#pragma config(Sensor, S3, MSTP, sensorI2CCustom)
#include "drivers/mindsensors-touchpanel.h"
task main () {
nxtDisplayCenteredTextLine(0, "MindSensors");
nxtDisplayCenteredBigTextLine(1, "TouchPnl");
nxtDisplayCenteredTextLine(3, "Noise-a-Tron");
nxtDisplayCenteredTextLine(5, "Connect sensor");
nxtDisplayCenteredTextLine(6, "to S3");
wait1Msec(2000);
eraseDisplay();
int x, y = 0;
ubyte buttons = 0;
int multiplierX = 10;
int multiplierY = 10;
while (true) {
if (!MSTPgetTouch(MSTP, x, y, buttons))
PlaySound(soundBlip);
else if (isButtonTouched(buttons, BUTTON_L1))
multiplierX = 10;
else if (isButtonTouched(buttons, BUTTON_L2))
multiplierX = 15;
else if (isButtonTouched(buttons, BUTTON_L3))
multiplierX = 20;
else if (isButtonTouched(buttons, BUTTON_L4))
multiplierX = 25;
else if (isButtonTouched(buttons, BUTTON_R1))
multiplierY = 10;
else if (isButtonTouched(buttons, BUTTON_R2))
multiplierY = 15;
else if (isButtonTouched(buttons, BUTTON_R3))
multiplierY = 20;
else if (isButtonTouched(buttons, BUTTON_R4))
multiplierY = 25;
else if (x > 0 && y > 0)
{
PlayImmediateTone(x * multiplierX, 1);
wait1Msec(10);
PlayImmediateTone(y * multiplierY, 1);
nxtSetPixel(x, y);
}
EndTimeSlice();
}
}