Compass App
#6
Thumbs Up 
(06-24-2021, 02:58 PM)lgtrombetta Wrote: @threepwood I made the terminal output more readable. Check it out on the devel branch.

For calibration, take note of the minimum and maximum values of each of the raw measurements Bx, By and Bz, as you rotate your phone around each axis (try to do it on the same spot such that the total field intensity B remains roughly constant). Then, compute the average between min and max for each axis and those are the 3 numbers you should put in the compass.conf file.

Checked it now, looks really good.

As for the permission issue when changing the sampling frequency, one possibility is to use a Udev rule. I tried by adding the following to the file "/etc/udev/rules.d/90-accelerometer.rules":
Quote:ATTRS{name}=="lis3mdl", RUN+="/bin/sh -c 'chgrp -R iio /sys%p; chmod -R g=u /sys%p'"

After reloading the device (sudo udevadm control --reload-rules + sudo udevadm trigger /sys/bus/iio/devices/iio:device2) it belongs to the "iio" group, and any member of this group gets write permission to the "sampling_frequency" file.

Not sure if this is a recommended approach though, it would probably be better if this was added officially by the distro. Also I guess you could add some more attributes to the rule in addition to the {name}. For a list of the available attributes you can run:
Quote:udevadm info --attribute-walk --path=/sys/bus/iio/devices/iio:device2

Obviously by replacing 2 with whatever the device number happens to be.

Finally I would like to mention that there is a library "libiio", which I guess could be a convenient alternative to directly reading the files in the /sys directory. I do not have experience with this library myself, but thought I should let you know in case you did not know about it. Python bindings are available here: https://pypi.org/project/pylibiio/
  Reply


Messages In This Thread
Compass App - by lgtrombetta - 06-23-2021, 10:54 AM
RE: Compass App - by awaittrot - 06-23-2021, 09:08 PM
RE: Compass App - by threepwood - 06-24-2021, 02:27 AM
RE: Compass App - by lgtrombetta - 06-24-2021, 09:16 AM
RE: Compass App - by lgtrombetta - 06-24-2021, 02:58 PM
RE: Compass App - by threepwood - 06-25-2021, 06:35 AM
RE: Compass App - by biketool - 06-25-2021, 07:08 AM
RE: Compass App - by lgtrombetta - 06-25-2021, 01:20 PM
RE: Compass App - by lgtrombetta - 06-26-2021, 07:28 AM
RE: Compass App - by lgtrombetta - 07-10-2021, 07:55 AM
RE: Compass App - by biketool - 07-28-2021, 01:07 AM
RE: Compass App - by lgtrombetta - 07-30-2021, 04:17 AM
RE: Compass App - by biketool - 07-30-2021, 08:14 AM
RE: Compass App - by newton688 - 09-09-2021, 08:42 PM
RE: Compass App - by lgtrombetta - 09-13-2021, 11:57 AM
RE: Compass App - by newton688 - 09-16-2021, 08:19 PM
RE: Compass App - by newton688 - 09-25-2021, 02:31 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)