Closed Juarezdoposto closed 3 years ago
No, you don't need definition. These definitions are just a way to automate executing digitalRead()
/analogRead()
. So you can just add your ibus.write()
(before ibus.end()
)
all ibus.write() does is push a 16 bit value onto the frame. The contents of that Word (u/int16) can be anything you need it to be.
your 10 bit ADC signal is probably using the Bottom of its var (LSB of Word = LSB of ADC value).
so you probably need no preprocessing if your values are stored in an int16 some pseudocode
IBus ibus(2);
uint16_t accelX = i2c.read(accelerometer(0));
uint16_t accelY = i2c.read(accelerometer(1));
ibus.begin();
ibus.write(accelX);
ibus.write(accelY);
ibus.end();
BTW I don't think I've documented this yet but it turned out that IBUS uses 12bit channels (0 - 4095). This leaves 4 bits unused from every two bytes.
Chan1 | Chan2 | Chan3 | ||||||
LSB Byte | MSB Byte | LSB Byte | MSB Byte | LSB Byte | MSB Byte | |||
low 8 bits | unused 4bits | high 4 bits | low 8 bits | unused 4bits | high 4 bits | low 8 bits | unused 4bits | high 4 bits |
What flysky are doing is that they take the three times of 4 unused bits and pack there another 12bit channel. Now vjsf by default unpacks these 4bits as channels.
When using Arduino such packing is too much work. Instead we can simply use the channels as 16-bit values (this is how vjsf used to work). To activate the old behavior, from Setup
next to the IBUS
protocol, the "use 16-bit .... " must be checked.
all ibus.write() does is push a 16 bit value onto the frame. The contents of that Word (u/int16) can be anything you need it to be.
your 10 bit ADC signal is probably using the Bottom of its var (LSB of Word = LSB of ADC value).
so you probably need no preprocessing if your values are stored in an int16 some pseudocode
IBus ibus(2); uint16_t accelX = i2c.read(accelerometer(0)); uint16_t accelY = i2c.read(accelerometer(1)); ibus.begin(); ibus.write(accelX); ibus.write(accelY); ibus.end();
In the case of sending HIGH or LOW values the idea would be the same?
I also didnt undertand the use of :
ibus.write(digitalRead(digitalPins[i]) == HIGH ? 1023 : 0);
The ? operator turns the HIGH on a int value?
The ? operator turns the HIGH on a int value?
Yes
digitalRead(digitalPins[i]) == HIGH ? 1023 : 0
means:
if (digitalRead(digitalPins[i])) == HIGH)
return 1023;
else
return 0;
My project worked,very thank you,im going to mention ya work on my instructables
Considering that the values i have are converted to 10bit signal that are the kind of signals retrivied by a analog input.and defining the 2 channels for x and y of the joystick, can i just send my sensor values on ibus.write() or i have to declare a pin for it(with is senseless cause the comunication with the sensor is i2c)?