This library is a collection for the Raspberry Pi Pico for several modules on the Joy-Pi Advanced. See here for more information.
This library includes the following modules:
- ADC
- Gyroscope
- Barometer
- Button matrix
- Color Sensor - library from
PiicoDev® Colour Sensor VEML6040 MicroPython Module - 16x2 LCD
- TFT 1.8
- Touchpads - library from
MicroPython MPR121 - Infrared sensor - library from
micropython_ir - 7-segment display - library from
HT16K33 Drivers 3.5.0 - RFID - library from
micropython-mfrc522 - RTC
- OLED - library from
micropython-ssd1306
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
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
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 communicationfillRec(x, y, width, height, colour)- method to draw filled rectangle, where x and y are the coordinates of the left upper cornerfill(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 pointdrawCircle(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
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
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.
Note: 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)
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
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
This library is subclassing FrameBuffer to provide for graphic primitives. Documentation can be found here for the methods to dislpay graphics.