Skip to content

Commit 975722d

Browse files
committed
Remove unnecessary Wire.endTransmission()
Remove unnecessary Wire.endTransmission()
1 parent 05079ae commit 975722d

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

sparkfun/avr/Qduino/Qduino.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* mattnewberry@me.com *
88
* *
99
***************************************************************************
10-
* *
10+
* *
1111
* This program is free software; you can redistribute it and/or modify *
1212
* it under the terms of the GNU License. *
1313
* This program is distributed in the hope that it will be useful, *
@@ -22,7 +22,7 @@
2222
#include "Wire.h"
2323

2424
void qduino::setup(){
25-
25+
2626
pinMode(13, OUTPUT);
2727
digitalWrite(13, HIGH);
2828
pinMode(11, OUTPUT);
@@ -32,21 +32,21 @@ void qduino::setup(){
3232
}
3333

3434
void qduino::setRGB(uint8_t r, uint8_t g, uint8_t b){
35-
35+
3636
// ratio for R:G:B is 4:7:7 for forward voltage
37-
37+
3838
r = 255 - r; // set all values to opposite values
3939
g = 255 - g; // because LED is common anode
4040
b = 255 - b;
41-
41+
4242
int newr = map(r, 0, 255, 0, 146);
43-
43+
4444
analogWrite(10, newr);
4545
analogWrite(11, g);
4646
analogWrite(13, b);
4747
}
4848

49-
void qduino::setRGB(COLORS color){
49+
void qduino::setRGB(COLORS color){
5050
switch (color) {
5151
case RED:
5252
analogWrite(10, 0);
@@ -97,31 +97,31 @@ void qduino::setRGB(COLORS color){
9797
}
9898

9999
void qduino::rainbow(uint8_t duration)
100-
{
100+
{
101101
uint8_t rgbColor[3];
102102

103103
// Keep values for duration bounded
104104
if (duration < 1) duration = 1;
105105
if (duration > 5) duration = 5;
106-
106+
107107
int newDuration = map(duration, 1, 5, 500, 3000);
108-
108+
109109
// Start off with red.
110110
rgbColor[0] = 255;
111111
rgbColor[1] = 0;
112-
rgbColor[2] = 0;
113-
112+
rgbColor[2] = 0;
113+
114114
// Choose the colours to increment and decrement.
115115
for (uint8_t decColor = 0; decColor < 3; decColor += 1)
116116
{
117117
int incColor = decColor == 2 ? 0 : decColor + 1;
118-
118+
119119
// cross-fade the two colours.
120120
for(uint8_t i = 0; i < 255; i += 1)
121121
{
122122
rgbColor[decColor] -= 1;
123123
rgbColor[incColor] += 1;
124-
124+
125125
analogWrite(10, rgbColor[0]);
126126
analogWrite(11, rgbColor[1]);
127127
analogWrite(13, rgbColor[2]);
@@ -131,7 +131,7 @@ void qduino::rainbow(uint8_t duration)
131131
}
132132

133133
void qduino::ledOff()
134-
{
134+
{
135135
analogWrite(10, 255);
136136
analogWrite(11, 255);
137137
analogWrite(13, 255);
@@ -167,7 +167,7 @@ char fuelGauge::getVersion()
167167
byte msb = 0;
168168
byte lsb = 0;
169169
readFrom(MAX1704_VERSION, msb, lsb);
170-
170+
171171
value = 0xFF00 & (msb<<8);
172172
value |= 0xFF & lsb;
173173

@@ -211,7 +211,7 @@ boolean fuelGauge::inSleep()
211211
byte lsb = 0;
212212

213213
readFrom(MAX1704_CONFIG,msb,lsb);
214-
byte sleep = (lsb >>7) & 0x01;
214+
byte sleep = (lsb >>7) & 0x01;
215215

216216
return int(sleep) == 1;
217217
}
@@ -256,7 +256,7 @@ void fuelGauge::wakeUp()
256256
Wire.endTransmission();
257257

258258
// This delay is here to ensure it's fully awake before moving on
259-
delay(150);
259+
delay(150);
260260
}
261261

262262
void fuelGauge::performCommand(byte address, int value)
@@ -281,6 +281,5 @@ void fuelGauge::readFrom(byte address, byte &msb, byte &lsb)
281281
msb = Wire.read();
282282
lsb = Wire.read();
283283
}
284-
Wire.endTransmission();
284+
//Wire.endTransmission();
285285
}
286-

sparkfun/avr/libraries/Qduino/Qduino.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* mattnewberry@me.com *
88
* *
99
***************************************************************************
10-
* *
10+
* *
1111
* This program is free software; you can redistribute it and/or modify *
1212
* it under the terms of the GNU License. *
1313
* This program is distributed in the hope that it will be useful, *
@@ -22,7 +22,7 @@
2222
#include "Wire.h"
2323

2424
void qduino::setup(){
25-
25+
2626
pinMode(13, OUTPUT);
2727
digitalWrite(13, HIGH);
2828
pinMode(11, OUTPUT);
@@ -32,21 +32,21 @@ void qduino::setup(){
3232
}
3333

3434
void qduino::setRGB(uint8_t r, uint8_t g, uint8_t b){
35-
35+
3636
// ratio for R:G:B is 4:7:7 for forward voltage
37-
37+
3838
r = 255 - r; // set all values to opposite values
3939
g = 255 - g; // because LED is common anode
4040
b = 255 - b;
41-
41+
4242
int newr = map(r, 0, 255, 0, 146);
43-
43+
4444
analogWrite(10, newr);
4545
analogWrite(11, g);
4646
analogWrite(13, b);
4747
}
4848

49-
void qduino::setRGB(COLORS color){
49+
void qduino::setRGB(COLORS color){
5050
switch (color) {
5151
case RED:
5252
analogWrite(10, 0);
@@ -97,31 +97,31 @@ void qduino::setRGB(COLORS color){
9797
}
9898

9999
void qduino::rainbow(uint8_t duration)
100-
{
100+
{
101101
uint8_t rgbColor[3];
102102

103103
// Keep values for duration bounded
104104
if (duration < 1) duration = 1;
105105
if (duration > 5) duration = 5;
106-
106+
107107
int newDuration = map(duration, 1, 5, 500, 3000);
108-
108+
109109
// Start off with red.
110110
rgbColor[0] = 255;
111111
rgbColor[1] = 0;
112-
rgbColor[2] = 0;
113-
112+
rgbColor[2] = 0;
113+
114114
// Choose the colours to increment and decrement.
115115
for (uint8_t decColor = 0; decColor < 3; decColor += 1)
116116
{
117117
int incColor = decColor == 2 ? 0 : decColor + 1;
118-
118+
119119
// cross-fade the two colours.
120120
for(uint8_t i = 0; i < 255; i += 1)
121121
{
122122
rgbColor[decColor] -= 1;
123123
rgbColor[incColor] += 1;
124-
124+
125125
analogWrite(10, rgbColor[0]);
126126
analogWrite(11, rgbColor[1]);
127127
analogWrite(13, rgbColor[2]);
@@ -131,7 +131,7 @@ void qduino::rainbow(uint8_t duration)
131131
}
132132

133133
void qduino::ledOff()
134-
{
134+
{
135135
analogWrite(10, 255);
136136
analogWrite(11, 255);
137137
analogWrite(13, 255);
@@ -167,7 +167,7 @@ char fuelGauge::getVersion()
167167
byte msb = 0;
168168
byte lsb = 0;
169169
readFrom(MAX1704_VERSION, msb, lsb);
170-
170+
171171
value = 0xFF00 & (msb<<8);
172172
value |= 0xFF & lsb;
173173

@@ -211,7 +211,7 @@ boolean fuelGauge::inSleep()
211211
byte lsb = 0;
212212

213213
readFrom(MAX1704_CONFIG,msb,lsb);
214-
byte sleep = (lsb >>7) & 0x01;
214+
byte sleep = (lsb >>7) & 0x01;
215215

216216
return int(sleep) == 1;
217217
}
@@ -256,7 +256,7 @@ void fuelGauge::wakeUp()
256256
Wire.endTransmission();
257257

258258
// This delay is here to ensure it's fully awake before moving on
259-
delay(150);
259+
delay(150);
260260
}
261261

262262
void fuelGauge::performCommand(byte address, int value)
@@ -281,6 +281,5 @@ void fuelGauge::readFrom(byte address, byte &msb, byte &lsb)
281281
msb = Wire.read();
282282
lsb = Wire.read();
283283
}
284-
Wire.endTransmission();
284+
//Wire.endTransmission();
285285
}
286-

0 commit comments

Comments
 (0)