File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change 23
23
#define HardwareI2C TwoWire
24
24
#endif
25
25
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
+
26
36
void __increaseI2CPriority ();
27
37
28
38
class ModulinoClass {
@@ -266,12 +276,23 @@ class ModulinoVibro : public Module {
266
276
public:
267
277
ModulinoVibro (uint8_t address = 0xFF )
268
278
: 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 ;
272
282
memcpy (&buf[0 ], &freq, 4 );
273
283
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);
275
296
}
276
297
void off () {
277
298
uint8_t buf[8 ];
You can’t perform that action at this time.
0 commit comments