Skip to content

Commit b70ec83

Browse files
committed
add examples
1 parent b8fd010 commit b70ec83

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
"examples/Pattern",
3030
"examples/Pattern2",
3131
"examples/FadingBlink",
32+
"examples/CustomSpeed",
33+
"examples/SpeedAdjustment",
3234
]
3335

3436
# Steps represent a sequence of tasks that will be executed as part of the job

examples/CustomSpeed/CustomSpeed.ino

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <Indicator.h>
2+
3+
Indicator led(13);
4+
SpeedSetting mySettings = {
5+
.on_ms = 100,
6+
.off_ms = 100,
7+
.pause_ms = 2000,
8+
.ending_ms = 2000,
9+
};
10+
11+
void setup()
12+
{
13+
// blink 2x on repeat with custom settings
14+
led.pattern(2, true, mySettings);
15+
}
16+
17+
void loop()
18+
{
19+
led.update();
20+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <FadeIndicator.h>
2+
3+
FadeIndicator led(13);
4+
5+
uint32_t lastSwitch;
6+
bool isFast;
7+
8+
void setup()
9+
{
10+
isFast = false;
11+
lastSwitch = millis();
12+
13+
led.blink(SPEED_SLOW);
14+
}
15+
16+
void loop()
17+
{
18+
led.update();
19+
20+
// toggle speed every 3 seconds
21+
if (millis() - lastSwitch > 3000)
22+
{
23+
lastSwitch = millis();
24+
isFast = !isFast;
25+
led.blink(isFast ? SPEED_FAST : SPEED_SLOW);
26+
}
27+
}

src/FadeIndicator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class FadeIndicator : public BaseFadeIndicator
77
{
88
public:
9-
FadeIndicator(int pin, bool logarithmic = true, int fade_speed = 20)
9+
FadeIndicator(int pin, bool logarithmic = true, int fade_speed = 30)
1010
: BaseFadeIndicator(logarithmic, fade_speed), pin_(pin)
1111
{
1212
pinMode(pin_, OUTPUT);

src/Indicator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class Indicator : public BaseIndicator
1515
void write(int state) override
1616
{
1717
digitalWrite(pin_, state ^ invert_);
18-
Serial.println(state);
1918
}
2019

2120
private:

0 commit comments

Comments
 (0)