This library provides a Microsoft Makecode package for the Joy-IT Joy-Pi Advanced. See https://joy-it.net/products/RB-JoyPi-Advanced and https://www.joy-pi.net for more details.
The Joy-Pi Advanced is the universal all-rounder for all Makers. It combines compatibility for Raspberry Pi, Raspberry Pi Pico, Arduino Nano, BBC micro:bit and NodeMCU ESP32 with the versatility of over 38 modules, making it the ultimate maker platform.
The Joy-Pi Advanced combines the following modules:
Module | Connection |
---|---|
1.8" TFT Display | P0 (D/C), P1 (Reset), P10 (CS) |
Light barrier | P0 |
Infrared receiver | P0 |
Relay | P1 |
Gyroscope (CS) | P1 |
Switch 1 | P2 |
Ultrasonic sensor | P2 (Echo), P3 (Trigger) |
Rotary Encoder | P2 (DT), P3 (CLK), P4 (SW) |
Switch 2 | P3 |
Switch 3 | P4 |
Stepper motor | P4 (S1), P5 (S2), P6 (S3), P7 (S4) |
Switch 4 | P5 |
Switch 5 | P6 |
PIR sensor | P6 |
PWM fan | P7 |
Buzzer | P7 |
Servo motor | P8 |
RGB Matrix | P8 |
DHT11 sensor | P8 |
DS18B20 sensor | P9 |
Sound sensor | P9 |
Joystick | P10 (Switch) |
Shock sensor | P10 |
RFID | P16 (CS) |
Vibration module | P16 |
Analog-Digtal converter | P16 (CS) |
I2C modules:
Module | I2C-Address |
---|---|
Color sensor | 0x10 |
16x2 LCD display | 0x21 |
Button matrix | 0x22 |
OLED display | 0x3C |
EEPROM | 0x50 |
Touch sensor | 0x5A |
Real-time clock | 0x68 |
7-segment display | 0x70 |
Barometer | 0x77 |
Modules connected to the analog-digital converter:
Module | Channel |
---|---|
Joystick (X-Axis) | A0 |
Joystick (Y-Axis) | A1 |
NTC | A2 |
Potentiometer | A3 |
Hall sensor | A4 |
LDR | A5 |
/ | A6 |
/ | A7 |
A 7-segment display is able to show numbers (or also characters) by displaying individual segments. A block contains 7 segments and an additional point. 7 segment displays are often used in watches, for example.
The 7-segment display is connected via I2C on address 0x70.
Because the 7-segment display is an I2C-device, an initial initialization is required to use the display:
// Initialize 7-segment display
JoyPiAdvanced.segmentInit()
Numbers with a length of up to 4 digits can be send to the display. You can additionally set the colon to on or off.
// Show number with colon off
JoyPiAdvanced.segmentWriteNumber(1234, Colon.off)
// Show number with colon on
JoyPiAdvanced.segmentWriteNumber(4321, Colon.on)
Clear the display to remove all active colons
JoyPiAdvanced.segmentClear()
Since many microcontrollers, like the micro:bit, cannot process analog signals, the Joy-Pi Advanced is equipped with an analog-to-digital converter. This converts analog signals into a digital signal and can thus be conveniently read out by a microcontroller. The ADC has a total of 8 (0 - 7) channels.
The analog-digital converter is connected via SPI on P16 (CS).
This ADC is a 12-bit ADC which means that the applied voltage can be converted to a total of 4096 (0 - 4095) values.
// Read value on channel no. 0
JoyPiAdvanced.adcReadValue(0)
// Read value on channel no. 3
JoyPiAdvanced.adcReadValue(3)
Instead of values, you can also directly read the raw applied voltage:
// Read voltage on channel no. 0
JoyPiAdvanced.adcReadVoltage(0)
// Read voltage on channel no. 3
JoyPiAdvanced.adcReadVoltage(3)
A barometer is a measuring device for determining the static air pressure. The barometer used in the Joy-Pi Advanced is additionally able to measure the temperature.
The barometer is connected via I2C on address 0x77.
Because the barometer is an I2C-device, an initial initialization is required before use:
// Initialize barometer
JoyPiAdvanced.barometerInit()
Read the pressure measurement from the barometer in mBar.
// Read pressure from barometer
JoyPiAdvanced.barometerGetPressure()
Read the temperature measurement from the barometer in Celsius.
// Read temperature from barometer
JoyPiAdvanced.barometerGetTemperature()
The button matrix is a keypad consisting of a total of 16 buttons arranged in a 4 x 4 matrix.
The button matrix is connected via I2C on address 0x22.
Because the button matrix is an I2C-device, an initial initialization is required before use:
// Initialize button matrix
JoyPiAdvanced.buttonmatrixInit()
Returns the value number when a button is pressed. If no button is pressed, -1 is returned.
// Return button value number
JoyPiAdvanced.buttonmatrixPressed()
On the silk screen of the Joy-Pi Advanced, the button matrix is labeled with 0-9 and #, X, /, +, - and =. This function returns the corresponding button value (as a string) when a button is pressed. If no button is pressed, -1 is returned.
// Return button value
JoyPiAdvanced.buttonMatrixPressedValue()
The buzzer is an acoustig signal generator, which is controlled with a frequency and thus emits a sound. The frequency determines the pitch of the tone.
The buzzer is connected to P7.
You can turn the buzzer on by using the JoyPiAdvanced.buzzerOn(frequency) function. The frequency can be a value between 100 and 20000.
// Turn buzzer on with a frequency of 2000
JoyPiAdvanced.buzzerOn(2000)
You can turn the buzzer off by using the JoyPiAdvanced.buzzerOff() function.
JoyPiAdvanced.buzzerOff()
The color sensor allows you to determine the composition (red, green, blue and white) of colors. The module outputs a signal which will be converted into the corresponding color values. Please note that the color sensor can not measure the exact composition of colors. Instead it gives you an indication to which base color the color tends.
The color sensor is connected via I2C on address 0x10.
Because the color sensor is an I2C-device, an initial initialization is required before use:
// Initialize color sensor
JoyPiAdvanced.initColorSensor()
You can detect the intensity of the base colors with the following functions: JoyPiAdvanced.colorSensorGetRed(), JoyPiAdvanced.colorSensorGetGreen(), JoyPiAdvanced.colorSensorGetBlue() and JoyPiAdvanced.colorSensorGetWhite().
// Get red intensity
JoyPiAdvanced.colorSensorGetRed()
// Get green intensity
JoyPiAdvanced.colorSensorGetGreen()
// Get blue intensity
JoyPiAdvanced.colorSensorGetBlue()
// Get white intensity
JoyPiAdvanced.colorSensorGetWhite()
The DHT11 is a combination sensor which can measure temperatures (0 - 50 degrees celsius) and humidity (20 - 90 %).
The DHT11 sensor is connected to P8.
You can use JoyPiAdvanced.dht11GetTemperature() and JoyPiAdvanced.dht11GetHumidity() to receive the corresponding measurement values.
// Measure temperature
JoyPiAdvanced.dht11GetTemperature()
// Measure humidity
JoyPiAdvanced.dht11GetHumidity()
The DS18B20 is an external, waterproof temperature sensor. It is located in an encapsulated housing on an approx. 1m long cable and is thus able to measure the temperature in liquids. Please note that the DS18B20 sensor need to be connected to your Joy-Pi Advanced board before you can use it.
The DS18B20 sensor is connected to P9.
The temperature can be measured by using the JoyPiAdvanced.readDS18B20() function.
// Measure temperature
JoyPiAdvanced.readDS18B20()
The EEPROM memory allows data to be stored and read out again at a later time. A write protection can additionally ne activated on the board.
The EEPROM is connected via I2C on address 0x50.
You can write up to 32 kB of data to the EEPROM by using the JoyPiAdvanced.eepromWrite(data, address) function. Both parameters, data and address, need to be a number.
// Write number 12345 to address 5
JoyPiAdvanced.eepromWrite(12345, 5);
Data can be read out by using the JoyPiAdvanced.eepromRead(address) function.
// Read data from address 5
JoyPiAdvanced.eepromRead(5)
With the help of a gyroscope, the angular velocity and thus the orientation of the object can be measured. The gyroscope built into the Joy-Pi Advanced is capable of measuring the orientation within the X-axis and the Y-axis, as well as the tilt. In addition, the temperature can also be measured.
The gyroscope is connected via SPI on P1 (CS).
Because the gyroscope is an SPI-device, an initial initialization is required before use:
// Initialize gyroscope
JoyPiAdvanced.gryoscopeInit()
The orientation of the X-axis and Y-axis can be measured by using the JoyPiAdvanced.gyroscopeGetX() and JoyPiAdvanced.gyroscopeGetY() functions.
// Measure orientation of X-Axis
JoyPiAdvanced.gyroscopeGetX()
// Measure orientation of Y-Axis
JoyPiAdvanced.gyroscopeGetY()
The tilt of the device can be measured by using the JoyPiAdvanced.gyroscopeGetTilt() function.
// Measure tilt of the device
JoyPiAdvanced.gyroscopeGetTilt()
Additionally, the temperature can be measured with the help of the gyroscope by using the JoyPiAdvanced.gyroscopeGetTemperature() function.
// Measure temperature
JoyPiAdvanced.gyroscopeGetTemperature()
Hall sensors are sensitive to magnetic fields and can therefore determine the strength of such a field. The stronger the magnetic field, the more voltage can be measured.
The hall sensor is an analog sensor and is connected to channel A4 of the ADC.
Determine the intensity of a magnetic field by measuring the voltage passing through the sensor with the JoyPiAdvanced.hallSensorVoltage() function.
// Measure voltage
JoyPiAdvanced.hallSensorVoltage()
The infrared receiver can receive infrared signals and output them as a digital signal sequence. Please note that not all remote controls can be detected, as remote controls from different manufacturers also use different communication protocols. We therefore recommend to use only the remote control included in the Joy-Pi Advanced.
The infrared receiver is connected to P0.
The infrared receiver needs to be initialized before use because it is listening for input in the background. You can initialize the ir receiver with JoyPiAdvanced.initIrReceiver().
// Initialize IR receiver
JoyPiAdvanced.initIrReceiver()
Each button is assigned a unique number for identification. With JoyPiAdvanced.irButton() the corresponding identification number can be read out. If no button was pressed, 0 is returned instead.
// Read out pressed button
JoyPiAdvanced.irButton()
The joystick outputs its position on the X an d Y axes and can thus be clearly localized in its current position. It is additionally equipped with a button.
The joystick is connected to the ADC channel A0 (X-Axis) and A1 (Y-Axis) as well as to P10 (button).
You can locate the position of the Joystick by using JoyPiAdvanced.joystickGetXValue() and JoyPiAdvanced.joystickGetYValue(). Because the joystick is connected to the build-in 12-bit ADC of the Joy-Pi Advanced, the axis values are between 0 and 4095.
// Get X-Axis
JoyPiAdvanced.joystickGetXValue()
// Get Y-Axis
JoyPiAdvanced.joystickGetYValue()
The press of the button can be checked with the JoyPiAdvanced.joystickCheckButton() function. The function returns true or false.
// Check if button was pressed
JoyPiAdvanced.joystickCheckButton()
The 16x2 display can output texts on a total of 16 characters and over 2 lines. It is ideally suited for the quick output of status information or measurement results.
The 16x2 lcd display is connected via I2C on address 0x21.
Because the display is an I2C-device, an initial initialization is required before use:
JoyPiAdvanced.lcd16x2Init()
The display supports various power functions. These include power on, power off, backlight power on and backlight power off.
// Turn LCD on
JoyPiAdvanced.lcd16x2TurnOn()
// Turn LCD off
JoyPiAdvanced.lcd16x2TurnOff()
// Turn backlight on
JoyPiAdvanced.lcd16x2BacklightOn()
// Turn backlight off
JoyPiAdvanced.lcd16x2BacklightOff()
Text can be send to the display by using the JoyPiAdvanced.LCD16x2_showText(text, x, y) function. The string to be displayed is passed with text and the position on the display is passed with x and y. The entire display output can be deleted with JoyPiAdvanced.LCD16x2_clear().
// Show text at position 0 on line 0
JoyPiAdvanced.lcd16x2ShowText('Hello World', 0, 0)
// Show text at position 2 on line 1
JoyPiAdvanced.lcd16x2ShowText('Hello World', 2, 1)
// Clear output
JoyPiAdvanced.lcd16x2Clear()
The whole output can be shifted to the left and right and can thus be moved over the display.
// Shift text to the left
JoyPiAdvanced.lcd16x2ShiftLeft()
// Shift text to the right
JoyPiAdvanced.lcd16x2ShiftRight()
The display also offers the possibility to switch on the current cursor position. You can choose between a permanent and a blinking cursor. Of course, the cursor can also be switched off and moved back to the start position.
// Show permanent cursor
JoyPiAdvanced.lcd16x2ShowCursor()
// Show blinking cursor
JoyPiAdvanced.lcd16x2BlinkingCursor()
// Move cursor to starting position
JoyPiAdvanced.lcd16x2ReturnHome()
// Hide cursor
JoyPiAdvanced.lcd16x2HideCursor()
A light dependent resistor is a light sensitive module. The more light that hits the sensor, the lower its resistance value and the higher the measurable voltage that flows through it. The LDR can therefore be used to measure the light intensity.
The LDR is connected to the ADC channel A5.
The light intensity can measured by using JoyPiAdvanced.ldrLight(). The intensity is returned as a percentages. Please note that a light intensity of 100% does not mean the greatest possible luminosity, but only that the measurement limit of the sensor has been reached.
// Measure light intensity
JoyPiAdvanced.ldrLight()
The light barrier detects when it has been interrupted by something. In combination with the attachment and motor included in the Joy-Pi Advanced, it is possible, for example, to drive the perforated disc and measure the motor speed.
The light barrier is connected to P0.
Check if something is interrupting the light barrier by using JoyPiAdvanced.lightBarrierIsTriggered(). The function returns true or false.
// Check if light barrier is interrupted
JoyPiAdvanced.lightBarrierIsTriggered()
If the light barrier is interrupted several times in succession by the perforated disc supplied, the corresponding revolutions per minute can be calculated from this.
// Calculate RPM
JoyPiAdvanced.lightBarrierRPM()
A negative temperature coefficient thermistor (NTC) is a temperature-dependent resistor. It conducts electrical current better at high temperatures than at low temperatures. The current temperature can thus be derived from the individual characteristic curve of the resistor and the measured current.
The NTC is connected to the ADC channel A2.
The temperature can be measured in celsius by using JoyPiAdvanced.ntcTemperature().
// Measure temperature
JoyPiAdvanced.ntcTemperature()
An OLED dipslay consists of organic light-emitting diodes and is technically fundamentally different from the 16x2 LCD display. A big advantage is that graphic elements (such as circles and rectangles) can be displayed on the OLED.
The OLED display is connected via I2C on address 0x3C.
Because the display is an I2C-device, an initial initialization is required before use:
// Initialize OLED display
JoyPiAdvanced.oledInit()
The display can show text as well as the graphical elements line, rectangle, and circle.
// Show text
JoyPiAdvanced.oledShowString("Hello World")
// Draw line from x-y coordinates 10-15 to x-y coordinates 60-60
JoyPiAdvanced.oledDrawLine(10, 15, 60, 60)
// Draw rectangle starting at x-y coordinate 10-15 with a width of 20 and a height of 30
JoyPiAdvanced.oledDrawRectangle(10, 15, 20, 30)
// Draw circle at x-y coordinate 50-50 with a radius of 20
JoyPiAdvanced.oledDrawCircle(50, 50, 20)
All contents on the display can be erased by using the JoyPiAdvanced.oledClear() function.
// CLear output from display
JoyPiAdvanced.oledClear()
A PIR sensor is an infrared-based motion sensor. Temperature changes in its proximity lead to measurable change in electrical voltage and thus allow conclusions to be drawn about movements in its vicinity.
The PIR sensor is connected to P6.
The function JoyPiAdvanced.pirCheckMotion() allows you to detect motion. The function returns true or false.
// Detect motion
JoyPiAdvanced.pirCheckMotion()
The fan on the Joy-Pi Advanced is supposed to cool an installed Raspberry Pi. When set to PWM mode, it is possible to control the speed of the fan by applying a PWM signal to the fan.
The PWM fan is connected to P7.
You can control the speed of the fan from 0 to 100.
// Set PWM fan to maximum speed
JoyPiAdvanced.pwmSetSpeed(100)
// Set PWM fan to medium speed
JoyPiAdvanced.pwmSetSpeed(50)
// Stop PWM fan
JoyPiAdvanced.pwmSetSpeed(0)
A potentiometer is a component whose resistance can be changed mechanically. By moving it from left to right, its resistance can be increased continuously.
The potentiometer is connected to the ADC on channel A3.
The voltage currently applied to the potentiometer can be measured directly.
JoyPiAdvanced.potentiometerVoltage()
RFID is a technology in which a transmitter communicates with a receiver without contact. The transponder usually consists of an object that can be held in front of the sensor.
The RFID module is connected via SPI on P16 (CS).
The RFID module needs to be initialized before use.
JoyPiAdvanced.rfidInit()
You can either read the ID of an RFID tag, for unique tag identification, or the content stored in an RFID tag.
// Read ID of RFID tag
JoyPiAdvanced.rfidReadId()
// Read content of RFID tag
JoyPiAdvanced.rfidReadText()
You can also overwrite the content stored in a tag.
// Write content to RFID tag
JoyPiAdvanced.rfidWriteText('Hello World')
An RGB matrix is a grid of LEDs divided into vertical columns and horizontal rows. Each LED can be controlled individually and can be set in the RGB color space.
The RGB matrix is connected to P8.
You can control the complete matrix as well as single pixels of the matrix. You are also able to set the brightness of the matrix.
// Set complete matrix to red
JoyPiAdvanced.matrixShowColor(255, 0, 0)
// Set complete matrix to green
JoyPiAdvanced.matrixShowColor(0, 255, 0)
// Set complete matrix to blue
JoyPiAdvanced.matrixShowColor(0, 0, 255)
// Set complete matrix to white
JoyPiAdvanced.matrixShowColor(255, 255, 255)
// Set single pixel at x-y position 5-5 to red
JoyPiAdvanced.matrixSetPixel(5, 5, 255, 0, 0, 0)
The rainbow mode automatically cycles the RGB matrix through all colors.
// Activate rainbow mode
JoyPiAdvanced.matrixRainbow()
The output of the matrix can be erased with JoyPiAdvanced.matrixClear().
// Clear matrix
JoyPiAdvanced.matrixClear()
An RTC does not measure the relative runtime of a microcontroller, but the actual time. So that the RTC does not have to be set again each time the device is switched off, it is additionally equipped with a button cell and can thus retain its settings.
The RTC is connected via I2C on address 0x68.
The RTC can be set completely with a single function, as well as individually with a function for each parameter.
// Set RTC to year 2023, month 2, day 1, weekday 3, hour 13, minute 37 and second 2
JoyPiAdvanced.rtcSetDateTime(2023, 2, 1, 3, 13, 37, 2)
// Set year to 2023
JoyPiAdvanced.rtcSetYear(2023)
// Set month to 2
JoyPiAdvanced.rtcSetMonth(2)
// Set day to 1
JoyPiAdvanced.rtcSetDay(1)
// Set weekday to 3
JoyPiAdvanced.rtcSetWeekday(3)
// Set hour to 13
JoyPiAdvanced.rtcSetHour(13)
// Set minute to 37
JoyPiAdvanced.rtcSetMinute(37)
// Set second to 2
JoyPiAdvanced.rtcSetSecond(2)
Of course each parameter can also be read out again.
// Read year
JoyPiAdvanced.rtcGetYear()
// Read month
JoyPiAdvanced.rtcGetMonth()
// Read day
JoyPiAdvanced.rtcGetDay()
// Read weekday
JoyPiAdvanced.rtcGetWeekday()
// Read hour
JoyPiAdvanced.rtcGetHour()
// Read minute
JoyPiAdvanced.rtcGetMinute()
// Read second
JoyPiAdvanced.rtcGetSecond()
A relay is a remotely controllable switch operated by current. Other circuits can be switched via a circuit that is activated. The line to be switched is connected to the COM interface. If the relay is switched off, the current is continued via the NC interface. The NO interface remains currentless. If the relay is switched, the two interfaces change. The current is now carried on via NO and NC is deenergized.
The relay is connected to P1.
The relay is fairly simple. It can be turned on and off.
// Turn relay on
JoyPiAdvanced.relayOn()
// Turn relay off
JoyPiAdvanced.relayOff()
The rotary encoder is a switch that can be turned clockwise or counterclockwise. When the roary encoder is moved, the direction of movement and the current position of the switch are encoded. Per steop the states of the outputs change. The direction of rotation can be determined by checking which of the two states changed first. In addition, the rotary encoder can be pressed to switch another signal.
The rotary encoder is connected to P2 (DT), P3 (CLK) and P4 (SW).
The rotation of the rotary encoder is not controlled by a single function, but by an event. All necessary instructions for the control can be integrated into this event.
// Respond to clockwise rotation
JoyPiAdvanced.rotaryEncoderonTurned(Direction.clockwise, function(){
serial.writeLine('Rotary encoder turned clockwise')
})
// Respond to counterclockwise rotation
JoyPiAdvanced.rotaryEncoderonTurned(Direction.counterclockwise, function(){
serial.writeLine('Rotary encoder turned counterclockwise')
})
// Respond to button pressed
JoyPiAdvanced.rotaryEncoderonPressEvent(function(){
serial.writeLine('Button has been pressed')
})
Servo motors are small motors that are adjustable in their direction of rotation and speed. Please note that the servo motor is an external device that needs to be connected to your Joy-Pi Advanced.
The servo motor is connected to P8.
The speed of the servo motor is not adjustable via the function. Instead, the speed can be influenced via pauses within the code. The servo motor can be driven to a degreen angle between 0 and 180.
// Rotate servo motor to degree angle 90
JoyPiAdvanced.turnMotor(90)
// Rotate servo motor cto degree angle
JoyPiAdvanced.turnMotor(120)
A shock sensor can detect shakes and vibrations. As soon as the signal exceeds a certain threshold, this is automatically output at the signal output of the sensor.
The shock sensor is connected to P10.
Shocks and vibrations can be detected with the JoyPiAdvanced.shocksensorCheck() function. The function returns true or false.
// Check for shocks
JoyPiAdvanced.shocksensorCheck()
The sound sensor detects noise. As soon as the noise level exceeds a defined threshold, this is automatically output at the signal output of the sensor.
The sound sensor is connected to P9.
You can detect sound via the JoyPiAdvanced.soundsensorCheck() function. The function returns true or false.
// Check for sound
JoyPiAdvanced.soundsensorCheck()
The stepper motor is a type of electric motor that moves in precise, fixed increments called steps, allowing for accurate position control. It is commonly used in robotics, 3D printers, and CNC machines for precise motion.
The stepper motor is connected to P4 (S1), P5 (S2), P6 (S3) and P7 (S4)
The stepper motor can be used with the JoyPiAdvanced.stepperRotate(direction, steps, unit) function. You can choose if you want to rotate by a number of steps or a number of full rotationF
// Rotate clockwise by 10 steps
JoyPiAdvanced.stepperRotate(Stepperdirection.clockwise, 10, Stepunit.steps)
// Rotate counterclockwise by 2 rotations
JoyPiAdvanced.stepperRotate(Stepperdirection.counterclockwise, 2, Stepunit.rotations)
A switch is a component with which an electrical connection can be closed and opened. The Joy-Pi Advanced has a total of 5 switches.
The switches are connected to P2, P3, P4, P5 and P6.
The condition of the switches can be checked with the JoyPiAdvanced.switchCheck(JoyPiSwitch) function. The function returns true or false.
// Check switch 1
JoyPiAdvanced.switchCheck(SWselection.switch1)
// Check switch 2
JoyPiAdvanced.switchCheck(SWselection.switch2)
// Check switch 3
JoyPiAdvanced.switchCheck(SWselection.switch3)
// Check switch 4
JoyPiAdvanced.switchCheck(SWselection.switch4)
// Check switch 5
JoyPiAdvanced.switchCheck(SWselection.switch5)
The TFT display is the all-rounder among the displays. It has a sufficient size for displaying content and can also display graphic elements in addition to text.
The TFT display is connected via SPI on P10 (CS), P0 (D/C) and P1 (Reset).
The display needs to be initialized before use.
// Initialize display
JoyPiAdvanced.tftInit()
The display can show single pixels, lines, rectangles and circles in addition to text.
// Show text at x-y position 20-30 with zoom level 1, font color red and background color black
JoyPiAdvanced.tftShowString('Hello World', 20, 30, 1, color.red, Color.black)
// Draw single pixel at x-y position 10-20 with color blue
JoyPiAdvanced.tftDrawPixel(10, 20, Color.blue)
// Draw line from x-y position 10-10 to x-y position 100-80 with color yellow
JoyPiAdvanced.tftDrawLine(10, 10, 100, 80, Color.yellow)
// Draw rectangle at x-y position 10-10 with a width of 50 and a height of 20 in color green
JoyPiAdvanced.tftDrawRectangle(10, 10, 50, 20, Color.green)
// Draw circle at x-y position 50-50 with a radius of 20 in color blue
JoyPiAdvanced.tftDrawCircle(50, 50, 20, Color.blue)
The display supports zoom levels for text from 1 to 5 and supports various predefined colors:
- color.black
- color.navy
- color.darkgreen
- color.darkcyan
- color.maroon
- color.purple
- color.olive
- color.lightgrey
- color.darkgrey
- color.blue
- color.green
- color.cyan
- color.red
- color.magenta
- color.yellow
- color.white
- color.orange
- color.greenyellow
- color.pink
In addition to the display drawing functions, the display can be switched off, switched on, and the current output can be deleted.
// Turn display off
JoyPiAdvanced.tftOff()
// Turn display on
JoyPiAdvanced.tftOn()
// Clear display
JoyPiAdvanced.tftClear()
With the touch sensor, the contact is closed by touch. The contacts can either be touched directly or attached to any object using the supplied clamps. A total of 6 touch sensors are available.
The touch sensor is connected via I2C on address 0x5A.
Because the touch sensor is an I2C-device, an initial initialization is required before use:
// Initialize touch sensor
JoyPiAdvanced.touchsensorInit()
The status of each contact can be queried directly. The function returns either true or false.
// Detect touch on channel 1
JoyPiAdvanced.touchsensorCheck(1)
// Detect touch on channel 2
JoyPiAdvanced.touchsensorCheck(2)
// Detect touch on channel 3
JoyPiAdvanced.touchsensorCheck(3)
// Detect touch on channel 4
JoyPiAdvanced.touchsensorCheck(4)
// Detect touch on channel 5
JoyPiAdvanced.touchsensorCheck(5)
// Detect touch on channel 6
JoyPiAdvanced.touchsensorCheck(6)
The ultrasonic sensor is a sensor that can determine distances using ultrasound.
The ultrasonic sensor is connected to P2 (Echo) and P3 (Trigger).
A measurement can be initiated directly via the JoyPiAdvanced.measureDistance() function. The measurement result is returned in cm.
// Measure distance
JoyPiAdvanced.measureDistance()
The vibration motor is a device that oscillates at a high frequency to produce noticable vibrations.
The vibration motor is connected to P16.
The vibration motor can be turned on or off.
// Turn vibration motor on
JoyPiAdvanced.vibrationOn()
// Turn vibration motor off
JoyPiAdvanced.vibrationOff()
- for PXT/microbit
MIT