RELEASED: 3RD PARTY NXC DRIVER SUITE V0.2
Posted: 05 Jun 2012, 20:48
hi @ all :)
this is my HT Touch Mux Driver - straight forward and simple to use:
test program:
share and enjoy :P
(... to be continued... )
this is my HT Touch Mux Driver - straight forward and simple to use:
Code: Select all
// excerpt from drivers.h
char HTTouchMuxValue(char port, char muxport) { // muxport= 0...3
long switches, value;
char muxtouch;
value=1023-SensorRaw(port);
switches=339*value;
switches/=1023-value;
switches+=5;
switches/=10;
return muxtouch=(switches & (1 << muxport))?1:0;
}
Code: Select all
// excerpt from stdio.h
#define printf2( _x, _y, _format1, _format2, _value1, _value2) { \
string sval1 = FormatNum(_format1, _value1); \
string sval2 = FormatNum(_format2, _value2); \
string s =sval1+sval2; \
TextOut(_x, _y, s); \
}
// excerpt from drivers.h
char HTTouchMuxValue(char port, char muxport) { // muxport= 0...3
long switches, value;
char muxtouch;
value=1023-SensorRaw(port);
switches=339*value;
switches/=1023-value;
switches+=5;
switches/=10;
return muxtouch=(switches & (1 << muxport))?1:0;
}
task main(){
char muxtouch;
SetSensor(S2, SENSOR_TOUCH);
while (true) {
for (int i=0; i<4; ++i) {
muxtouch = HTTouchMuxValue(S2, i);
printf2(0,40-(8*i), "switch%d="," %d", i+1, muxtouch);
Wait(50);
}
}
}
(... to be continued... )