-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmindsensors-touchpanel-test1.c
73 lines (64 loc) · 2.03 KB
/
mindsensors-touchpanel-test1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma config(Sensor, S3, MSTP, sensorI2CCustom)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*
* $Id: mindsensors-touchpanel-test1.c 133 2013-03-10 15:15:38Z xander $
*/
/**
* mindsensors-touchpanel.h provides an API for the Mindsensors TouchPanel. This program
* demonstrates how to use that API.
*
* Changelog:
* - 0.1: Initial release
*
* Credits:
* - Big thanks to Mindsensors for providing me with the hardware necessary to write and test this.
*
* License: You may use this code as you wish, provided you give credit where it's due.
*
* THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER.
* Xander Soldaat (xander_at_botbench.com)
* 30 November 2011
* version 0.1
*/
#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();
}
}