This library is a collection for the Raspberry Pi Pico for several modules on the Joy-Pi Advanced. See here for more information.
Note
This repository includes all necessary libraries which are needed for the Joy-Pi Advanced with the Raspberry Pi Pico. Libraries from other authors are marked as such.
| Repository | Needed for |
|---|---|
ADC_TLA2518 |
Library to use the Analog-Digital-Converter |
ICG1020S |
Library to use the gyroscope |
MCP23008 |
Library to use the buton matrix |
I2CLCD |
Library to use the 16x2 LCD |
ST7735 |
Library to use the 1.8" TFT display |
DS1307Z |
Library to use the real time clock |
MS5607 |
Library to use the barometer |
RGB_Matrix |
Library to use the RGB LED matrix on Joy-Pi Advanced 2 - RP2040 is used to communicate with led matrix |
VEML6040 |
Library to use the colour sensor |
MPR121 |
Library to use the touchpads |
IR_RX |
Library to use the infrared sensor |
HT16K33Segment |
Library to use the 7-segment display |
MFRC522 |
Library to use the RFID module |
SSD1306 |
Library to use the OLED display |
Download this repository and copy the folder lib onto your Raspberry Pi Pico.
ADC_TLA2518(spi, cs = 17)- initialize ADC with default valuesbegin()- starts communicationread_value(channel)- returns raw value from a selected channelread_voltage(channel, value=None)- returns measured voltage from a selected channel, raw value can also be calculated into voltage with this method
ICG1020S(spi, cs = 27)- initialize gyroscope with default valuesbegin()- starts communicationgetTemperature()- returns measured temperaturegetTilt()- returns the tilted directionscale_Factor(scale)- sets scale factor of the gyroscope (0, 8, 16 or 24)
MS5607(i2c, addr = 0x77, res = 4096)- initialize barometer with default valuesbegin()- starts communicationget_pressure()- returns the measured pressureget_temperature()- returns the measured temperatureget_altitude(reference_pressure = 1013.25)- return the calculated altitude with the measured pressure and your local pressure (reference_pressure)
Buttonmatrix(i2c, addr = 0x22)- initialize button matrix with default valuesbegin()- starts communicationgetKey()- returns the pressed buttonclearMemory()- clears class variablecalculatedcalculate()- method to use the button matrix as a calculator
I2CLCD(i2c, addr = 0x21)- initialize 16x2 LCD with default valuesbegin()- starts communicationclear()- clears LCDsetHome()- sets cursor to position (0,0)shiftToLeft()- shift the whole display to the leftshiftToRight()- shift the whole display to the rightshowCursor()- show cursorblinkingCursor()- activate the blinking cursorhideCursor()- hide cursorturnOff()- turn background light offturnOn()- turn background light onsetCursor(x, y)- set cursor to position (x, y)print(text)- print String onto the LCD at the current cursor position
ST7735(spi, dc = 26, res = 27, cs = 10, x_offset = 2, y_offset = 1, rgbMode = "bgr")- initialize TFT with default valuesbegin()- starts communicationfillRectangle(x, y, width, height, colour)- method to draw filled rectangle, where x and y are the coordinates of the left upper cornerdrawRectangle(x, y, width, height, colour)- method to draw outline of a rectangle, where x and y are the coordinates of the left upper cornerfillTriangle(x0, y0, x1, y1, x2, y2, colour)- method to draw triangle, where x0 and y0 are the coordinates of the left corner, x1 and y1 the coordinates of the corner in the middle and x2 and y2 the coordinates of the right cornernfill(colour)- fills display with one colourclear()- clears displaydrawPixel(x, y, colour)- draws pixel onto the displayfillCircle(x, y, radius, colour)- draws filled circle on display, where x and y are the coordinates of the centerdrawLine(x1, y1, x2, y2, colour)- draws line, where x1 and y1 are the coordinates of the starting point and x2 and y2 are the coordinates of the end pointdrawHorizontalLine(x, y, width, colour)- draws a horizontal line starting at the coordinates x and y and iswidthpixel longdrawVerticalLine(x, y, height, colour)- draws a vertical line starting at the coordinates x and y and isheightpixel longdrawCircle(x_cent, y_cent, radius, colour)- draws circle, where x_cent and y_cent are the coordinates of the centerturnOff()- turns the display offturnOn()- turns the display onprint(text, x, y, textColour, bgColour, size = 1)- prints String onto the display, where x and y are the coordinates of the starting point
DS1307Z(i2c, addr = 0x68)- initialize RTC with default valuessetDate(year, month, day, weekday, hour, minute, second)- set all values of the RTCsetYear(year)- set year on the RTCsetMonth(month)- set month on the RTCsetDay(day)- set day on the RTCsetWeekday(weekday)- set weekday on the RTC (0 - Sunday etc.)setHour(hour)- set hour on the RTCsetMinute(minute)- set minute on the RTCsetSecond(second)- set second on the RTCgetDate()- returns all values of the RTCgetYear()- returns year from the RTCgetMonth()- returns month of the RTCgetDay()- returns day of the RTCgetWeekday()- returns weekday of the RTCgetHour()- returns hour of the RTCgetMinute()- returns minute of the RTCgetSecond()- returns second of the RTC
RGB_Matrix(i2c, i2c_adress = 0x66, count = 64, brightness = 80, right_border = [7,15,23,31,39,47,55,63], left_border = [0,8,16,24,32,40,48,56]))- initialize RGB LED matrix with already Joy-Pi Advanced values set as defaultclean()- turn off all pixelssetPixel(position, colour)- set a pixel atpositiontocolour(32 bit integer or tuple)setBrightness(brightness)- set brightness of led matrix to a certain level (0-255)getPixelNum()- returns number of pixels at matrixRGB_on(colour)- set all pixel of matrix tocolour(32 bit integer or tuple)RGB_off()- turn off all pixelswheel(pos)- generate rainbow colours overpospositions 0-255rainbow(wait_ms=20, iterations=1)- play rainbow effect on all LEDs, wherewait_msis the time in bewteen colour change anditerationsthe number of repetitionscolourWipe(color, wait_ms=50)- Move colours pixel by pixel over the LEDs with a givencolour(32 bit integer or tuple), wherewait_msis the time in bewteen colour changetheaterChase(color, wait_ms=50, iterations=10)- chaser animation with a givencolour(32 bit integer or tuple), wherewait_msis the time in bewteen colour change anditerationsthe number of repetitionsdemo1()- simple demo programmdemo2()- more complex demo programm in a continuous loopshow()- show changes on LED matrix
Note
This object is for an easier and more flexible use of colour codes. You can use the hexadecimal value, separate RGB values or separate RGBW values.
RGBW(r, g=None, b=None, w=None)- create new RGBW value in two possible ways:- with a single integer
RGBW(0xWWRRGGBB)as parameterr - with individual colour components as a tuple
(r, g, b, w=0)
- with a single integer
unpackRGBW()- returns value ofRGBW- object as colour tuple(red, green, blue, white)unpackHEX()- return value ofRGBW- object as 32 bit integer0xWWRRGGBB
VEML6040(i2c, address = 0x10)- initialize colour sensor with default valuesenableSensor()- start communicationdisableSensor()- end communicationsetIntegrationTime()- set integration time (0-40ms,1-80ms,2-160ms,3-320ms,4-640ms or5-1280ms)forceMode()- forces measurement modeautoMode()- automatic measurement modeget_red()- returns the raw value of redget_green()- returns the raw value of greenget_blue()- returns the raw value of blueget_white()- returns the raw value of whiteget_rgbw()- returns all raw values of RGBWreadAll()- returns most recognized RGB colour as well as all raw values
MPR121(i2c, address = 0x5A)- initialize touchpads with default valuesreset()- resets touchpads to default stateset_thresholds(touch, release, electrode = None)- sets the touch and release thresholds from 0 to 255 for a single touch pad or allfiltered_data(electrode)- returns filtered data value for a specific touch padbaseline_electrode(electrode)- returns baseline data value for a specific touch padtouched()- returns a 12bit value which represents which touch pad is touch and which is not (LSB)is_touched(electrode)- returns true if a specific touch pads is touchedget_all_states()- returns the state of all touchpads
NEC_8(pin, nedges, tblock, callback, *args)- initialize infrared receiver for a remote controller with NEC 8 encoding (*argsincludes arguments for the callback function)NEC_16(pin, nedges, tblock, callback, *args)- initialize infrared receiver for a remote controller with NEC 16 encoding (*argsincludes arguments for the callback function)NEC_SAMSUNG(pin, nedges, tblock, callback, *args)- initialize infrared receiver for a remote controller with NEC Samsung encoding (*argsincludes arguments for the callback function)do_callback(cmd, addr, ext, thresh = 0)- sets callback method manuallyerror_function(func)- sets a error methodclose()- close communication
Note
If setting attribute verbose to true, the code emits debug output.
When you want to use a remote controll with a different encoding, you can add specific encodings into this directory ir_rx from here.
When you define your callback method, it needs to receive the arguments data - value from the remote, addr - address from remote and ctrl - always 0 with NEC encoding.
HT16K33Segment(i2c, i2c_adress=0x70)- initialize 7-segment display with default valuesrotate()- rotate the segment displayset_colon(is_set = True)- sets the colon of the displayset_glyph(glyph, digit = 0, has_dot = False)- sets a user-defined glyph on display at a specific digit, where glyph is a 8-bit integer representing 7 segmentsset_number(number, digit = 0, has_dot = False)- sets single decimal value (< 10) at a specific digitset_character(char, digit = 0, has_dot = False)- sets single alpganumeric character at a specific digitdraw- writes display buffer onto displayprintNum(num)- write number onto the displayclear()- clears display
MFRC522(ck, mosi, miso, rst, cs,baudrate=1000000,spi_id=0)- initialize RFID moduleinit()- start communicationreset()- reset RFID moduleantenna_on(on = True)- activate or deactivate antennarequest(mode)- request data from RFID module in a mode (REQIDL or REQALL)anticoll(anticolN)- sets anticollisionPcdSelect(serNum, anticolN)- checks if reading of tag went smoothlySelectTag(uid)- checks if tag has a specific UIDtohexstring(v)- converts hex to stringSelectTagSN()- returns is reading of a tag was correct and uidauth(mode, addr, sect, ser)- check if tag can be written onauthKeys(uid, addr, keyA = None, keyB = None)- check if which key to use to writestop_crypto1()- stop encriptionread(addr)- returns specific block (addr) of tagwrite(addr, data)- writes into a specific block (addr) datawriteSectorBlock(uid, sector, block, data, keyA = None, keyB = None)- write data into a specific sector and blockreadSectorBlock(uid, sector, block, keyA = None, keyB = None)- read data from a specific sector and blockMFRC522_DumpClassic1K(uid, Start = 0, End = 64, keyA = None, keyB = None)- returns all data from tag (start and end can be defined)
SSD1306_I2C(width, height, i2c, addr=0x3C, external_vcc=False)- initialize OLED with default valuesinit_display()- starts communication with OLEDpoweroff()- turns off OLEDpoweron()- turns on OLEDcontrast(contrast)- sets contrast of OLEDinvert(invert)- sets colour invertionshow()- writes display buffer onto OLED
Note
This library is subclassing FrameBuffer to provide for graphic primitives. Documentation can be found here for the methods to dislpay graphics.