microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
726 stars 638 forks source link

requesting magnetometer (x,y,z) values triggers a calibration #4995

Closed jaustin closed 1 year ago

jaustin commented 1 year ago

Describe the bug

The magnetometer supports a number of different modes of operation. It is possible to read the raw x/y/z values of the compass without calibrating first, and this gives a good experience to anyone wanting to use the magnetometer to measure local strong magnets (for example making a wand game, etc)

To Reproduce call input.magneticForce(Dimension.X) (or any dimension) -->calibration starts

Expected behavior

Uncalibrated X,Y,Z values reported

It looks like MakeCode is enforcing the calibration here https://github.com/microsoft/pxt-microbit/blob/4375b988b21e7fea5188e982205dc184b54e52d7/libs/core/input.cpp#L352-L354 - we don't do this in MicroPython and seems to be fine.

abchatra commented 1 year ago

@jaustin feel free to do a PR.

martinwork commented 1 year ago

@jaustin Related: https://github.com/microsoft/pxt-microbit/issues/1750, Sorry! I only just remembered seeing this.

abchatra commented 1 year ago

@jaustin to do a PR here.

abchatra commented 1 year ago

@jaustin do you want us to take over this change?

davidhoness commented 1 year ago

@jaustin @martinwork @abchatra

Dear all

I’m working on an Educational project of the European Space Agency involving an ESA astronaut using a micro:bit v2 on board the International Space Station later this year. The project involves students sending in their own HEX files which will be run on board the ISS as experiments.

Details here: https://www.dr.dk/skole/ultrabit/artikel-ultrabit-rejser-ud-i-rummet-med-andreas-mogensen

We have identified that the compass calibration step relies on the accelerometer to know the orientation of the device. On board the ISS the accelerometer will read zero (plus maybe some noise) on all axes and therefore we predict that it would not be possible to get past the compass calibration step, and onto the user code, in the presence of microgravity. This would therefore mean that the students would have to avoid using the compass or use a different software stack like Micro-Python or Open Roberta.

The students will be working on writing their experiments in the months of August and September 2023, so I am wondering if there is any possibility for this change request to be including in your upcoming 2023 summer release milestone?

Many thanks Dave Honess

abchatra commented 1 year ago

Thanks @davidhoness. I have a put up a PR to address this. This should be in /beta soon and will be in product once we release in mid June.

abchatra commented 1 year ago

Fixed in beta https://makecode.microbit.org/beta#editor

davidhoness commented 1 year ago

FYI, today I have tested the beta version by running a program that uses the magnetic force block - however the Tilt to fill screen calibration step is still coming up on the micro:bit v2.21 hardware. So it doesn't look like the beta fix has worked.

abchatra commented 1 year ago

@davidhoness can you share your program just to make sure we are testing the right scenario?

davidhoness commented 1 year ago

Here's the program I am using; https://makecode.microbit.org/_5tb4Du97PY7R

abchatra commented 1 year ago

@davidhoness this program has compas heading which will trigger calibration. AFAIK There is no way to do that without calibration. Fix is only for magnetic force block.

image
abchatra commented 1 year ago

@jaustin to confirm