Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nxt Light Sensor support #1027

Merged
merged 54 commits into from
Feb 2, 2024
Merged

Conversation

THEb0nny
Copy link
Contributor

First support code for nxt light sensor analog sensor. The sensor gives real values. If the sensor is pulled out of the port, then the value is 4096. The default mode is reflection mode with the backlight turned on.
Support for switching modes is not implemented.

Some of the code was taken from here...
#948

I will work on changing the mode of operation.

Add NXT Sensors subcategorie
The light sensor gives real values. Mode change not supported...
@THEb0nny THEb0nny marked this pull request as draft July 14, 2023 17:43
The simulator now understands that it has an EV3 or NXT analog sensor enabled. The devType value of the virtual sensor will be passed so that the sensor becomes active in the simulator and transmits its values to the simulator.
Setting the range of values for determining black and white in reflection mode and in ambient light mode is now different.
@THEb0nny
Copy link
Contributor Author

Implemented support for the simulator. All that remains is to change the svg image for the sensor. Later I'll draw it in Illustrator.

@THEb0nny
Copy link
Contributor Author

THEb0nny commented Oct 23, 2023

I note that the analog touch sensor also works. I tested this on hardware as well.

image

image

@THEb0nny THEb0nny marked this pull request as ready for review October 23, 2023 11:12
I'm removing an unnecessary function that doesn't work, which I took from the pelikhan change. It does not apply to this change with the sensor and data input.
@THEb0nny
Copy link
Contributor Author

I have verified that the problem with two nxt analog light sensors, the problem with duplicate values is gone.
Maybe I did something wrong during testing before.
As a result, the sensors show different values.
First of all, this concerns hardware; I also tested it on hardware.
image

@THEb0nny
Copy link
Contributor Author

image

@THEb0nny
Copy link
Contributor Author

THEb0nny commented Nov 3, 2023

@jwunderl please look at this change

@THEb0nny
Copy link
Contributor Author

THEb0nny commented Nov 3, 2023

Conflicts arose because the changes were based on the old version. It takes some time to solve them.

Fix range - 0..4095
Disable the visibility of ambient blocks so that they are not used, because There is no implementation of disabling LED lighting.
Solving the problem that the field in the simulator and the value from the sensor on the screen could be different.
And one more thing...
@THEb0nny THEb0nny marked this pull request as draft November 12, 2023 21:57
The changes are aimed at supporting reflection and lighting modes, not raw modes.
Setting the mode so that the sensor starts working in the simulator. Otherwise, it, like a touch sensor, does not create view control, because in the touch sensor this was not necessary. Without this change, lightView would only activate if a sensor with type uart was used in the code.
Support blocks have been removed, which may be available later. The ambient mode has been removed, because There is no implementation of turning off the backlight LED. Now it is always on.
Make sure that the library is not included by default. It will need to be enabled via extensions.
@THEb0nny THEb0nny marked this pull request as ready for review December 13, 2023 22:07
@THEb0nny
Copy link
Contributor Author

@jwunderl look here please?

@THEb0nny
Copy link
Contributor Author

THEb0nny commented Dec 14, 2023

There are currently two modes of raw reflection values and a reflection mode being implemented. The mode of external consecration is hidden, because The backlight LED must be turned off. I couldn't do it. According to the developers’ scheme, pin 5 should not be supplied with power, but I don’t know how to implement this now.

Simulator support is also implemented.

The implementation of this sensor does not interfere with the operation of the ev3's other analog sensor, the touch sensor.

There is also an issue with the documentation, I will implement it in full later.

This is a beta version of the library, but it is already needed now so that children can use this sensor. As I use it, I find problems and solve them. As I use it, I find problems and solve them.

@THEb0nny
Copy link
Contributor Author

THEb0nny commented Dec 14, 2023

2023-12-14_23-22-37.mp4

https://photos.app.goo.gl/xuUM93NHKnazHCvJ7
Video on hardware. Line 3 reflective sensor nxt in raw mode.

Copy link
Member

@jwunderl jwunderl left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the PR!

@jwunderl jwunderl merged commit 891a237 into microsoft:master Feb 2, 2024
1 check passed
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.

2 participants