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

Logarithmic ALS Scaling #71

Merged
merged 4 commits into from
Apr 3, 2021
Merged

Logarithmic ALS Scaling #71

merged 4 commits into from
Apr 3, 2021

Conversation

abredall
Copy link
Contributor

This is what I had in mind for logarithmic scaling; I changed the default MIN and MAX values based on this general guideline for interpreting lux.

Ensuring min and max >= 1 prevents negative log values.

I am unsure if this breaks any previous compatibilities or expected behaviors, so feel free to change it how you see fit. I also don't code in C so apologies if something is blatantly wrong.

Copy link
Owner

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

Hi! Thank you very much for the PR, much appreciated!
I just left a couple of questions; the PR looks fine anyway, it just needs some minor changes (i guess!).
Btw again thank you for your time!

@FedeDP
Copy link
Owner

FedeDP commented Mar 31, 2021

Note, moreover, that i am really curious about different meanings for
static const char *ill_names[] = { "in_illuminance_input", "in_illuminance_raw", "in_intensity_clear_raw" };
Ie: Clightd supports reading ALS sensor data from any of these sysfs attributes; fact is, i don't really know what they really mean.
Maybe some of them are already pre-processed (ie: not logarithmic).
I will look for more informations :)

@FedeDP
Copy link
Owner

FedeDP commented Mar 31, 2021

What:		/sys/.../iio:deviceX/in_illuminance_input
What:		/sys/.../iio:deviceX/in_illuminance_raw
What:		/sys/.../iio:deviceX/in_illuminanceY_input
What:		/sys/.../iio:deviceX/in_illuminanceY_raw
What:		/sys/.../iio:deviceX/in_illuminanceY_mean_raw
What:		/sys/.../iio:deviceX/in_illuminance_ir_raw
What:		/sys/.../iio:deviceX/in_illuminance_clear_raw
KernelVersion:	3.4
Contact:	linux-iio@vger.kernel.org
Description:
		Illuminance measurement, units after application of scale
		and offset are lux.

What:		/sys/.../iio:deviceX/in_intensityY_raw
What:		/sys/.../iio:deviceX/in_intensityY_ir_raw
What:		/sys/.../iio:deviceX/in_intensityY_both_raw
What:		/sys/.../iio:deviceX/in_intensityY_uv_raw
What:		/sys/.../iio:deviceX/in_intensityY_duv_raw
KernelVersion:	3.4
Contact:	linux-iio@vger.kernel.org
Description:
		Unit-less light intensity. Modifiers both and ir indicate
		that measurements contain visible and infrared light
		components or just infrared light, respectively. Modifier
		uv indicates that measurements contain ultraviolet light
		components. Modifier duv indicates that measurements
		contain deep ultraviolet light components.

https://mjmwired.net/kernel/Documentation/ABI/testing/sysfs-bus-iio

@abredall
Copy link
Contributor Author

Note, moreover, that i am really curious about different meanings for
static const char *ill_names[] = { "in_illuminance_input", "in_illuminance_raw", "in_intensity_clear_raw" };
Ie: Clightd supports reading ALS sensor data from any of these sysfs attributes; fact is, i don't really know what they really mean.
Maybe some of them are already pre-processed (ie: not logarithmic).
I will look for more informations :)

I was also confused by this. Perhaps then there should be a check to see if, after applying the scale, we have illuminance in lux or not.

@FedeDP
Copy link
Owner

FedeDP commented Apr 1, 2021

I was also confused by this. Perhaps then there should be a check to see if, after applying the scale, we have illuminance in lux or not.

I don't really know how can that be achieved, any idea?

@abredall
Copy link
Contributor Author

abredall commented Apr 2, 2021

I've taken all the suggestions and put them in; again, I don't normally code in C, so you might want to double check that I edited the parse_settings function correctly.

My only concern with this is that it would throw an error at anyone who currently defines min and max. Perhaps it would be better to add a deprecation warning for now.

I don't really know how can that be achieved, any idea?

Probably a check for if in_illuminance_scale exists for the device. However, I don't know how best to handle things if it can only output in the unitless intensity scale.

@FedeDP
Copy link
Owner

FedeDP commented Apr 3, 2021

I've taken all the suggestions and put them in; again, I don't normally code in C, so you might want to double check that I edited the parse_settings function correctly.

Everything's fine thanks!

My only concern with this is that it would throw an error at anyone who currently defines min and max. Perhaps it would be better to add a deprecation warning for now.

I don't think lots of users are overriding it :) it is safe to drop i guess. Moreover, this is done for quite a good reason (better ambient brightness curve) so i am all for it!

Probably a check for if in_illuminance_scale exists for the device. However, I don't know how best to handle things if it can only output in the unitless intensity scale.

Yup that is my greatest concern right now; i will dig into it before next release :)

Anyway, really thank you for taking the time to help me! I really appreciated that!
Good Easter!

@FedeDP FedeDP merged commit 13a964b into FedeDP:master Apr 3, 2021
@abredall abredall deleted the log_als branch April 5, 2021 13:26
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