Skip to content

Commit a84b86f

Browse files
Brent WilkinsBrent Wilkins
Brent Wilkins
authored and
Brent Wilkins
committed
Changed scope of enum
1 parent 6b6540d commit a84b86f

File tree

4 files changed

+22
-29
lines changed

4 files changed

+22
-29
lines changed

IDE_Board_Manager/package_sparkfun_index.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"category":"Contributed",
1717
"url":"https://github.com/sparkfun/Arduino_Boards/raw/master/IDE_Board_Manager/sparkfunboards.1.1.2.tar.bz2",
1818
"archiveFileName":"sparkfunboards.1.1.2.tar.bz2",
19-
"checksum":"SHA-256:b7d483353abd2aa2ad666729d1647cdbee8b1637dbb6d316ef6445ae103d7017",
20-
"size":"1138360",
19+
"checksum":"SHA-256:ff12b10a929f551b1383cba408ddc7535a9cb8b6224b09d8162b22fc3cd82b0e",
20+
"size":"1138406",
2121
"help":{
2222
"online":"https://forums.sparkfun.com"
2323
},
46 Bytes
Binary file not shown.

sparkfun/avr/libraries/Qduino/Qduino.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void qduino::setRGB(uint8_t r, uint8_t g, uint8_t b){
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);
@@ -98,39 +98,33 @@ void qduino::setRGB(colors color){
9898

9999
void qduino::rainbow(uint8_t duration)
100100
{
101-
unsigned int rgbColor[3];
102-
if (duration < 1)
103-
{
104-
duration = 1;
105-
}
106-
else if (duration > 5)
107-
{
108-
duration = 5;
109-
}
101+
uint8_t rgbColor[3];
110102

111-
unsigned int newDuration = map(duration, 1, 5, 500, 3000);
103+
// Keep values for duration bounded
104+
if (duration < 1) duration = 1;
105+
if (duration > 5) duration = 5;
106+
107+
int newDuration = map(duration, 1, 5, 500, 3000);
112108

113109
// Start off with red.
114110
rgbColor[0] = 255;
115111
rgbColor[1] = 0;
116112
rgbColor[2] = 0;
117113

118114
// Choose the colours to increment and decrement.
119-
for (int decColor = 0; decColor < 3; decColor += 1)
115+
for (uint8_t decColor = 0; decColor < 3; decColor += 1)
120116
{
121117
int incColor = decColor == 2 ? 0 : decColor + 1;
122118

123119
// cross-fade the two colours.
124-
for(int i = 0; i < 255; i += 1)
120+
for(uint8_t i = 0; i < 255; i += 1)
125121
{
126122
rgbColor[decColor] -= 1;
127123
rgbColor[incColor] += 1;
128124

129125
analogWrite(10, rgbColor[0]);
130126
analogWrite(11, rgbColor[1]);
131127
analogWrite(13, rgbColor[2]);
132-
Serial.print("newDuration: ");
133-
Serial.println(newDuration);
134128
delayMicroseconds(newDuration);
135129
}
136130
}

sparkfun/avr/libraries/Qduino/Qduino.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
#include "Arduino.h"
2121

22-
#ifndef _Qduino_h
23-
#define _Qduino_h
22+
#ifndef _QDUINO_H_
23+
#define _QDUINO_H_
2424

2525
#define MAX1704_ADDR 0x36
2626
#define MAX1704_SOC 0x04
@@ -31,23 +31,21 @@
3131
#define MAX1704_COMMAND 0xFE
3232
#define MAX1704_ALERT_LEVEL 0x97
3333

34-
enum colors
35-
{
36-
RED = 0, GREEN, BLUE, CYAN, PINK, WHITE, PURPLE, YELLOW, ORANGE
37-
};
34+
// Predefined named colors for use in setRGB method
35+
enum COLORS { RED, GREEN, BLUE, CYAN, PINK, WHITE, PURPLE, YELLOW, ORANGE };
3836

3937
class qduino
40-
{
38+
{
4139
public:
4240
void setup();
4341
void setRGB(uint8_t r, uint8_t g, uint8_t b);
44-
void setRGB(colors color);
45-
void rainbow(uint8_t duration);
42+
void setRGB(COLORS color);
43+
void rainbow(uint8_t duration); // [1,5] valid
4644
void ledOff();
4745
};
4846

49-
class fuelGauge{
50-
47+
class fuelGauge
48+
{
5149
public:
5250
int chargePercentage();
5351
void setup();
@@ -59,7 +57,8 @@ class fuelGauge{
5957
boolean inAlert();
6058
void goToSleep();
6159
void wakeUp();
62-
60+
61+
6362
private:
6463
void performCommand(byte address, int value);
6564
void readFrom(byte address, byte &msb, byte &lsb);

0 commit comments

Comments
 (0)