Skip to content

Commit 44ee0ea

Browse files
Rocketctfacchinm
authored andcommitted
Added support for vibration power on modulino Vibro
1 parent 650968e commit 44ee0ea

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
@@ -23,6 +23,16 @@
2323
#define HardwareI2C TwoWire
2424
#endif
2525

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

2838
class ModulinoClass {
@@ -266,12 +276,23 @@ class ModulinoVibro : public Module {
266276
public:
267277
ModulinoVibro(uint8_t address = 0xFF)
268278
: Module(address, "VIBRO") {}
269-
void on(size_t len_ms) {
270-
uint8_t buf[8];
271-
uint32_t freq = 100;
279+
void on(size_t len_ms, bool block, int power = MAXIMUM ) {
280+
uint8_t buf[12];
281+
uint32_t freq = 1000;
272282
memcpy(&buf[0], &freq, 4);
273283
memcpy(&buf[4], &len_ms, 4);
274-
write(buf, 8);
284+
memcpy(&buf[8], &power, 4);
285+
write(buf, 12);
286+
if (block) {
287+
delay(len_ms);
288+
off();
289+
}
290+
}
291+
void on(size_t len_ms) {
292+
on(len_ms, false);
293+
}
294+
void on(size_t len_ms, int power) {
295+
on(len_ms, false, power);
275296
}
276297
void off() {
277298
uint8_t buf[8];

0 commit comments

Comments
 (0)