Connect two SIMHUB devices using I2C.#43
Conversation
…angedEvents are resended to IC2 with the same serial protocol.
|
is this replacing serial with i2c? |
| } | ||
|
|
||
| void I2CustomPacketStart(byte packetType, uint8_t length) { | ||
| Wire.write(0x09); |
There was a problem hiding this comment.
the whole point of StreamWrite is to be able to replace it with whatever you need (in this case Wire.write), so that you don't have to add much custom code here :)
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
…(basic impl ) and a buffer.
Only if the device is configured as I2C Master. |
|
This is very interesting, thanks for adding the description. I was wondering what the approach was going to be on the other side. |
I'm using the original Arduino in the other Side with Joystick support enabled. But thats impl isn't complete yet, with buttons is working in the other side fine. I'm planning to add the serial protocol decoder/bypasser to Joystick support in this repo. The next commit is preparing the files for this approach. Off course slave in arduino needs updates too to work properly with this approach, beause the decode phase and slave config must be implemented. This works is in progress, i hope to send it to SimHub's developer if he has a repo to include in his codebase. ---- HOW TO INTEGRATE THE SLAVE INTO THE SIMHUB AVR PROJECT ---- You can checkout the slave logic, in the 99a49f8 commit, this logic is attached to the original arduino simhub project in the DisplayClientV2.ino after ading de SimHubProtocolDecoder.h to the project. Later you make an instance in the ino about de EventCallBackManager and setup de callback functions defined in the ino like the "buttonStatusChanged" via the setter for the event. Finally you must configrate de I2C channel with the correct address and attach the callback function for the I2C request in the setup() section. The I2C callback function is now this, can be directy a call to decodeBuffer contained in the SimHubProtocolDecoder.h
|
… impl on the slave, working with arduino AVR impl.
…ro will be overriden later. The default behaviour about stream, is read all the stream an send to StreamWrite(buffer,buffersize) method, seems that stream.write(buf,size) is stream compliant and must be implemented in all the stream transport layer that maybe used to comunicate with SIMHUB.
sync upstream
sync with upstream
…SS_MASTER IS ENABLED
I2c encoders

The underlying idea is to extend the digital or analog inputs and outputs to connect more devices together and make them compatible with the serial protocol used by SimHub. To achieve this, we connect two devices (for now, only two) using I2C, so that the Master sends its information via I2C to the Slave, which decodes and forwards this byte stream through the configured transport layer.
Features:
- [TBD] Bypass analog readings from master -> slave with custom serial protocol.