ev3dev / ev3dev-lang

(deprecated) language bindings for ev3dev sensors, motors, LEDs, etc.
GNU General Public License v2.0
56 stars 39 forks source link

Convert types and indices in special sensor specification to lists #169

Closed ddemidov closed 7 years ago

ddemidov commented 7 years ago

This allows to correctly work with modes that have several values. The immediate example is GYRO-G&A mode that is added to gyroSensor with this PR.

:exclamation: Requires rewriting templates for special sensor types.

See ddemidov/ev3dev-lang-cpp#10

WasabiFan commented 7 years ago

Sorry I haven't been involved in that thread so far.

Although this looks good code-wise, I am wondering why we need it. Is there an advantage to doing this over just always using the G&A mode for that sensor? I haven't gotten the chance to do a speed comparison.

ddemidov commented 7 years ago

Citing @dlech: https://github.com/ddemidov/ev3dev-lang-cpp/issues/10#issuecomment-249599869

WasabiFan commented 7 years ago

Give me some time to look through this more closely (I want to understand the C++ template you have); right now I don't think I properly understand the use case.

ddemidov commented 7 years ago

Sure. Compare the result of the template here: https://github.com/ddemidov/ev3dev-lang-cpp/blob/858c0cb77b43f4e265fc571783986f5da51db556/ev3dev.h#L481-L491

The first method is generated from a type/indices list with single entry, and the second is generated from two entries. The template just checks if the type list has single entry and does different things depending on that.

WasabiFan commented 7 years ago

By the way, I haven't forgotten about this; I just haven't had a time to read through and understand the changes and their implications. If you want to merge this before I can take a look, go ahead; I trust your judgment.

WasabiFan commented 7 years ago

OK, I understand this now. LGTM.