ev3dev-lang icon indicating copy to clipboard operation
ev3dev-lang copied to clipboard

Updating the JS binding for recent changes

Open WasabiFan opened this issue 10 years ago • 5 comments

@ddemidov Can I get a list of the changes that I need to adapt to on my Node.js side? I believe that there were changes to the LED spec, but didn't follow closely enough to fully grasp the changes that I should make. Also, what's the situation regarding supporting the various ev3dev platforms (RasPi, BB, etc)? Do we need to change the default instances?

P.S. Sorry I've been so out-of-touch :wink:

UPDATE: Current TODO list

  • [ ] Fix default names/instances for battery class
  • [x] Update examples and add new examples based on updates/additions
    • Additional ideas (after initial batch of example additions):
      • Requires a specific port
      • Uses the new sensor wrappers
  • [x] Test all codepaths on EV3
  • [ ] Update packaging for new structure
  • [ ] Add buttons?
  • [ ] Add sound?
  • [ ] Update spec to change pattern strings

WasabiFan avatar Nov 11 '15 04:11 WasabiFan

Here are the changes, I hope did not miss anything. Btw, thanks for opening this, it will also be useful for C++ bindings.

Motors

Sensors

Buttons, RemoteControl

  • We have created a ButtonBase class in python that provides some basic functionality for buttons and remote control. This is not in specification, but I think is worth noting.
  • Added mapping between InfraredSensor values in IR-REMOTE mode and RemoteControl buttons.
  • Added per platform specification for GPIO files and button values for EV3.

Leds

This is the biggest change in specification.

  • Led interface was switched to group-based. We used to group EV3 leds by color. That is, we had red group of red_left and red_right leds and green group of green_left and green_right. That only allowed us to operate on all leds at once to create colors like amber or orange. Group based interface makes led groups based on their location. We have left and right groups for EV3. This allows the user to think in terms or logical led that can create different colors. For example, the following code is now supported in python:
# Set left logical led to red color.
Leds.set_color(Leds.LEFT, Leds.RED)
# Set trigger for the right logical led, make it 50% bright:
Leds.set(Leds.RIGHT, trigger='timer', brightness_pct=0.5)

This also scales well onto other platforms. For example, PiStorms have two logical groups, each having Red, Blue, and Green physical leds.

Sound

  • This is not in specification, but we changed how sound works in python. Instead of using platform-specific sysfs node, we switched to using /usr/bin/beep for making beeps. See description of sound interface here.

The way we currently work with different platforms may change in the future, see discussion in ev3dev/ev3dev#412. Also see #115.

ddemidov avatar Nov 11 '15 07:11 ddemidov

Great! Thanks. I'll start working on these changes today.

WasabiFan avatar Nov 11 '15 17:11 WasabiFan

@ddemidov I noticed that the systemDeviceNameConvention uses a {0} to denote the numbers in a name. I think that was something I added as a test a while ago, and now we both replace that with a * for use. Should we just make that replacement in the spec?

WasabiFan avatar Nov 11 '15 23:11 WasabiFan

Oh, and what's the current status on detecting the running platform for buttons/LEDs? I saw a long discussion somewhere referencing a fair amount of Linux magic that I didn't understand... was that concluded? If not, what are you doing for C++ and Python in this area?

WasabiFan avatar Nov 12 '15 02:11 WasabiFan

and now we both replace that with a * for use. Should we just make that replacement in the spec?

I don't see why not.

Oh, and what's the current status on detecting the running platform for buttons/LEDs?

I think that is still in the planning phase. I made rhempel/ev3dev-lang-python#90 with this in mind, but nothing besides that.

ddemidov avatar Nov 12 '15 03:11 ddemidov