[Snek] Is EV3 port of Snek a good idea?

Mikhail Gusarov dottedmag at dottedmag.net
Sat Feb 8 01:00:21 PST 2020


On 8 Feb 2020, at 4:03, Keith Packard wrote:

> The EV3 sensors and actuators are way more sophisticated than what 
> we've
> used on other devices, so I'm not sure if it makes sense, but I'd love
> to see the API look more like how Snek works on other boards, which 
> uses
> the LEGO Logo semantics:
>         talkto()
>         setpower()
>         on()
>         off()
>         etc...

I thought a bit about it, and here's the mapping — any ideas about 

EV3 ports: 1-4 sensors, A-D actuators. `talkto` sets the current port.

# Tacho motor

- `setpower` sets the speed, 0..1 (XXX max speed is 3 rotations per 
second - should it be 0..3?)
- `setleft` / `setright` as usual
- `on` / `off` as usual
- `onfor` as usual
- `read` reads the current speed

XXX Tacho motors know their position and can rotate to reach position X
XXX and to increase position by X. How to expose it?

# Push button

- `read` as usual: 0/1

# Distance sensor

- `read` as usual: 0..n centimetres, `inf` if unable to sense anything

# Light sensor

This sensor has 4 modes.

- XXX `setmode(COLOR)`? `setpower(COLOR)`? 

   Or use `read(A_COLOR)`? But mode needs to be set before read, or the 
   won't have time to happen after mode switch.

- `read` as usual, results depend on the current mode:
   - reflected strength: strength of sensor's LED reflected from object, 
   - ambient strength: strength of ambient light, 0..1
   - color: "none" / "black" / "blue" / "green" / "yellow" / "red" / 
"white" / "brown"
   - RGB: (0, 0, 0) .. (1, 1, 1)

# Gyroscope

XXX Not even started on this yet.


More information about the Snek mailing list