Skip to content

Scale values of type 'float' when returned from special sensor classes#330

Merged
ddemidov merged 2 commits intodevelopfrom
scale-values
Aug 7, 2017
Merged

Scale values of type 'float' when returned from special sensor classes#330
ddemidov merged 2 commits intodevelopfrom
scale-values

Conversation

@ddemidov
Copy link
Copy Markdown
Member

Fixes #329

@ddemidov
Copy link
Copy Markdown
Member Author

Not yet tested on the EV3.

Copy link
Copy Markdown
Member

@WasabiFan WasabiFan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to test live, but it looks good in general.

@ddemidov
Copy link
Copy Markdown
Member Author

So I did test this on the EV3, which resulted in 271f02a. But it seems I don't posses a single sensor that would both be listed in special sensors section and have a floating point value with non-zero decimals. All I could test is that Sensor._scale(mode) does work correctly (it returns 1 for my sensors). @marnovdm, would you mind testing this with your Ultrasonic sensor?

@marnovdm
Copy link
Copy Markdown

marnovdm commented Jul 17, 2017

Thanks for the update, I will test this when I get home later today and update this comment.

UPDATE @ddemidov: I replaced core.py on my ev3 with the modified version for this commit. I was unable to find the liquid modified template file, but think it doesn't matter (?). When I test now it seems to work and returns the distance in centimeters:

>>> import ev3dev.ev3 as ev3
>>> ultrasonic = ev3.UltrasonicSensor('in1')
>>> ultrasonic.distance_centimeters
95.10000000000001
>>> ultrasonic.distance_centimeters
51.900000000000006
>>> ultrasonic.distance_centimeters
6.7
>>> ultrasonic.distance_centimeters
32.6
>>> ultrasonic.distance_centimeters
32.2
>>> ultrasonic.distance_centimeters
45.2
>>> ultrasonic.distance_centimeters
52.7
>>> ultrasonic.distance_centimeters
13.0

Looks good to me, thanks for fixing this so quickly!

@ddemidov
Copy link
Copy Markdown
Member Author

ddemidov commented Aug 7, 2017

Sorry, did not see the updated comment (github does not send notifications on updates, so its better to create new comments). Thanks for testing!

@ddemidov ddemidov merged commit 798cad1 into develop Aug 7, 2017
@ddemidov ddemidov deleted the scale-values branch August 7, 2017 15:28
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