Skip to content

Commit 8de1ba6

Browse files
committed
rebuild examples for release
1 parent 2467d43 commit 8de1ba6

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

examples/halloween/halloween.ino

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* If you're looking around for a last minute Halloween light flasher for the pumpkin, I use LEDs in the pumpkin because
3+
* if it is not left too long I have the chance of making soup from it, without it being tainted by candle smoke.
4+
*
5+
* This program just requires 4 LEDs that are attached to PWM capable pins with suitable resistors, if you use an Uno,
6+
* or other 5V board that would be around 330R. The LEDs randomly flash using task manager to schedule at random
7+
* intervals. Tested in my pumpkin and works fairly well. Enjoy!
8+
*/
9+
#include <TaskManagerIO.h>
10+
11+
class LedControlTask : public Executable {
12+
private:
13+
pintype_t pin;
14+
bool inverted;
15+
int maxDelay;
16+
public:
17+
LedControlTask(pintype_t pin, bool inverted = false, int maxDelay = 256): pin(pin), inverted(inverted), maxDelay(maxDelay) {
18+
}
19+
20+
void init() {
21+
taskManager.execute(this);
22+
pinMode(pin, OUTPUT);
23+
}
24+
25+
void exec() override {
26+
int levelThisTime = rand() % 255;
27+
int delayThisTime = rand() % maxDelay;
28+
29+
analogWrite(pin, levelThisTime);
30+
31+
taskManager.scheduleOnce(delayThisTime, this);
32+
}
33+
};
34+
35+
LedControlTask blueLed(6);
36+
LedControlTask redLed(5);
37+
LedControlTask greenLed(11, true);
38+
LedControlTask yellowLed(10);
39+
40+
void setup() {
41+
blueLed.init();
42+
redLed.init();
43+
greenLed.init();
44+
yellowLed.init();
45+
}
46+
47+
void loop() {
48+
taskManager.runLoop();
49+
}

src/TaskPlatformDeps.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99

1010
class TimerTask;
1111

12+
// You can add your own local definitions header file here, this enables you to adjust build flags in environments
13+
// where there is no easy way to do so with compiler options. Just create an include file "io_local_definitions.h"
14+
// at the top level of your project source tree. This file will be honoured by all our libraries.
15+
#if defined __has_include
16+
# if __has_include ("zio_local_definitions.h")
17+
# include "zio_local_definitions.h"
18+
# endif
19+
#endif // has include "io_local_definitions"
20+
1221
// when not on mbed, we need to load Arduino.h to get the right defines for some boards.
1322
#ifndef __MBED__
1423
#include <Arduino.h>

0 commit comments

Comments
 (0)