1
1
# Summary
2
2
3
+ * [ buzzer] ( #modulino.buzzer )
4
+ * [ ModulinoBuzzer] ( #modulino.buzzer.ModulinoBuzzer )
5
+ * [ tone] ( #modulino.buzzer.ModulinoBuzzer.tone )
6
+ * [ no\_ tone] ( #modulino.buzzer.ModulinoBuzzer.no_tone )
3
7
* [ buttons] ( #modulino.buttons )
4
8
* [ ModulinoButtons] ( #modulino.buttons.ModulinoButtons )
5
9
* [ default\_ long\_ press\_ duration] ( #modulino.buttons.ModulinoButtons.default_long_press_duration )
10
+ * [ set\_ led\_ status] ( #modulino.buttons.ModulinoButtons.set_led_status )
6
11
* [ update] ( #modulino.buttons.ModulinoButtons.update )
12
+ * [ is\_ pressed] ( #modulino.buttons.ModulinoButtons.is_pressed )
7
13
* [ modulino] ( #modulino.modulino )
8
14
* [ I2CHelper] ( #modulino.modulino.I2CHelper )
9
15
* [ frequency] ( #modulino.modulino.I2CHelper.frequency )
21
27
* [ has\_ default\_ address] ( #modulino.modulino.Modulino.has_default_address )
22
28
* [ available\_ devices] ( #modulino.modulino.Modulino.available_devices )
23
29
* [ reset\_ bus] ( #modulino.modulino.Modulino.reset_bus )
30
+ * [ knob] ( #modulino.knob )
31
+ * [ ModulinoKnob] ( #modulino.knob.ModulinoKnob )
32
+ * [ reset] ( #modulino.knob.ModulinoKnob.reset )
33
+ * [ update] ( #modulino.knob.ModulinoKnob.update )
34
+ * [ range] ( #modulino.knob.ModulinoKnob.range )
35
+ * [ on\_ rotate\_ clockwise] ( #modulino.knob.ModulinoKnob.on_rotate_clockwise )
36
+ * [ on\_ rotate\_ counter\_ clockwise] ( #modulino.knob.ModulinoKnob.on_rotate_counter_clockwise )
37
+ * [ on\_ press] ( #modulino.knob.ModulinoKnob.on_press )
38
+ * [ on\_ release] ( #modulino.knob.ModulinoKnob.on_release )
39
+ * [ value] ( #modulino.knob.ModulinoKnob.value )
40
+ * [ value] ( #modulino.knob.ModulinoKnob.value )
41
+ * [ pressed] ( #modulino.knob.ModulinoKnob.pressed )
24
42
* [ pixels] ( #modulino.pixels )
25
43
* [ ModulinoColor] ( #modulino.pixels.ModulinoColor )
26
44
* [ \_\_ int\_\_ ] ( #modulino.pixels.ModulinoColor.__int__ )
45
+ * [ ModulinoPixels] ( #modulino.pixels.ModulinoPixels )
46
+ * [ set\_ range\_ rgb] ( #modulino.pixels.ModulinoPixels.set_range_rgb )
47
+ * [ set\_ range\_ color] ( #modulino.pixels.ModulinoPixels.set_range_color )
48
+ * [ set\_ all\_ rgb] ( #modulino.pixels.ModulinoPixels.set_all_rgb )
49
+ * [ set\_ all\_ color] ( #modulino.pixels.ModulinoPixels.set_all_color )
50
+ * [ set\_ color] ( #modulino.pixels.ModulinoPixels.set_color )
51
+ * [ set\_ rgb] ( #modulino.pixels.ModulinoPixels.set_rgb )
52
+ * [ clear] ( #modulino.pixels.ModulinoPixels.clear )
53
+ * [ clear\_ all] ( #modulino.pixels.ModulinoPixels.clear_all )
54
+ * [ show] ( #modulino.pixels.ModulinoPixels.show )
27
55
* [ thermo] ( #modulino.thermo )
28
56
* [ ModulinoThermo] ( #modulino.thermo.ModulinoThermo )
29
57
* [ measurements] ( #modulino.thermo.ModulinoThermo.measurements )
30
58
* [ relative\_ humidity] ( #modulino.thermo.ModulinoThermo.relative_humidity )
31
59
* [ temperature] ( #modulino.thermo.ModulinoThermo.temperature )
32
60
61
+ <a id =" modulino.buzzer.ModulinoBuzzer " ></a >
62
+
63
+ ## class ` ModulinoBuzzer `
64
+
65
+ ``` python
66
+ class ModulinoBuzzer (Modulino )
67
+ ```
68
+
69
+ <a id ="modulino .buzzer .ModulinoBuzzer .tone "></a >
70
+
71
+ ### `tone `
72
+
73
+ ```python
74
+ def tone (frequency , lenght_ms = 0x FFFF , blocking = False )
75
+ ```
76
+
77
+ Plays a tone with the given frequency and duration .
78
+ If blocking is set to True , the function will wait until the tone is finished .
79
+
80
+ Parameters :
81
+ frequency: The frequency of the tone in Hz
82
+ lenght_ms: The duration of the tone in milliseconds
83
+ blocking: If set to True , the function will wait until the tone is finished
84
+
85
+ < a id = " modulino.buzzer.ModulinoBuzzer.no_tone" >< / a>
86
+
87
+ # ## `no_tone`
88
+
89
+ ```python
90
+ def no_tone ()
91
+ ```
92
+
93
+ Stops the current tone from playing.
94
+
33
95
<a id =" modulino.buttons.ModulinoButtons " ></a >
34
96
35
97
## class ` ModulinoButtons `
@@ -44,6 +106,21 @@ class ModulinoButtons(Modulino)
44
106
45
107
1 second
46
108
109
+ <a id ="modulino .buttons .ModulinoButtons .set_led_status "></a >
110
+
111
+ ### `set_led_status `
112
+
113
+ ```python
114
+ def set_led_status (a , b , c )
115
+ ```
116
+
117
+ Turn on or off the button LEDs according to the given status .
118
+
119
+ Parameters :
120
+ a (bool ): The status of the LED A.
121
+ b (bool ): The status of the LED B.
122
+ c (bool ): The status of the LED C.
123
+
47
124
< a id = " modulino.buttons.ModulinoButtons.update" >< / a>
48
125
49
126
# ## `update`
@@ -55,6 +132,22 @@ def update()
55
132
Update the button status and call the corresponding callbacks.
56
133
Returns True if any of the buttons has changed its state.
57
134
135
+ Returns:
136
+ bool: True if any of the buttons has changed its state.
137
+
138
+ <a id =" modulino.buttons.ModulinoButtons.is_pressed " ></a >
139
+
140
+ ### ` is_pressed `
141
+
142
+ ``` python
143
+ def is_pressed (index )
144
+ ```
145
+
146
+ Returns True if the button at the given index is currently pressed.
147
+
148
+ Parameters:
149
+ index (int): The index of the button. A = 0, B = 1, C = 2.
150
+
58
151
<a id =" modulino.modulino.I2CHelper " ></a >
59
152
60
153
## class ` I2CHelper `
@@ -244,6 +337,141 @@ If the host board does a reset during such operation it can make the bus get stu
244
337
Returns:
245
338
I2C: A new i2c bus object after resetting the bus.
246
339
340
+ <a id =" modulino.knob.ModulinoKnob " ></a >
341
+
342
+ ## class ` ModulinoKnob `
343
+
344
+ ``` python
345
+ class ModulinoKnob (Modulino )
346
+ ```
347
+
348
+ <a id ="modulino .knob .ModulinoKnob .reset "></a >
349
+
350
+ ### `reset `
351
+
352
+ ```python
353
+ def reset ()
354
+ ```
355
+
356
+ Resets the encoder value to 0.
357
+
358
+ <a id ="modulino .knob .ModulinoKnob .update "></a >
359
+
360
+ ### `update `
361
+
362
+ ```python
363
+ def update ()
364
+ ```
365
+
366
+ Reads new data from the Modulino and calls the corresponding callbacks
367
+ if the encoder value or pressed status has changed .
368
+
369
+ <a id ="modulino .knob .ModulinoKnob .range "></a >
370
+
371
+ ### `range `
372
+
373
+ ```python
374
+ @range .setter
375
+ def range (value )
376
+ ```
377
+
378
+ Sets the range of the encoder value .
379
+
380
+ Parameters :
381
+ value (tuple ): A tuple with two integers representing the minimum and maximum values of the range .
382
+
383
+ < a id = " modulino.knob.ModulinoKnob.on_rotate_clockwise" >< / a>
384
+
385
+ # ## `on_rotate_clockwise`
386
+
387
+ ```python
388
+ @on_rotate_clockwise.setter
389
+ def on_rotate_clockwise (value )
390
+ ```
391
+
392
+ Sets the callback for the rotate clockwise event.
393
+
394
+ Parameters:
395
+ value (function): The function to be called when the encoder is rotated clockwise.
396
+
397
+ <a id =" modulino.knob.ModulinoKnob.on_rotate_counter_clockwise " ></a >
398
+
399
+ ### ` on_rotate_counter_clockwise `
400
+
401
+ ``` python
402
+ @on_rotate_counter_clockwise.setter
403
+ def on_rotate_counter_clockwise (value )
404
+ ```
405
+
406
+ Sets the callback for the rotate counter clockwise event.
407
+
408
+ Parameters:
409
+ value (function): The function to be called when the encoder is rotated counter clockwise.
410
+
411
+ <a id =" modulino.knob.ModulinoKnob.on_press " ></a >
412
+
413
+ ### ` on_press `
414
+
415
+ ``` python
416
+ @on_press.setter
417
+ def on_press (value )
418
+ ```
419
+
420
+ Sets the callback for the press event.
421
+
422
+ Parameters:
423
+ value (function): The function to be called when the encoder is pressed.
424
+
425
+ <a id =" modulino.knob.ModulinoKnob.on_release " ></a >
426
+
427
+ ### ` on_release `
428
+
429
+ ``` python
430
+ @on_release.setter
431
+ def on_release (value )
432
+ ```
433
+
434
+ Sets the callback for the release event.
435
+
436
+ Parameters:
437
+ value (function): The function to be called when the encoder is released.
438
+
439
+ <a id =" modulino.knob.ModulinoKnob.value " ></a >
440
+
441
+ ### ` value `
442
+
443
+ ``` python
444
+ @ property
445
+ def value ()
446
+ ```
447
+
448
+ Returns the current value of the encoder.
449
+
450
+ <a id =" modulino.knob.ModulinoKnob.value " ></a >
451
+
452
+ ### ` value `
453
+
454
+ ``` python
455
+ @value.setter
456
+ def value (new_value )
457
+ ```
458
+
459
+ Sets the value of the encoder. This overrides the previous value.
460
+
461
+ Parameters:
462
+ new_value (int): The new value of the encoder.
463
+
464
+ <a id =" modulino.knob.ModulinoKnob.pressed " ></a >
465
+
466
+ ### ` pressed `
467
+
468
+ ``` python
469
+ @ property
470
+ def pressed ()
471
+ ```
472
+
473
+ Returns the pressed status of the encoder.
474
+
247
475
<a id =" modulino.pixels.ModulinoColor " ></a >
248
476
249
477
## class ` ModulinoColor `
@@ -262,6 +490,147 @@ def __int__()
262
490
263
491
Return the 32-bit integer representation of the color .
264
492
493
+ <a id ="modulino .pixels .ModulinoPixels "></a >
494
+
495
+ ## class `ModulinoPixels `
496
+
497
+ ```python
498
+ class ModulinoPixels (Modulino )
499
+ ```
500
+
501
+ <a id ="modulino .pixels .ModulinoPixels .set_range_rgb "></a >
502
+
503
+ ### `set_range_rgb `
504
+
505
+ ```python
506
+ def set_range_rgb (index_from , index_to , r , g , b , brightness = 100 )
507
+ ```
508
+
509
+ Sets the color of the LEDs in the given range to the given RGB values .
510
+
511
+ Parameters :
512
+ index_from (int ): The starting index of the range .
513
+ index_to (int ): The ending index (inclusive) of the range .
514
+ r (int ): The red value of the color.
515
+ g (int ): The green value of the color.
516
+ b (int ): The blue value of the color.
517
+ brightness (int ): The brightness of the LED . It should be a value between 0 and 100 .
518
+
519
+ < a id = " modulino.pixels.ModulinoPixels.set_range_color" >< / a>
520
+
521
+ # ## `set_range_color`
522
+
523
+ ```python
524
+ def set_range_color (index_from , index_to , color , brightness = 100 )
525
+ ```
526
+
527
+ Sets the color of the LEDs in the given range to the given color.
528
+
529
+ Parameters:
530
+ index_from (int): The starting index of the range.
531
+ index_to (int): The ending index (inclusive) of the range.
532
+ color (ModulinoColor): The color of the LEDs.
533
+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
534
+
535
+ <a id =" modulino.pixels.ModulinoPixels.set_all_rgb " ></a >
536
+
537
+ ### ` set_all_rgb `
538
+
539
+ ``` python
540
+ def set_all_rgb (r , g , b , brightness = 100 )
541
+ ```
542
+
543
+ Sets the color of all the LEDs to the given RGB values.
544
+
545
+ Parameters:
546
+ r (int): The red value of the color.
547
+ g (int): The green value of the color.
548
+ b (int): The blue value of the color.
549
+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
550
+
551
+ <a id =" modulino.pixels.ModulinoPixels.set_all_color " ></a >
552
+
553
+ ### ` set_all_color `
554
+
555
+ ``` python
556
+ def set_all_color (color , brightness = 100 )
557
+ ```
558
+
559
+ Sets the color of all the LEDs to the given color.
560
+
561
+ Parameters:
562
+ color (ModulinoColor): The color of the LEDs.
563
+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
564
+
565
+ <a id =" modulino.pixels.ModulinoPixels.set_color " ></a >
566
+
567
+ ### ` set_color `
568
+
569
+ ``` python
570
+ def set_color (idx , rgb : ModulinoColor, brightness = 100 )
571
+ ```
572
+
573
+ Sets the color of the given LED index to the given color.
574
+
575
+ Parameters:
576
+ idx (int): The index of the LED.
577
+ rgb (ModulinoColor): The color of the LED.
578
+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
579
+
580
+ <a id =" modulino.pixels.ModulinoPixels.set_rgb " ></a >
581
+
582
+ ### ` set_rgb `
583
+
584
+ ``` python
585
+ def set_rgb (idx , r , g , b , brightness = 100 )
586
+ ```
587
+
588
+ Set the color of the given LED index to the given RGB values.
589
+
590
+ Parameters:
591
+ idx (int): The index of the LED.
592
+ r (int): The red value of the color.
593
+ g (int): The green value of the color.
594
+ b (int): The blue value of the color.
595
+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
596
+
597
+ <a id =" modulino.pixels.ModulinoPixels.clear " ></a >
598
+
599
+ ### ` clear `
600
+
601
+ ``` python
602
+ def clear (idx )
603
+ ```
604
+
605
+ Turns off the LED at the given index.
606
+
607
+ Parameters:
608
+ idx (int): The index of the LED.
609
+
610
+ <a id =" modulino.pixels.ModulinoPixels.clear_all " ></a >
611
+
612
+ ### ` clear_all `
613
+
614
+ ``` python
615
+ def clear_all ()
616
+ ```
617
+
618
+ Turns all the LEDs off.
619
+
620
+ Parameters:
621
+ idx (int): The index of the LED
622
+
623
+ <a id =" modulino.pixels.ModulinoPixels.show " ></a >
624
+
625
+ ### ` show `
626
+
627
+ ``` python
628
+ def show ()
629
+ ```
630
+
631
+ Applies the changes to the LEDs. This function needs to be called after any changes to the LEDs.
632
+ Otherwise, the changes will not be visible.
633
+
265
634
<a id =" modulino.thermo.ModulinoThermo " ></a >
266
635
267
636
## class ` ModulinoThermo `
0 commit comments