Skip to content

Commit a913d08

Browse files
authored
Merge pull request #26 from Rocketct/vibro
Added support for vibration power on modulino Vibro
2 parents 060556e + deaabd6 commit a913d08

File tree

2 files changed

+1398
-1377
lines changed

2 files changed

+1398
-1377
lines changed

src/Modulino.h

+25-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
#define HardwareI2C TwoWire
1919
#endif
2020

21+
typedef enum {
22+
STOP = 0,
23+
GENTLE = 25,
24+
MODERATE = 30,
25+
MEDIUM = 35,
26+
INTENSE = 40,
27+
POWERFUL = 45,
28+
MAXIMUM = 50
29+
} VibroPowerLevel;
30+
2131
void __increaseI2CPriority();
2232

2333
class ModulinoClass {
@@ -242,12 +252,23 @@ class ModulinoVibro : public Module {
242252
public:
243253
ModulinoVibro(uint8_t address = 0xFF)
244254
: Module(address, "VIBRO") {}
245-
void on(size_t len_ms) {
246-
uint8_t buf[8];
247-
uint32_t freq = 100;
255+
void on(size_t len_ms, bool block, int power = MAXIMUM ) {
256+
uint8_t buf[12];
257+
uint32_t freq = 1000;
248258
memcpy(&buf[0], &freq, 4);
249259
memcpy(&buf[4], &len_ms, 4);
250-
write(buf, 8);
260+
memcpy(&buf[8], &power, 4);
261+
write(buf, 12);
262+
if (block) {
263+
delay(len_ms);
264+
off();
265+
}
266+
}
267+
void on(size_t len_ms) {
268+
on(len_ms, false);
269+
}
270+
void on(size_t len_ms, int power) {
271+
on(len_ms, false, power);
251272
}
252273
void off() {
253274
uint8_t buf[8];

0 commit comments

Comments
 (0)