microsoft / pxt-ev3

Microsoft MakeCode editor for the LEGO MINDSTORMS EV3 Brick
https://makecode.mindstorms.com/
Other
54 stars 39 forks source link

Nxt Light Sensor support #1027

Closed THEb0nny closed 9 months ago

THEb0nny commented 1 year ago

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... https://github.com/microsoft/pxt-ev3/pull/948

I will work on changing the mode of operation.

THEb0nny commented 1 year ago

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 commented 1 year ago

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

image

image

THEb0nny commented 1 year ago

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 commented 1 year ago

image

THEb0nny commented 1 year ago

@jwunderl please look at this change

THEb0nny commented 1 year ago

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

THEb0nny commented 1 year ago

image

Everything seems to be working.

THEb0nny commented 11 months ago

@jwunderl look here please?

THEb0nny commented 11 months ago

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 commented 11 months ago

https://github.com/microsoft/pxt-ev3/assets/13646226/ed7d5183-916d-4a54-ab0a-a77c24da30ba

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