2022-11-12 20:13:09 +00:00
|
|
|
#include "lightmeter_helper.h"
|
|
|
|
#include "lightmeter_config.h"
|
|
|
|
|
2023-02-26 02:46:50 +00:00
|
|
|
extern const float aperture_numbers[];
|
|
|
|
extern const float speed_numbers[];
|
2022-11-12 20:13:09 +00:00
|
|
|
|
|
|
|
float lux2ev(float lux) {
|
|
|
|
return log2(lux / 2.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
float getMinDistance(float x, float v1, float v2) {
|
|
|
|
if(x - v1 > v2 - x) {
|
|
|
|
return v2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return v1;
|
|
|
|
}
|
|
|
|
|
|
|
|
float normalizeAperture(float a) {
|
|
|
|
for(int i = 0; i < AP_NUM; i++) {
|
|
|
|
float a1 = aperture_numbers[i];
|
|
|
|
float a2 = aperture_numbers[i + 1];
|
|
|
|
|
|
|
|
if(a1 < a && a2 >= a) {
|
|
|
|
return getMinDistance(a, a1, a2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
float normalizeTime(float a) {
|
|
|
|
for(int i = 0; i < SPEED_NUM; i++) {
|
2023-02-26 02:46:50 +00:00
|
|
|
float a1 = speed_numbers[i];
|
|
|
|
float a2 = speed_numbers[i + 1];
|
2022-11-12 20:13:09 +00:00
|
|
|
|
|
|
|
if(a1 < a && a2 >= a) {
|
|
|
|
return getMinDistance(a, a1, a2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|