greiman / SSD1306Ascii

Text only Arduino Library for SSD1306 OLED displays
MIT License
500 stars 122 forks source link

Add support SoftWire for non AVR #108

Closed FREEWING-JP closed 1 year ago

FREEWING-JP commented 1 year ago

Add support SoftWire for non AVR

ESP32-C3 has only one I2C . I need more I2C . So I add this .

Tested with

Demo movie YouTube https://youtu.be/JHlt9EG22BI

greiman commented 1 year ago

I think I will implement this as a template. There are lots of Software Wire libraries and even some optional hardware libraries.

Here is a bit of my template test of hardware and software use.

#define SOFT_WIRE 1
#if SOFT_WIRE
SoftWire sw(SDA_PIN, SCL_PIN);
SSD1306AsciiWire<SoftWire> oled(sw);
#else
SSD1306AsciiWire<TwoWire> oled(Wire);
#endif
//------------------------------------------------------------------------------
void setup() {
#if SOFT_WIRE
  static uint8_t txBuffer[32];
  sw.setTxBuffer(txBuffer, 32);
  sw.begin();

#else
  Wire.begin();
  Wire.setClock(400000L);
#endif

The rest is just the HelloWorldWire example.

I will probably need a new class since I probably can't make templates like this work with the default TwoWire type.

SSD1306AsciiWire oled;

FREEWING-JP commented 1 year ago

I understand template . Solution of using template is Very Excellent . So I close this PR .

greiman commented 1 year ago

Thanks for suggesting support for Software I2c.

My search for I2C libraries I may be able to support includes these:

https://github.com/bxparks/AceWire

https://github.com/felias-fogg/SoftI2CMaster

https://github.com/RaemondBW/SWire

https://github.com/Seeed-Studio/Arduino_Software_I2C

https://github.com/stevemarple/SoftWire

https://github.com/Testato/SoftwareWire

https://github.com/thexeno/HardWire-Arduino-Library

https://github.com/todbot/SoftI2CMaster

There are many others. I will include an example that features many of the above. This should make it easy use others.

I plan to do a template for SPI also.

Edit: Look at AceWire It is a great resource.

FREEWING-JP commented 1 year ago

Wow ! What a variety ! This information is also very useful for me ! Thank you !

Edit: Look at AceWire It is a great resource.

I think so . Because it use interface .