Skip to content

Commit 986f711

Browse files
committed
Added support for vibration power on modulino Vibro
1 parent 53aa89e commit 986f711

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
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 {
@@ -226,12 +236,23 @@ class ModulinoVibro : public Module {
226236
public:
227237
ModulinoVibro(uint8_t address = 0xFF)
228238
: Module(address, "VIBRO") {}
229-
void on(size_t len_ms) {
230-
uint8_t buf[8];
231-
uint32_t freq = 100;
239+
void on(size_t len_ms, bool block, int power = MAXIMUM ) {
240+
uint8_t buf[12];
241+
uint32_t freq = 1000;
232242
memcpy(&buf[0], &freq, 4);
233243
memcpy(&buf[4], &len_ms, 4);
234-
write(buf, 8);
244+
memcpy(&buf[8], &power, 4);
245+
write(buf, 12);
246+
if (block) {
247+
delay(len_ms);
248+
off();
249+
}
250+
}
251+
void on(size_t len_ms) {
252+
on(len_ms, false);
253+
}
254+
void on(size_t len_ms, int power) {
255+
on(len_ms, false, power);
235256
}
236257
void off() {
237258
uint8_t buf[8];

0 commit comments

Comments
 (0)