Hello,
I want to read the position of a joystick. 0 shall be middle, negative (-127) shall be left and positive (127) shall be right. So I want to read the result of the analog input into a signed integer variable.
(The “joystick” driver doesn’t help, it has only two channels and returns doubles.)
My idea is to read the eight MSB of the ADC result into an sbyte with MSB toggled:
Is that (or something similar) possible?
(I don't want to convert a 12 bit fixpoint value to a 64 bit floating point value and then back to an 8 bit fixpoint value...)
Probably you missunderstood my question.
My FEZ Cerberus has one (or more) 12 bit ADC which produces a 12 bit fixpoint value. My question is: How can I read this value without converting it to a floating point value?
Microsoft.SPOT.Hardware.AnalogInput input = new Microsoft.SPOT.Hardware.AnalogInput(Microsoft.SPOT.Hardware.CPU.AnalogChannel.ANALOG_0);
int position = input.ReadRaw();
Thanks, Bec a Fuel!
My next proplem is: How can I use the gadgeteer socket numbers instead of “[…]AnalogChannel.ANALOG_0”? (FEZ Cerberus and probably some other gadgeteer mainboards)