UCUq API #
Functions #
sleep(delay): the microcontroller waits for<delay>seconds before executing the next instruction;sleepStart(): starts a timer (to be used in conjunction withsleepWait(…));sleepWait(delay): the microcontroller waits for<delay>seconds to elapse since the lastsleepStart()was called before executing the next instruction.
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(<count>,<pin>)(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>(a list or a tuples of formatR,G,Bfrom 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 ofI2CorSoftI2C;setBlinkRate(<rate>): defines as<rate>the number of times per second that the display blinks (allowed values:0,0.5,1and2);setBrightness(<brightness>): sets<brightness>as the display brightness (from0and15);clear(): empties the display buffer;draw(<pattern>): places<pattern>, which must be a sequence of hexadecimal characters, each representing 4 horizontal pixels, in the display buffer;plot(<x>,<y>,<ink>): turns on if<ink>is at1or off if<ink>is at0the 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 of frequency<freq>Hz and with a pulse width of<ns>nanoseconds or a ratio of<u16>/ 65536 on an output of PWM type identified by<pin>(<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.
HD44780_I2C class
#
Manages an LCD display based on the HD44780 controller through the I2C protocol.
HD44780_I2C(<columns>,<lines>,<i2c>)(constructor): returns an object managing, through<i2c>which must be an instance ofI2CorSoftI2C, a HD44780 controller connected to an LCD display of<lines>rows and<columns>columns;moveTo(x,y): positions the cursor on the<x>column and the<y>line;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;ttyWrite(text, delay=.2, hideCursorOnEnd=True): writes<text>, character by character, with a delay of<delay>seconds between each character, and hides the cursor after the last character is displayed if<hideCursorOnEnd>is set toTrue.
SSD1306_I2C class
#
Manages an OLED display via the I2C protocol.
SSD1306_I2C(<width>,<height>,<i2c>): returns an object managing an OLED display of dimensions<width>by<height>through<i2c>, which must be an instance ofI2CorSoftI2C;ellipse(x, y, rx, ry, col, fill=False, quad=15): draws an ellipse centered at<x>,<y>, with a radius of<rx>,<ry>, and of color<col>, filled iffillisTrue, and only in the quadrants where the bits in<quad>are set to 1;fill(<col>): fills the buffer with the<col>color;line(x1, y1, x2, y2, col): draws a line in the color<col>from the position<x1>,<y1>to the position<x2>,<y2>;pixel(<x>,<y>,<col>): sets the pixel at position<x>,<y>in the buffer to color<col>;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.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>;
SH1106_I2C class
#
Same as SSD1306_I2C, but for a display of type SH1106.
Buzzer class
#
Controls a passive buzzer.
Buzzer(pwm): (constructor) returns an object that controls a passive buzzer via<pwm>, which must be an instance ofPWM;on(freq): emits a sound with a frequency of<freq>Hertz;play(note): plays a sound at the frequency corresponding to the MIDI note<note>;off(): mutes the sound.