![]() They still do not belong in a ISR, because the I2C bus is slow. Then you have to use those software I2C calls in the loop(). (2) Use the u8g2 library and use its software I2C code optimized for displays. (1) Use a software I2C library for the display. It is possible to get far away from interrupt problems: Are you reading data from a microSD card ? What is wrong with the code in your loop(). In case of the latter, what solution would you propose to be able to read many rotary encoders? ![]() I've done some research online, and all of the posts seem to end with: "Don't do the I☬ transmission in the ISR, just set a flag and handle it in the main loop", which is of course a valid point, but that's just not possible in this case, because the OLED I☬ transmissions take up so much time in the loop.ĭo you think trying to get this working is worth it (is it even possible at all?), or am I just wasting my time? Calculate encoder deltas and update positions. ![]() Wait for MCP23017 I☬ transmission to finish. ![]() Start I☬ transmission to read MCP23017 input registers.Wait for OLED I☬ transmission to finish.MCP23017 interrupt fires → inside of ISR.Would it be possible to do the following: ISR(TWI_vect) is where the actual transmission of the data happens, asynchronously ( source).twi_writeTo waits for any previous I☬ transmissions to finish, configures the TWI FSM, configures the TWI interrupts, and finally waits until the transmission is complete ( source).TwoWire::endTransmission calls twi_writeTo ( source).TwoWire::write writes data to the buffer and increments the index ( source).TwoWire::beginTransmission just resets the buffer indices ( source).This is because the Wire library relies on interrupts to work correctly: However, the problem is that I cannot use I☬ in the ISR. The MCP23017 has interrupt outputs to indicate that the input registers have changed, so far so good. I believe using external interrupts is the only option here, because my loop is way too slow to poll. I would like to add eight rotary encoders using an MCP23017. Most of time in my loop is spent transmitting the frame buffer to the display. I'm driving an SSD1306 display over I☬ using the Adafruit_SSD1306 library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |