What's wrong with John's official HT Touch mux support?
If you want the switch you're reading to be a number-indexed array, why not use array elements as the parameters? The way you set it up, you aren't even using an array (you're just number indexing a bit mask).
Also, how come you use "msk=(2<<muxport)/2;" instead of "msk = 1 << muxport;"? Is there any functional difference? I can't think of any, except execution time.
I must say, I am impressed that you programmed drivers for something
Arrays? I don't use arrays. Why should I use arrays?
I don't want to use arrays - I find my access to mux touchers much much easier:
access each single sensor by the nxt-port-number of the muxer and by its mux-port-number.
Any sensor at any muxer should be accessible by that scheme.
Also I don't find John's drivers if I search for them by pressing F1 or searching through the built-in help (also other people - at least in Germany - do neither).
Was there already a JH touch mux driver? I didn't find it so far.
msk = 1 << muxport is better, your right, my own formula was developed by trial and error.
oh sh** that was part of a different piece of code of an older algorithm which I copied and pasted - forget it at this place...!
(I once had to access a set of variables counting through them in a loop, so then I would rather use an array than a couple of single values)
and - oh man:
mattallen37 wrote:What's wrong with John's official HT Touch mux support?
Read touch sensor values from the HiTechnic touch multiplexer device.
Parameters:
port The sensor port. See Input port constants.
t1 The value of touch sensor 1.
t2 The value of touch sensor 2.
t3 The value of touch sensor 3.
t4 The value of touch sensor 4.
I have to pass 4 sensor value variables by "reference" if I want to read just 1 sensor?
that's really hard stuff... ;)