UCUq API #
IMPORTANT (really): the various methods below are only executed by the microcontroller when ucuq.commit()
is called.
GPIO
class
#
Manages an output corresponding to a microcontroller pin.
GPIO(<pin>)
(constructor): returns an object managing the pin identified by<pin>
;high()
: sets the pin to high state;low()
: sets the pin to the low state.
WS2812
class
#
Manages LEDs of type WS2812.
WS2812(<pin>,<count>)
(constructor): returns an object managing<count>
WS2812 LEDs connected to pin<pin>
;setValue(<index>, <value>)
: sets the LED of index<index>
(starting at 0) to color<value>
(in format[R,G,B]
from 0 to 255) in the buffer;fill(<value>)
: puts all LEDs at color<value>
in the buffer;write()
: sends buffer content to LEDs.
I2C
class
#
Manages the I2C protocol.
I2C(<sda>,<scl>)
(constructor): returns an object managing a component connected to the microcontroller pins identified by<sda>
and<scl>
and supporting the I2C protocol.
SoftI2C
class
#
Same as the I2C
class, but managed by software, so <sda>
and <scl>
can be any microcontroller GPIO pin.
HT16K33
class
#
Manages a HT16K33 component.
HT16K33(<i2c>)
(constructor): returns an object managing a HT16K33 component through<i2c>
which must be an instance ofI2C
orSoftI2C
;setBlinkRate(<rate>)
: defines as<rate>
the number of times per second that the display blinks (allowed values:0
,0.5
,1
and2
);setBrightness(<brightness>)
: sets<brightness>
as the display brightness (from0
and15
);clear()
: empties the display buffer;draw(<pattern>)
: places<pattern>
, which must be a sequence of hexadecimal characters each representing 4 pixels, in the display buffer;plot(<x>,<y>,<ink>)
: turns on if<ink>
is at1
or off if<ink>
is at0
the pixel at position<x>
,<y>
in the display buffer;show()
: sends the content of the buffer to the display.
PWM
class
#
Management of an output of type PWM.
PWM(<pin>,<freq>,*,ns=<ns>,u16=<u16>)
(constructor): returns an object generating a signal on an output of PWM type identified by<pin>
with a frequency of<freq>
Hz and with a pulse width of<ns>
nanoseconds or a ratio of<u16>
/ 65536 (<ns>
and<u16>
cannot be defined simultaneously);setU16(<u16>)
: generates a signal with a pulse width ratio of<u16>
/ 65536;setNS(<ns>)
: generates a signal with a pulse width of<ns>
nanoseconds;setFreq(<freq>)
: generates a signal with a frequency of<freq>
Hz.
LCD_PCF8574
class
#
Manages an LCD display based on a component of type PCF8574.
LCD_PCF8574(<i2c>,<lines>,<columns>)
(constructor): returns an object managing, through<i2c>
which must be an instance ofI2C
orSoftI2C
, a component of type PCF8574 connected to an LCD display of<lines>
rows and<columns>
columns;moveTo(x,y)
: positions the cursor on the<x>
line and the<y>
column;putString(<string>)
: displays the string<string>
;clear()
: clears the display;hideCursor()
: hides the cursor;showCursor()
: displays the cursor;blinkCursorOff()
: deactivates cursor blinking;blinkCursorOn()
: enables cursor blinking;backlightOff()
: deactivates backlight;backlightOn()
: enables backlight.
SSD1206_I2C
class
#
Manages an OLED screen via the I2C protocol.
SSD1206_I2C(<width>,<height>,<i2c>)
: returns an object managing an OLED screen of dimensions<width>
by<height>
through<i2c>
, which must be an instance ofI2C
orSoftI2C
;fill(<col>)
: fills the buffer with the<col>
color;pixel(<x>,<y>,<col>)
: sets the pixel at position<x>
,<y>
in the buffer to color<col>
;scroll(<dx>,<dy>)
: moves the pattern in the buffer by<dx>
,<dy>
pixels;text(<text>,<x>,<y>)
: places the string<text>
in the buffer at position<x>
,<y>
;rect(<x>,<y>,<w>,<h>,fill=<fill>
: places a rectangle of width<w>
and height<h>
at position<x>
,<y>
in the buffer and fills it if<fill>
andTrue
(default value);- show()`: sends the buffer contents to the display.