File tree 1 file changed +27
-6
lines changed
1 file changed +27
-6
lines changed Original file line number Diff line number Diff line change 18
18
#define HardwareI2C TwoWire
19
19
#endif
20
20
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
+
21
31
void __increaseI2CPriority ();
22
32
23
33
class ModulinoClass {
@@ -226,28 +236,39 @@ class ModulinoVibro : public Module {
226
236
public:
227
237
ModulinoVibro (uint8_t address = 0xFF )
228
238
: 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, VibroPowerLevel power = MAXIMUM ) {
240
+ uint8_t buf[12 ];
241
+ uint32_t freq = 1000 ;
232
242
memcpy (&buf[0 ], &freq, 4 );
233
243
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, VibroPowerLevel power) {
255
+ on (len_ms, false , power);
235
256
}
236
257
void off () {
237
258
uint8_t buf[8 ];
238
259
memset (&buf[0 ], 0 , 8 );
239
260
write (buf, 8 );
240
261
}
241
262
virtual uint8_t discover () {
242
- for (unsigned int i = 0 ; i < sizeof ( match)/ sizeof (match[ 0 ] ); i++) {
263
+ for (int i = 0 ; i < match. size ( ); i++) {
243
264
if (scan (match[i])) {
244
265
return match[i];
245
266
}
246
267
}
247
268
return 0xFF ;
248
269
}
249
270
protected:
250
- uint8_t match[ 1 ] = { 0x70 }; // same as fw main.c
271
+ std::vector< uint8_t > match = { 0x70 }; // same as fw main.c
251
272
};
252
273
253
274
class ModulinoColor {
You can’t perform that action at this time.
0 commit comments