Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

python for megapi

Project description

# Python For MegaPi
## How To Use
* Compile and upload the Firmware to MegaPi ( https://github.com/Makeblock-Official/FirmwareForMegaPi )
* On your Raspberry Pi,
```
sudo pip install megapi
```
* Insert the initial code for starting MegaPi first.
```
from megapi import *
bot = MegaPi()
bot.start()
```
* python your code

## Python API
* Start
* **MegaPi**()
* **start**()

* GPIO
* **digitalWrite**( pin, level )
* **pwmWrite**( pin, pwm )
* **digitalRead**( pin, **def** onResult )
* **analogRead**( pin, **def** onResult )

* Motion
* DC Motor
* **dcMotorRun**( port, speed )
* Servo Motor
* **servoRun**( port, angle )
* Encoder Motor
* **encoderMotorRun**( port, speed )
* **encoderMotorMove**( port, speed, distance, **def** onFinish )
* **encoderMotorMoveTo**( port, speed, position, **def** onFinish )
* **encoderMotorSetCurPosZero( port )
* **encoderMotorPosition( port, **def** onResult )
* **encoderMotorSpeed( port, **def** onResult )
* Stepper Motor
* **stepperMotorRun**( port, speed )
* **stepperMotorMove**( port, speed, distance, **def** onFinish )
* **stepperMotorMoveTo**( port, speed, position, **def** onFinish )
* **stepperMotorSetCurPosZero( port )

* Sensors
* Ultrasonic Sensor
* **ultrasonicSensorRead** ( port, **def** onResult )
* LineFollow Sensor
* **lineFollowerRead** ( port, **def** onResult )
* Light Sensor
* **lightSensorRead** ( port, **def** onResult )
* Sound Sensor
* **soundSensorRead** ( port, **def** onResult )
* Temperature Sensor
* **temperatureRead** ( port, **def** onResult )
* PIR Motion Sensor
* **pirMotionSensorRead** ( port, **def** onResult )
* Touch Sensor
* **touchSensorRead** ( port, **def** onResult )
* LimitSwitch
* **limitSwitchRead** ( port, slot, **def** onResult )
* Humiture Sensor
* **humitureSensorRead** ( port, type, **def** onResult )
* Gas Sensor
* **gasSensorRead** ( port, **def** onResult )
* Flame Sensor
* **flameSensorRead** ( port, **def** onResult )
* Button
* **buttonRead** ( port, **def** onResult )
* Potentiometer
* **potentiometerRead** ( port, **def** onResult )
* Joystick
* **joystickRead** ( port, axis, **def** onResult )
* 3-Axis Accelerometer and Gyro Sensor
* **gyroRead** (port, axis, **def** onResult )
* Compass
* **compassRead** ( **def** onResult )

* Display
* RGB Led
* **rgbLedSetColor** ( port, slot, index, r, g, b )
* **rgbLedShow** ( port, slot )
* **rgbLedDisplay** ( port, slot, index, r, g, b )
* 7-segment Display
* **sevenSegmentDisplay** ( port, value )
* Led Matrix Display
* **ledMatrixDisplayMessage** ( port, x, y, msg )
* **ledMatrixDisplayRaw** ( port, buffer )
* Serial LCD Display
* **lcdDisplay** ( string )

* Others
* DSLR Shutter
* **shutterOn** ( port )
* **shutterOff** ( port )
* **focusOn** ( port )
* **focusOff** ( port )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for megapi, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size megapi-0.2.2.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page