Skip to content

README.md update #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![logo](https://static.creatordev.io/logo-md-s.svg)
![logo](https://avatars2.githubusercontent.com/u/18185398?s=200&v=4)


# PyLetMeCreate
@@ -57,3 +57,10 @@ thermo3.disable()
# Release I2C
i2c.release()
```

## This repository is no longer maintained.

Issue reports and pull requests will not be attended.

---

9 changes: 5 additions & 4 deletions letmecreate/click/__init__.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
- CO
- Color
- Color2
- DC motor
- Eve
- Fan
- GYRO
@@ -32,7 +33,7 @@
"""

__all__ = ['seven_seg', 'led_matrix', 'accel', 'adc', 'air_quality', 'alcohol',
'bargraph', 'co', 'color', 'color2', 'eve', 'fan', 'gyro',
'ir_distance', 'ir_eclipse', 'joystick', 'light', 'lin_hall', 'lora',
'motion', 'oled', 'proximity', 'relay', 'relay2', 'relay4', 'rtc',
'thermo3', 'uni_hall']
'bargraph', 'co', 'color', 'color2', 'dc_motor', 'eve', 'fan',
'gyro', 'ir_distance', 'ir_eclipse', 'joystick', 'light',
'lin_hall', 'lora', 'motion', 'oled', 'proximity', 'relay',
'relay2', 'relay4', 'rtc', 'thermo3', 'uni_hall']
85 changes: 85 additions & 0 deletions letmecreate/click/dc_motor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env python3
"""Python binding of DC motor Click wrapper of LetMeCreate library."""

import ctypes

_LIB = ctypes.CDLL('libletmecreate_click.so')


def init(mikrobus_index):
"""Initialise the DC motor click.

mikrobus_index: must be 0 (MIKROBUS_1) or 1 (MIKROBUS_2)

Note: An exception is thrown if it fails to initialise the board.
"""
ret = _LIB.dc_motor_click_init(mikrobus_index)
if ret < 0:
raise Exception("dc motor click init failed")


def set_direction(mikrobus_index, direction):
"""Change the direction of the motor.

mikrobus_index: must be 0 (MIKROBUS_1) or 1 (MIKROBUS_2)
direction: must be 0 (reverse) or 1 (forward

Note: An exception is thrown if it fails to change the direction.
"""
ret = _LIB.dc_motor_click_set_direction(mikrobus_index, direction)
if ret < 0:
raise Exception("dc motor click set direction failed")


def get_direction(mikrobus_index):
"""Returns the direction of the motor.

mikrobus_index: must be 0 (MIKROBUS_1) or 1 (MIKROBUS_2)

Note: An exception is thrown if it fails to get the direction.
"""
direction = ctypes.c_uint8()
ret = _LIB.dc_motor_click_set_direction(mikrobus_index,
ctypes.byref(direction))
if ret < 0:
raise Exception("dc motor click get direction failed")
return direction.value


def set_speed(mikrobus_index, speed):
"""Change the speed of the motor.

mikrobus_index: must be 0 (MIKROBUS_1) or 1 (MIKROBUS_2)
speed: floating point value in range 0..100

Note: An exception is thrown if it fails to change the speed.
"""
ret = _LIB.dc_motor_click_set_speed(mikrobus_index, speed)
if ret < 0:
raise Exception("dc motor click set speed failed")


def get_speed(mikrobus_index):
"""Returns the speed of the motor.

mikrobus_index: must be 0 (MIKROBUS_1) or 1 (MIKROBUS_2)

Note: An exception is thrown if it fails to get the speed.
"""
speed = ctypes.c_float()
ret = _LIB.dc_motor_click_get_speed(mikrobus_index, ctypes.byref(speed))
if ret < 0:
raise Exception("dc motor click get speed failed")
return speed.value


def release(mikrobus_index):
"""Release the DC motor click.

Stops the motor.

Note: An exception is thrown if it fails to release
"""
ret = _LIB.dc_motor_click_release(mikrobus_index)
if ret < 0:
raise Exception("dc motor click release failed")