Skip to content

Commit 430b395

Browse files
Rocketctfacchinm
authored andcommitted
Added support for vibration power on modulino Vibro
1 parent afbf7d3 commit 430b395

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/Modulino.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
#define HardwareI2C TwoWire
2323
#endif
2424

25+
typedef enum {
26+
STOP = 0,
27+
GENTLE = 25,
28+
MODERATE = 30,
29+
MEDIUM = 35,
30+
INTENSE = 40,
31+
POWERFUL = 45,
32+
MAXIMUM = 50
33+
} VibroPowerLevel;
34+
2535
void __increaseI2CPriority();
2636

2737
class ModulinoClass {
@@ -265,12 +275,23 @@ class ModulinoVibro : public Module {
265275
public:
266276
ModulinoVibro(uint8_t address = 0xFF)
267277
: Module(address, "VIBRO") {}
268-
void on(size_t len_ms) {
269-
uint8_t buf[8];
270-
uint32_t freq = 100;
278+
void on(size_t len_ms, bool block, int power = MAXIMUM ) {
279+
uint8_t buf[12];
280+
uint32_t freq = 1000;
271281
memcpy(&buf[0], &freq, 4);
272282
memcpy(&buf[4], &len_ms, 4);
273-
write(buf, 8);
283+
memcpy(&buf[8], &power, 4);
284+
write(buf, 12);
285+
if (block) {
286+
delay(len_ms);
287+
off();
288+
}
289+
}
290+
void on(size_t len_ms) {
291+
on(len_ms, false);
292+
}
293+
void on(size_t len_ms, VibroPowerLevel power) {
294+
on(len_ms, false, power);
274295
}
275296
void off() {
276297
uint8_t buf[8];

0 commit comments

Comments
 (0)