Skip to content

Releases: jtobinart/CircuitPython_CLUE_Cutebot

Compatibility with CircuitPython v5.3.1

27 Sep 20:27
1a91c19
Compare
Choose a tag to compare

This version was originally released on September 8, 2020, on the eave of CircuitPython day. It is compatible with CircuitPython v5.3.1. The CircuitPython-v5.3.1 branch contains an archive of the python files and the accompanying examples for this code.

Changes:

  • Code is much more efficient and leaner
  • Code handles unforeseen errors better
  • The edited version of the CLUE library has been absorbed by the Cutebot library
  • The CLUE and Cutebot libraries are imported by using from jisforjt_cutebot_clue import cutebot, clue
  • Sensor functions are now properties and as such parenthesis (i.e. round brackets) are no longer required when calling the functions
  • Sensor functions have been renamed - all letters are lowercase and the prefix "get" has been removed from all of them

Usage:

from jisforjt_cutebot_clue import cutebot, clue

cutebot.playTone(tone, duration)
 # Parameters:
    # tone (int) - the frequency of the tones/music notes you want to play
    # duration (float) - the number of seconds you want to play the tone

cutebot.headlights(whichLight, colors)
cutebot.pixels(whichLight, colors)
 # Parameters:
    # whichLight (integer) - there are four states to choose from
        # 0 = Sets both lights to off
        # 1 = Sets left light only
        # 2 = Sets right light only
        # 3 = Sets both lights
    # colors (array of three integers) - RGB color that will be displayed
        # colors[0] = red
        # colors[1] = green
        # colors[2] = blue

cutebot.lightsOff()        # Turn off all LEDs

cutebot.motors(leftSpeed, rightSpeed)
 # Parameters:
    # leftSpeed (int) - speed of the left motor (Speed Range: full backwards = -100, stop = 0, and full forwards = 100)
    # rightSpeed (int) - speed of the right motor (Speed Range: full backwards = -100, stop = 0, and full forwards = 100)

cutebot.motorsOff()      # stops Cutebot's motors

cutebot.servoMaxAngleInDegrees = 180         # Set to your servos' maximum degree angle
cutebot.servos(whichServo, angleInDegrees)
 # Parameters:
    # whichServo (integer) - there are three states to choose from
        # 1 = S1 Servo (0x05)
        # 2 = S2 Servo (0x06)
        # 3 = S1 and S2 Servos
    # angleInDegrees (integer) - the angle in degrees that the servo(s) should be set to

cutebot.centerServos()      # centers both servos

cutebot.p1          # Returns a value between 0 and 65535 from the P1 sensor extension pins
cutebot.p2          # Returns a value between 0 and 65535 from the P2 sensor extension pins
cutebot.sonar        # Returns the distance between the ultrasound sensor and the object in front of it in centimeters (cm)
cutebot.tracking        # Returns two true or false values - first for the left line sensor and second for the right line sensor.

Compatibility with CircuitPython v5.3.0

27 Sep 20:27
d11ed99
Compare
Choose a tag to compare

This version was originally released on July 27, 2020, and was compatible with CircuitPython v5.3.0. The CircuitPython-v5.3.0 branch contains the python files and the accompanying examples for this code.

This version is a higher-level library that requires you to use two files to control all the features of Adafruit's CLUE dev board and ElecFreaks' Smart Cutebot. Due to issues with the i2c clock frequency, a special instance of busio.I2C was created and shared with both the edited version of the CLUE and Cutebot libraries. This version of the CLUE library contains all the features of the original except for the touch features.

Usage:

import cutebot
from cutebot import clue

cutebot.playTone(tone, duration)
 # Parameters:
    # tone (int) - the frequency of the tones/music notes you want to play
    # duration (float) - the number of seconds you want to play the tone

cutebot.headlights(whichLight, colors)
cutebot.pixels(whichLight, colors)
 # Parameters:
    # whichLight (integer) - there are four states to choose from
        # 0 = Sets both lights to off
        # 1 = Sets left light only
        # 2 = Sets right light only
        # 3 = Sets both lights
    # colors (array of three integers) - RGB color that will be displayed
        # colors[0] = red
        # colors[1] = green
        # colors[2] = blue

cutebot.lightsOff()        # Turn off all LEDs

cutebot.motors(leftSpeed, rightSpeed)
 # Parameters:
    # leftSpeed (int) - speed of the left motor (Speed Range: full backwards = -100, stop = 0, and full forwards = 100)
    # rightSpeed (int) - speed of the right motor (Speed Range: full backwards = -100, stop = 0, and full forwards = 100)

cutebot.motorsOff()      # stops Cutebot's motors

cutebot.servoMaxAngleInDegrees = 180         # Set to your servos' maximum degree angle
cutebot.servos(whichServo, angleInDegrees)
 # Parameters:
    # whichServo (integer) - there are three states to choose from
        # 1 = S1 Servo (0x05)
        # 2 = S2 Servo (0x06)
        # 3 = S1 and S2 Servos
    # angleInDegrees (integer) - the angle in degrees that the servo(s) should be set to

cutebot.centerServos()      # centers both servos

cutebot.getP1()          # Returns a value between 0 and 65535 from the P1 sensor extension pins
cutebot.getP2()          # Returns a value between 0 and 65535 from the P2 sensor extension pins
cutebot.getSonar()        # Returns the distance between the ultrasound sensor and the object in front of it in centimeters (cm)
cutebot.getTracking()        # Returns two true or false values - first for the left line sensor and second for the right line sensor.