# Notation - `(value)` - `(d! dropdown)` - `` - `(m! display matrix picker)` # Hub - DONE `initialize hub (d! top_side = Axis.Z) (d! front_size = Axis.X)` - transpiled: `hub = PrimeHub(top_side, front_side)` ## Hub - Status Light - DONE `set button color to (d! color)` - transpiled: `hub.light.on(color)` - DONE `turn off button light` - transpiled: `hub.light.off()` todo: light.blink todo: light.animate ## Hub - Display - `set display orientation to (d! side)` - transpiled: `hub.display.orientation(side)` - DONE `turn display off` - transpiled: `hub.display.off()` - `set (m! row, col) to (brightness %) brightness` - transpiled: `hub.display.pixel(row, col, brightness)` - `show (m! picutre) on display` - transpiled: `hub.display.icon(picture)` todo: display.animate - DONE `show (number) on display` - transpiled: `hub.display.number(number)` - `show (char) on display` - transpiled: `hub.display.char(char)` - DONE `scroll (text) on display` - transpiled: `hub.display.text(text)` - `scroll (text) on display, on for (on) off for (off)` - transpiled: `hub.display.text(text, on, off)` ## Hub - Buttons !- `(buttons pressed)` ! - transpiled: `hub.buttons.pressed()` - DONE `` - transpiled: `button in hub.buttons.pressed()` ## Hub - IMU - DONE `` - transpiled: `hub.imu.ready()` - DONE `` - transpiled: `!hub.imu.stationary()` - `(side facing up)` - transpiled: `hub.imu.up()` - DONE `(pitch)` - transpiled: `hub.imu.tilt()[0]` - DONE `(roll)` - transpiled: `hub.imu.roll()[1]` - DONE `(acceleration (d! axis))` - transpiled: `hub.imu.acceleration(axis)` - DONE `(angular velocity (d! axis))` - transpiled: `hub.imu.angular_velocity(axis)` - DONE `(yaw)` - transpiled: `hub.imu.heading()` - warning: must be reset if lifted from table - reset in prelude? - DONE `reset yaw angle` - transpiled: `hub.imu.reset_heading(0)` - DONE `reset yaw angle to (degrees)` - transpiled: `hub.imu.reset_heading(degrees)` todo: imu.rotation todo: imu.orientation - DONE `(angular velocity threshold)` - transpiled: `hub.imu.settings()[0]` - DONE `(acceleration threshold)` - transpiled: `hub.imu.settings()[1]` - DONE `set angular velocity threshold to (threshold)` - transpiled: `hub.imu.settings(threshold, hub.imu.settings()[1])` - DONE `set acceleration threshold to (threshold)` - transpiled: `hub.imu.settings(hub.imu.settings()[0], threshold)` ## Hub - Speaker - `(volume)` - transpiled: `hub.speaker.volume()` - `set speaker volume to (volume)` - transpiled: `hub.speaker.volume(volume)` - `play tone (frequency) for (ms) ms` - transpiled: `hub.speaker.beep(frequency, ms)` - `start playing tone (frequency)` - transpiled: `hub.speaker.beep(frequency, -1)` todo: speaker.play_notes ## TODO: Hub - Bluetooth Not legal for competition, so I skipped it. Easy to design though, for late.r ## Hub - Battery - `(battery voltage)` - transpiled: `hub.battery.voltage()` - `(battery current)` - transpiled: `hub.battery.current()` - `` - transpiled: `hub.charger.connected()` - `(charging current)` - transpiled: `hub.charger.current()` - `` - transpiled: `hub.charger.status() == 1` - `` - transpiled: `hub.charger.status() == 2` - `` - transpiled: `hub.charger.status() == 3` ## Hub - Control - `set stop button to (button)` - transpiled: `hub.system.set_stop_button(button)` - `(hub name)` - transpiled: `hub.system.name()` todo: system.storage - DONE `stop and exit program` - program terminator - transpiled: prelude code, go back to selection screen - DONE `stop and restart program` - program terminator - transpiled: prelude code, exit, run again - DONE `stop and shutdown system` - program terminator - transpiled: `hub.system.shutdown()` - `` - transpiled: `hub.system.reset_reason() == 0` - `` - transpiled: `hub.system.reset_reason() == 1` - `` - transpiled: `hub.system.reset_reason() == 2` # Motors ## Motors - DC - `turn on dc motor (port) at (power) power` - transpiled: `motor.dc(power)` - `stop dc motor (port)` - transpiled: `motor.stop()` - `set max voltage of dc motor (port) to (voltage)` - transpiled: `motor.settings(voltage)` - `(max voltage of dc motor (port))` - transpiled: `motor.settings()[0]` - `set positive direction of dc motor (port) to (d! direction)` - transpiled: RESET motor variable with the direction ## Motors - `set positive direction of motor (port) to (d! direction)` - traspiled: RESET motor variable with the direction todo: geartrain todo: reset_angle - `((port) rotation angle)` - transpiled: `motor.angle()` - `reset rotation angle of (port)` - transpiled: `motor.reset_angle(0)` - `reset rotation angle of (port) to (deg)` - transpiled: `motor.reset_angle(deg)` - `((port) current speed)` - transpiled: `motor.speed()` - `((port) current load)` - transpiled: `motor.load()` - `<(port) is stalled?>` - transpiled: `motor.stalled()` - `(port) stop moving` - transpiled: `motor.stop()` - `(port) brake` - transpiled: `motor.brake()` - `(port) stop and hold position` - transpiled: `motor.hold()` - `(port) start moving at (speed)` - transpiled: `motor.run(speed)` - `(port) start moving at (power) power` - transpiled: `motor.dc(power)` - `(port) run for (time) seconds at (speed) speed, then (d! stop action)` - transpiled: `motor.run_time(speed, time, stop action, True)` - `(port) start running for (time) seconds at (speed) speed, then (d! stop action)` - transpiled: `motor.run_time(speed, time, stop action, False)` - `(port) run for (deg) degrees at (speed), then (d! stop action)` - transpiled: `motor.run_angle(speed, deg, stop action, True)` - `(port) start running for (deg) degrees at (speed), then (d! stop action)` - transpiled: `motor.run_angle(speed, deg, stop action, False)` - `(port) go to relative position (deg) at (speed), then (d! stop action)` - transpiled: `motor.run_target(speed, deg, stop action, True)` - `(port) start moving to relative position (deg) at (speed), then (d! stop action)` - transpiled: `motor.run_target(speed, deg, stop action, False)` - `(port) go to relative position (deg) immediately` - transpiled: `motor.track_target(deg)` - `(port) run at (speed) speed until stalled, then (d! stop action)` - transpiled: `motor.run_until_stalled(speed, stop action)` - `(port) run at (speed) speed until stalled, then (d! stop action), with maximum power (power)` - transpiled: `motor.run_until_stalled(speed, stop action, power)` - `<(port) is done moving?>` - transpiled: `motor.done()` - `((port) max speed)` - transpiled: `motor.limits()[0]` - `((port) max acceleration)` - transpiled: `motor.limits()[1]` - `((port) max torque)` - transpiled: `motor.limits()[2]` - `set (port) max speed to (speed)` - transpiled: `motor.limits(speed, motor.limits()[1], motor.limits()[2])` - `set (port) max acceleration to (accel)` - transpiled: `motor.limits(motor.limits()[0], accel, motor.limits()[2])` - `set (port) max torque to (torq)` - transpiled: `motor.limits(motor.limits()[0], motor.limits()[1], torq)` TODO: pid TODO: tolerances TODO: stall tolerances TODO: scale TODO: state TODO: settings # Tilt Sensor - `((port) pitch)` - transpiled: `sensor.tilt()[0]` - `((port) roll)` - transpiled: `sensor.tilt()[1]` # Infrared Sensor - `((port) infrared distance)` - transpiled: `sensor.distance()` - `((port) infrared reflection)` - transpiled: `sensor.reflection()` - `((port) object count)` - transpiled: `sensor.count()` # Color and Distance Sensor - `<(port) color is (d! color)?>` - transpiled: `sensor.color() == color` - `((port) reflection)` - transpiled: `sensor.reflection()` - `((port) intensity)` - transpiled: `sensor.ambient()` - `((port) infrared distance)` - transpiled: `sensor.distance()` TODO: detectable_colors - `set (port) light to (d! color RGB)` - transpiled: `sensor.light.on(color)` - `turn off (port) light` - transpiled: `sensor.light.off()` # TODO - Power Functions Infrared Controls # Color Sensor - `<(port) color is (d! color)?>` - transpiled: `sensor.color() == color` - `((port) reflection)` - transpiled: `sensor.reflection()` - `((port) intensity)` - transpiled: `sensor.ambient()` - `((port) hue)` - transpiled: `sensor.hsv().h` - `((port) saturation)` - transpiled: `sensor.hsv().s` - `((port) brightness)` - transpiled: `sensor.hsv().v` TODO: detectable_colors - `turn on (port) light at (power) brightness` - transpiled: `sensor.lights.on(power)` - `turn off (port) light` - transpiled: `sensor.lights.off()` # Ultrasonic Sensor - `((port) distance)` - transpiled: `sensor.distance()` - `<(port) other ultrasonic sensors nearby?>` - transpiled: `sensor.presence()` - `turn on (port) light at (power) brightness` - transpiled: `sensor.lights.on(power)` - `turn off (port) light` - transpiled: `sensor.lights.off()` # Force Sensor - `((port) force)` - transpiled: `sensor.force()` - `((port) distance travelled)` - transpiled: `sensor.distance()` - `<(port) pressed?>` - transpiled: `sensor.pressed()` - `<(port) touched?>` - transpiled: `sensor.touched()` # TODO - Color Light Matrix # Light - `turn on (port) at (power) brightness` - transpiled: `sensor.on(power)` - `turn off (port)` - trnaspiled: `sensor.off()` # TODO - Remote Control # Constants ## Constants - Axis - `(x axis)` - transpiled: `Axis.X` - `(y axis)` - transpiled: `Axis.Y` - `(z axis)` - transpiled: `Axis.Z` ## Constants - Button - `(left button)` - transpiled: `Button.LEFT` - `(center button)` - transpiled: `Button.CENTER` - `(right button)` - transpiled: `Button.RIGHT` - `(bluetooth button)` - transpiled: `Button.BLUETOOTH` ## Constants - Stop Behavior - `coast` - transpiled: `Stop.COAST` - `preplanned coast` - transpiled: `Stop.COAST_SMART` - `brake` - transpiled: `Stop.BRAKE` - `hold position` - transpiled: `Stop.HOLD` - `do not stop` - transpiled: `Stop.NONE` # Tools - `wait (ms) ms` - transpiled: `tools.wait(ms)` ## TODO - Tools - Stopwatch # Movement (Robotics) - `set movement motors to (left port) and (right port)` - transpiled: `left_motor = left port; right_motor = right port; drive = DriveBase(left_motor, right_motor, wd, track)` - `set wheel diameter to (mm) mm` - transpiled: `wd = mm; drive = DriveBase(left_motor, right_motor, wd, track)` - `set track width to (mm) mm` - transpiled: `track = mm; drive = DriveBase(left_motor, right_motor, wd, track)` - `move (mm) mm, then (d! stop)` - transpiled: `drive.straight(mm, stop, True)` - `start moving (mm) mm, then (d! stop)` - transpiled: `drive.straight(mm, stop, False)` - `turn in place (deg) degrees, then (d! stop)` - transpiled: `drive.turn(deg, stop, True)` - `start turning in place (deg) degrees, then (d! stop)` - transpiled: `drive.turn(deg, stop, False)` - `turn (deg) degrees across a (rad) mm arc, then (d! stop)` - transpiled: `drive.curve(rad, deg, stop, True)` - `start turning (deg) degrees across a (rad) mm arc, then (d! stop)` - transpiled: `drive.curve(rad, deg, stop, False)` - `(movement speed)` - transpiled: `drive.settings()[0]` - `(movement acceleration)` - transpiled: `drive.settings()[1]` - `(turn speed)` - transpiled: `drive.settings()[2]` - `(turn acceleration)` - transpiled: `drive.settings()[3]` - `set movement speed to (speed)` - transpiled: `drive.settings(speed, drive.settings()[1], drive.settings()[2], drive.settings()[3])` - `set movement acceleration to (speed)` - transpiled: `drive.settings(drive.settings()[0], speed, drive.settings()[2], drive.settings()[3])` - `set turn speed to (speed)` - transpiled: `drive.settings(drive.settings()[0], drive.settings()[1], speed, drive.settings()[3])` - `set turn acceleration to (speed)` - transpiled: `drive.settings(drive.settings()[0], drive.settings()[1], drive.settings()[2], speed)` - `` - transpiled: `drive.done()` - `start moving at (spd) speed` - transpiled: `drive.drive(spd, 0)` - `start moving at (spd) speed with turn rate (tr)` - transpiled: `drive.drive(spd, tr)` - `stop moving` - transpiled: `drive.stop()` - `(relative distance)` - transpiled: `drive.distance()` - `(relative angle)` - transpiled: `drive.angle()` - `(current drive speed)` - transpiled: `drive.state()[1]` - `(current turn rate)` - transpiled: `drive.state()[3]` - `reset angle and distance` - transpiled: `drive.reset()` - `` - transpiled: `drive.stalled()` - `use gyroscope for movement` - transpiled: `drive = GyroDriveBase(left_motor, right_motor, wd, track)` - `use math for movement` - transpiled: `drive = DriveBase(left_motor, right_motor, wd, track)` # Random - `(random number from (a) to (b))` - transpiled: `urandom.randint(a, b)` - `(random decimal from 0 to 1)` - transpiled: `urandom.random()` # Control - `repeat (n)` - transpiled: `for i in range(n):` - `forever` - transpiled: `while True:` - `if then` - transpiled: `if cond:` - `if then else` - transpiled: `if cond: else:` - `wait until ` - transpiled: `while !: pass` - `repeat until ` - transpiled: `while !cond:` - `stop` - transpiled: `raise SystemExit("Exited by program")` # Operators - `((a) + (b))` - transpiled: `a + b` - `((a) - (b))` - transpiled: `a - b` - `((a) * (b))` - transpiled: `a * b` - `((a) / (b))` - transpiled: `a / b` - `<(a) > (b)>` - transpiled: `a > b` - `<(a) < (b)>` - transpiled: `a < b` - `<(a) = (b)>` - transpiled: `a == b` - `< and >` - transpiled: `a and b` - `< or >` - transpiled: `a or b` - `>` - transpiled: `not a` - `(join (a) (b))` - transpiled: `a + b` - `(letter (n) of (a))` - transpiled: `a[n]` - `(length of (a))` - transpiled: `len(a)` - `<(a) contains (b)?>` - transpiled: `a in b` - `((a) mod (b))` - transpiled: `a % b` - `(round (a))` - transpiled: `round(a)` TODO: operators # Variables Variables are stored as python variables with the prefix `UVAR` - for example `UVAR_myvar` # My blocks re just functions