Comments (8)
I will add a call to set the I2C speed. This is the function from the Wire library.
void twi_setFrequency(uint32_t frequency)
{
TWBR = ((F_CPU / frequency) - 16) / 2;
/* twi bit rate formula from atmega128 manual pg 204
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
note: TWBR should be 10 or higher for master mode
It is 72 for a 16mhz Wiring board with 100kHz TWI */
}
The comment implies this works from about 40 kHz to 444,000 kHz with FCPU = 16 MHz.
from ssd1306ascii.
The above function works on any AVR board without including Wire.
To set 100 kHz on a 16 MHz AVR board you can just add a line like this.
TWBR = 72;
I have added a setClock() call to the AvrI2c so you will be able do the following in the next version of SSD1306AsciiAvrI2c.
oled.setI2cClock(100000L);
from ssd1306ascii.
I just do :
Wire.setClock(2500000L);
to change the i2c speed to my favorite speed (Yes I need High speed)
from ssd1306ascii.
KK but I'm not using Wire, just SSD1306Ascii and SSD1306AsciiAvrI2c
from ssd1306ascii.
@greiman
will
oled.setI2cClock(100000L);
affects communication with my other I2c devices too or just the SSD1306 ?
I want to use different speeds for my various slower devices. Today I speed up the clock when talking to the SSD1306 and reduce the speed just after to allow my other devices to work
from ssd1306ascii.
deladriere
Changing the I2C frequency on an AVR board is global. There is a single TWBR baud rate register. You must set the I2C frequency in your program before using a device.
MasterBlatter
I published an update that allows setting the I2C frequency with AvrI2c.
There are two methods.
You can change the default frequency by editing SSD1306Ascii.h.
/** AvrI2c uses 400 kHz fast mode if AVRI2C_FASTMODE is nonzero else 100 kHz. */
#define AVRI2C_FASTMODE 1
You can call oled.setI2cClock(frequency) in your sketch.
from ssd1306ascii.
@greiman
Thanks for the update
My board is a SAMD21 clone and I cannot have a global change of speed because my other device is slower than the display.
So I guess I'll stay with Wire.setClock(high-speed); before driving any SSD1306 command and Wire.setClock(low-speed); just after them
from ssd1306ascii.
deladriere
I guess this is a universal problem for Wire on all boards.
Too bad the Wire library is not like SPI. The SPI beginTransaction() protocol insures each device uses the proper clock.
from ssd1306ascii.
Related Issues (20)
- When using a display with more than 64 pixels in the Y direction, the lcdHeight parameter is ignored. HOT 6
- Changing I2C pins HOT 1
- Arduino Pro Micro 32U4 and oled.clear(); HOT 1
- Some functions seem to need pixels as a parameter and not row/column character numbers? HOT 3
- Is there any function that returns data from the display? (to verify the display is somewhat functional in init) HOT 2
- Issues Initializing Multiple OLEDs HOT 4
- 1.3" SSH1106 Compatibility HOT 1
- How to make 3 lines of text as large as possible HOT 2
- Support for 0.42" OLED 72x40
- Limiting display decimals, float with 1 decimal, not 2, using oled.print HOT 10
- When using the ssd1306AvrI2c library, the avr hangs indefinitely HOT 4
- Is there interest in Supporting the ATTiny1614 et al?
- How to use u8g2_font_unifont_t_chinese Chinese character library HOT 2
- degrees celsius symbol HOT 3
- Software i2c HOT 4
- 70x42 OLED ? HOT 8
- Begin() return error if OLED not connected/found. HOT 2
- Text height HOT 2
- Two oled 128x32 sharing the same address 0x3C connected to ESP32
- Compiling error with Arduino nano every (ATMega4809) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ssd1306ascii.