Skip to content

Commit

Permalink
Better Arduino compatability: Changed to order of the Wire.begin and …
Browse files Browse the repository at this point in the history
…Wire.pins parameters to

match the [Arduino order](samples/DS3232RTC_NTP_Setter/app/application.cpp).

Related to SmingHub#1179 and SmingHub#1061.

Warning: this is a backward incompatible change.
  • Loading branch information
slav-at-attachix committed Jul 18, 2017
1 parent 8fe2d3a commit 8948a88
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Sming/SmingCore/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ TwoWire::TwoWire(){}

// Public Methods //////////////////////////////////////////////////////////////

void TwoWire::begin(int scl, int sda){
void TwoWire::begin(int sda, int scl){
default_sda_pin = sda;
default_scl_pin = scl;
twi_init(sda, scl);
flush();
}

void TwoWire::pins(int scl, int sda){
void TwoWire::pins(int sda, int scl){
default_sda_pin = sda;
default_scl_pin = scl;
}

void TwoWire::begin(void){
begin(default_scl_pin, default_sda_pin);
begin(default_sda_pin, default_scl_pin);
}

void TwoWire::begin(uint8_t address){
Expand Down
4 changes: 2 additions & 2 deletions Sming/SmingCore/Wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class TwoWire : public Stream
static void onReceiveService(uint8_t*, int);
public:
TwoWire();
void begin(int scl, int sda);
void pins(int scl, int sda);
void begin(int sda, int scl);
void pins(int sda, int scl);
void begin();
void begin(uint8_t);
void begin(int);
Expand Down
2 changes: 1 addition & 1 deletion samples/Accelerometer_MMA7455/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void init()
Serial.println("Starting...");

// You can change pins:
//Wire.pins(12, 14); // SCL, SDA
//Wire.pins(14, 12); // SDA, SCL
Wire.begin();

// Select the Working Mode
Expand Down
2 changes: 1 addition & 1 deletion samples/Arducam/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void initCam() {
Serial.printf("ArduCAM init!");

// initialize I2C
Wire.pins(CAM_SCL, CAM_SDA);
Wire.pins(CAM_SDA, CAM_SCL);
Wire.begin();

//Check if the camera module type is OV2640
Expand Down
4 changes: 2 additions & 2 deletions samples/Basic_ScannerI2C/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ void init()

WDT.enable(false); // First (but not the best) option: fully disable watch dog timer

// Default I2C pins (SCL:0 , SDA: 2)
// Default I2C pins (SDA: 2, SCL:0)

// You can change pins:
//Wire.pins(12, 14); // SCL, SDA
//Wire.pins(14, 12); // SDA, SCL

Wire.begin();
procTimer.initializeMs(3000, scanBus).start();
Expand Down
2 changes: 1 addition & 1 deletion samples/DS3232RTC_NTP_Setter/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void init()
{
Serial.begin(SERIAL_BAUD_RATE);
Serial.println("Sming DSRTC_NTP_SETTER started!");
Wire.pins(0, 2); //Change to your SCL - 0,SDA - 2 GPIO pin number
Wire.pins(2, 0); //Change to your SDA - 2, SCL - 0 GPIO pin number
Wire.begin();

// Station - WiFi client
Expand Down
2 changes: 1 addition & 1 deletion samples/Humidity_AM2321/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void init()
delay(500);

// Apply I2C pins
Wire.pins(SCL, SDA);
Wire.pins(SDA, SCL);
Wire.begin();

am2321.begin(); // REQUIRED. Call it after choosing I2C pins.
Expand Down
2 changes: 1 addition & 1 deletion samples/Humidity_SI7021/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void init()
Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
Serial.systemDebugOutput(true); // Allow debug output to serial
Serial.print("Start I2c");
Wire.pins(I2C_SCL, I2C_SDA); // SCL, SDA
Wire.pins(I2C_SDA, I2C_SCL); // SDA, SCL
Wire.begin();
procTimer_ht.initializeMs(10000, si_read_ht).start();
procTimer_olt.initializeMs(15000, si_read_olt).start();
Expand Down
2 changes: 1 addition & 1 deletion samples/MeteoControl_mqtt/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void init()
{
Serial.begin(SERIAL_BAUD_RATE); // 115200 by default

Wire.pins(5, 4); // SCL, SDA
Wire.pins(4, 5); // SDA, SCL
Wire.begin();

// initialization config
Expand Down
2 changes: 1 addition & 1 deletion samples/PortExpander_MCP23017/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void init()
Serial.begin(115200);

// You can select ESP I2C pins here:
//Wire.pins(4, 5); // SCL, SDA
//Wire.pins(5, 4); // SDA, SCL

mcp.begin(0); // 0 - for default mcp address, possible values: 0..7

Expand Down

0 comments on commit 8948a88

Please sign in to comment.