Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1c53666

Browse files
sebromeroactions-user
authored andcommittedOct 29, 2024
Update documentation
1 parent 96572f1 commit 1c53666

File tree

1 file changed

+369
-0
lines changed

1 file changed

+369
-0
lines changed
 

‎docs/api.md

Lines changed: 369 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Summary
22

3+
* [buzzer](#modulino.buzzer)
4+
* [ModulinoBuzzer](#modulino.buzzer.ModulinoBuzzer)
5+
* [tone](#modulino.buzzer.ModulinoBuzzer.tone)
6+
* [no\_tone](#modulino.buzzer.ModulinoBuzzer.no_tone)
37
* [buttons](#modulino.buttons)
48
* [ModulinoButtons](#modulino.buttons.ModulinoButtons)
59
* [default\_long\_press\_duration](#modulino.buttons.ModulinoButtons.default_long_press_duration)
10+
* [set\_led\_status](#modulino.buttons.ModulinoButtons.set_led_status)
611
* [update](#modulino.buttons.ModulinoButtons.update)
12+
* [is\_pressed](#modulino.buttons.ModulinoButtons.is_pressed)
713
* [modulino](#modulino.modulino)
814
* [I2CHelper](#modulino.modulino.I2CHelper)
915
* [frequency](#modulino.modulino.I2CHelper.frequency)
@@ -21,15 +27,71 @@
2127
* [has\_default\_address](#modulino.modulino.Modulino.has_default_address)
2228
* [available\_devices](#modulino.modulino.Modulino.available_devices)
2329
* [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)
2442
* [pixels](#modulino.pixels)
2543
* [ModulinoColor](#modulino.pixels.ModulinoColor)
2644
* [\_\_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)
2755
* [thermo](#modulino.thermo)
2856
* [ModulinoThermo](#modulino.thermo.ModulinoThermo)
2957
* [measurements](#modulino.thermo.ModulinoThermo.measurements)
3058
* [relative\_humidity](#modulino.thermo.ModulinoThermo.relative_humidity)
3159
* [temperature](#modulino.thermo.ModulinoThermo.temperature)
3260

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=0xFFFF, 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+
3395
<a id="modulino.buttons.ModulinoButtons"></a>
3496

3597
## class `ModulinoButtons`
@@ -44,6 +106,21 @@ class ModulinoButtons(Modulino)
44106

45107
1 second
46108

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+
47124
<a id="modulino.buttons.ModulinoButtons.update"></a>
48125

49126
### `update`
@@ -55,6 +132,22 @@ def update()
55132
Update the button status and call the corresponding callbacks.
56133
Returns True if any of the buttons has changed its state.
57134

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+
58151
<a id="modulino.modulino.I2CHelper"></a>
59152

60153
## class `I2CHelper`
@@ -244,6 +337,141 @@ If the host board does a reset during such operation it can make the bus get stu
244337
Returns:
245338
I2C: A new i2c bus object after resetting the bus.
246339

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+
247475
<a id="modulino.pixels.ModulinoColor"></a>
248476

249477
## class `ModulinoColor`
@@ -262,6 +490,147 @@ def __int__()
262490

263491
Return the 32-bit integer representation of the color.
264492

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+
265634
<a id="modulino.thermo.ModulinoThermo"></a>
266635

267636
## class `ModulinoThermo`

0 commit comments

Comments
 (0)
Please sign in to comment.