Skip to content

Commit 39ced7a

Browse files
Modification to allow SSD1306 example to compile, following changes to Wire to use HWire by default. Note this code is only known to compile , it may not work with the SSD1306 display
1 parent d635631 commit 39ced7a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

STM32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ All text above, and the splash screen below must be included in any redistributi
2222
//#endif
2323
#include <stdlib.h>
2424

25-
//#include <HWIRE.h>
26-
#include <HardWire.h>
25+
//#include <Wire.h>
26+
#include <Wire.h>
2727
//HardWire HWIRE(1,I2C_FAST_MODE); // I2c1
28-
HardWire HWIRE(2,I2C_FAST_MODE); // I2c2
28+
//HardWire HWIRE(2,I2C_FAST_MODE); // I2c2
2929
#include "Adafruit_GFX.h"
3030
#include "Adafruit_SSD1306_STM32.h"
3131

@@ -197,7 +197,7 @@ void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
197197
else
198198
{
199199
// I2C Init
200-
HWIRE.begin();
200+
Wire.begin();
201201

202202
#ifdef __SAM3X8E__
203203
// Force 400 KHz I2C, rawr! (Uses pins 20, 21 for SDA, SCL)
@@ -359,10 +359,10 @@ void Adafruit_SSD1306::ssd1306_command(uint8_t c) {
359359
{
360360
// I2C
361361
uint8_t control = 0x00; // Co = 0, D/C = 0
362-
HWIRE.beginTransmission(_i2caddr);
362+
Wire.beginTransmission(_i2caddr);
363363
WIRE_WRITE(control);
364364
WIRE_WRITE(c);
365-
HWIRE.endTransmission();
365+
Wire.endTransmission();
366366
}
367367
}
368368

@@ -473,10 +473,10 @@ void Adafruit_SSD1306::ssd1306_data(uint8_t c) {
473473
{
474474
// I2C
475475
uint8_t control = 0x40; // Co = 0, D/C = 1
476-
HWIRE.beginTransmission(_i2caddr);
476+
Wire.beginTransmission(_i2caddr);
477477
WIRE_WRITE(control);
478478
WIRE_WRITE(c);
479-
HWIRE.endTransmission();
479+
Wire.endTransmission();
480480
}
481481
}
482482

@@ -525,14 +525,14 @@ void Adafruit_SSD1306::display(void) {
525525
// I2C
526526
for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
527527
// send a bunch of data in one xmission
528-
HWIRE.beginTransmission(_i2caddr);
528+
Wire.beginTransmission(_i2caddr);
529529
WIRE_WRITE(0x40);
530530
for (uint8_t x=0; x<16; x++) {
531531
WIRE_WRITE(buffer[i]);
532532
i++;
533533
}
534534
i--;
535-
HWIRE.endTransmission();
535+
Wire.endTransmission();
536536
}
537537
/*
538538
#ifndef __SAM3X8E__

STM32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ All text above, and the splash screen must be included in any redistribution
1818

1919
#if ARDUINO >= 100
2020
#include "Arduino.h"
21-
#define WIRE_WRITE HWIRE.write
21+
#define WIRE_WRITE Wire.write
2222
#else
2323
#include "WProgram.h"
24-
#define WIRE_WRITE HWIRE.send
24+
#define WIRE_WRITE Wire.send
2525
#endif
2626
/*
2727
#ifdef __SAM3X8E__

0 commit comments

Comments
 (0)