Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions src/Modulino.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
#define HardwareI2C TwoWire
#endif

typedef enum {
STOP = 0,
GENTLE = 25,
MODERATE = 30,
MEDIUM = 35,
INTENSE = 40,
POWERFUL = 45,
MAXIMUM = 50
} VibroPowerLevel;

void __increaseI2CPriority();

class ModulinoClass {
Expand Down Expand Up @@ -226,12 +236,23 @@ class ModulinoVibro : public Module {
public:
ModulinoVibro(uint8_t address = 0xFF)
: Module(address, "VIBRO") {}
void on(size_t len_ms) {
uint8_t buf[8];
uint32_t freq = 100;
void on(size_t len_ms, bool block, int power = MAXIMUM ) {
uint8_t buf[12];
uint32_t freq = 1000;
memcpy(&buf[0], &freq, 4);
memcpy(&buf[4], &len_ms, 4);
write(buf, 8);
memcpy(&buf[8], &power, 4);
write(buf, 12);
if (block) {
delay(len_ms);
off();
}
}
void on(size_t len_ms) {
on(len_ms, false);
}
void on(size_t len_ms, int power) {
on(len_ms, false, power);
}
void off() {
uint8_t buf[8];
Expand Down
Loading