Skip to content

[breaking] Special properties - #229

Merged
ddemidov merged 2 commits into
developfrom
special-properties
Oct 28, 2016
Merged

ddemidov merged 2 commits into
developfrom
special-properties

Conversation

@ddemidov

Copy link
Copy Markdown
Member

This converts special sensor methods to properties for the sake of uniformity throughout the library. See discussion in #228.

This will break existing code!

Instead of

print( cs.ambient() )   # function call syntax
cs.mode = 'COL-AMBIENT'
while True:
    log(cs.ambient(do_set_mode=False)) # do not set mode when polling the sensor value

one has to

print( cs.ambient )   # property syntax
cs.mode = 'COL-AMBIENT'
cs.auto_mode = False  # do not set mode when polling the sensor value
while True:
    log(cs.ambient)

I've updated my part of the demo scripts. @dwalton76, if we decide to merge this, could you take care of yours?

@ensonic

ensonic commented Oct 14, 2016

Copy link
Copy Markdown
Contributor

I never use do_set_mode in openroberta so fine for me.

@ddemidov

Copy link
Copy Markdown
Member Author

@ensonic, I was more concerned about function-call vs get-property syntax (cs.ambient() vs cs.ambient). I think openroberta was implemented before we introduced special sensor properties though, so I guess you use cs.value() instead? That should still work.

@WasabiFan

Copy link
Copy Markdown
Member

This looks good to me by the way, although I'd like to hear back from @ensonic on whether this will be an issue to get some user feedback.

@ensonic

ensonic commented Oct 28, 2016

Copy link
Copy Markdown
Contributor

@ddemidov , yes I use value(), see
https://github.com/OpenRoberta/robertalab-ev3dev/blob/develop/roberta/ev3.py#L452
FYI, all the code that interfaces with hardware is in there.

@ddemidov
ddemidov merged commit ea66472 into develop Oct 28, 2016
@ddemidov
ddemidov deleted the special-properties branch October 28, 2016 17:36
ddemidov added a commit that referenced this pull request Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants