commit 4832f6a365dd54af6497f35e2cd8c376b186135b Author: Fisch Date: Thu Mar 22 08:57:53 2018 +0100 Initial commit diff --git a/UI_Design.xcf b/UI_Design.xcf new file mode 100644 index 0000000..05c72ec Binary files /dev/null and b/UI_Design.xcf differ diff --git a/calibration.txt b/calibration.txt new file mode 100644 index 0000000..a94d96d --- /dev/null +++ b/calibration.txt @@ -0,0 +1,17 @@ +Am Dell U2715H Brightness 50/ Contrast 50 +abstand zu kamera 1m + +EOS 600D +ISO 800 F5.6. Kit @55mm +gray eos ldr /brightmode ldr +0% 1.3s 580/70 +10% 0.3s 720/85 +20% 1/10 1075/140 +30% 1/25 1555/230 +40% 1/50 2020/350 +50% 1/80 2410/495 +60% 1/125 2735/653 +70% 1/200 2950/800 +80% 1/250 3140/965 +90% 1/400 3295/1130 +100% 1/500 3400/1280 \ No newline at end of file diff --git a/calibration/20180123_prototype_calibration (Kopie 1).csv b/calibration/20180123_prototype_calibration (Kopie 1).csv new file mode 100644 index 0000000..42c3845 --- /dev/null +++ b/calibration/20180123_prototype_calibration (Kopie 1).csv @@ -0,0 +1,248 @@ +low,bright,Aperature(at iso 100),shutter time,EV,EV Norm +793,101,5.6,0.25,6.9708536543,7 +794,100,5.6,0.25,6.9708536543,7 +797,99,5.6,0.25,6.9708536543,7 +790,97,5.6,0.25,6.9708536543,7 +799,98,5.6,0.25,6.9708536543,7 +794,99,5.6,0.25,6.9708536543,7 +793,99,5.6,0.25,6.9708536543,7 +797,97,5.6,0.25,6.9708536543,7 +791,98,5.6,0.25,6.9708536543,7 +797,99,5.6,0.25,6.9708536543,7 +796,97,5.6,0.25,6.9708536543,7 +793,99,5.6,0.25,6.9708536543,7 +800,100,5.6,0.25,6.9708536543,7 +793,101,5.6,0.25,6.9708536543,7 +,,,,, +791,98,5.6,0.25,6.9708536543,7 +791,97,5.6,0.25,6.9708536543,7 +793,98,5.6,0.25,6.9708536543,7 +792,99,5.6,0.25,6.9708536543,7 +792,98,5.6,0.25,6.9708536543,7 +794,99,5.6,0.25,6.9708536543,7 +794,101,5.6,0.25,6.9708536543,7 +793,99,5.6,0.25,6.9708536543,7 +792,99,5.6,0.25,6.9708536543,7 +791,97,5.6,0.25,6.9708536543,7 +794,99,5.6,0.25,6.9708536543,7 +792,98,5.6,0.25,6.9708536543,7 +,,,,, +525,63,5.6,8,1.9708536543,2 +527,63,5.6,8,1.9708536543,2 +525,61,5.6,8,1.9708536543,2 +524,62,5.6,8,1.9708536543,2 +526,62,5.6,8,1.9708536543,2 +527,61,5.6,8,1.9708536543,2 +523,64,5.6,8,1.9708536543,2 +524,60,5.6,8,1.9708536543,2 +525,62,5.6,8,1.9708536543,2 +811,102,5.6,0.2,7.2927817492,7.3 +812,100,5.6,0.2,7.2927817492,7.3 +811,100,5.6,0.2,7.2927817492,7.3 +812,100,5.6,0.2,7.2927817492,7.3 +812,99,5.6,0.2,7.2927817492,7.3 +811,101,5.6,0.2,7.2927817492,7.3 +812,103,5.6,0.2,7.2927817492,7.3 +810,100,5.6,0.2,7.2927817492,7.3 +811,100,5.6,0.2,7.2927817492,7.3 +2194,413,5.6,0.02,10.6147098441,10.6 +2193,413,5.6,0.02,10.6147098441,10.6 +2195,413,5.6,0.02,10.6147098441,10.6 +2190,410,5.6,0.02,10.6147098441,10.6 +2195,411,5.6,0.02,10.6147098441,10.6 +2193,409,5.6,0.02,10.6147098441,10.6 +2193,413,5.6,0.02,10.6147098441,10.6 +2199,414,5.6,0.02,10.6147098441,10.6 +2201,412,5.6,0.02,10.6147098441,10.6 +2205,413,5.6,0.02,10.6147098441,10.6 +2202,412,5.6,0.02,10.6147098441,10.6 +2203,412,5.6,0.02,10.6147098441,10.6 +2194,413,5.6,0.008,11.936637939,11.9 +2193,413,5.6,0.008,11.936637939,11.9 +2195,413,5.6,0.008,11.936637939,11.9 +2190,410,5.6,0.008,11.936637939,11.9 +2195,411,5.6,0.008,11.936637939,11.9 +2193,409,5.6,0.008,11.936637939,11.9 +2193,413,5.6,0.008,11.936637939,11.9 +2199,414,5.6,0.008,11.936637939,11.9 +2201,412,5.6,0.008,11.936637939,11.9 +2205,413,5.6,0.008,11.936637939,11.9 +2202,412,5.6,0.008,11.936637939,11.9 +2203,412,5.6,0.008,11.936637939,11.9 +,,,,, +3445,1297,5.6,0.0025,13.6147098441,13.6 +3342,1216,5.6,0.0025,13.6147098441,13.6 +3444,1354,5.6,0.0025,13.6147098441,13.6 +3402,1176,5.6,0.0025,13.6147098441,13.6 +3396,1335,5.6,0.0025,13.6147098441,13.6 +3401,1163,5.6,0.0025,13.6147098441,13.6 +3341,1329,5.6,0.0025,13.6147098441,13.6 +3429,1223,5.6,0.0025,13.6147098441,13.6 +3313,1295,5.6,0.0025,13.6147098441,13.6 +3462,1306,5.6,0.0025,13.6147098441,13.6 +3326,1217,5.6,0.0025,13.6147098441,13.6 +3447,1334,5.6,0.0025,13.6147098441,13.6 +3367,1185,5.6,0.0025,13.6147098441,13.6 +3423,1383,5.6,0.0025,13.6147098441,13.6 +3093,853,5.6,0.005,12.6147098441,12.6 +3077,984,5.6,0.005,12.6147098441,12.6 +3145,911,5.6,0.005,12.6147098441,12.6 +3055,959,5.6,0.005,12.6147098441,12.6 +3189,969,5.6,0.005,12.6147098441,12.6 +3056,877,5.6,0.005,12.6147098441,12.6 +3139,981,5.6,0.005,12.6147098441,12.6 +3106,856,5.6,0.005,12.6147098441,12.6 +3062,969,5.6,0.005,12.6147098441,12.6 +3136,893,5.6,0.005,12.6147098441,12.6 +2996,896,5.6,0.005,12.6147098441,12.6 +3147,938,5.6,0.005,12.6147098441,12.6 +3038,856,5.6,0.005,12.6147098441,12.6 +3191,1109,5.6,0.0035087719,13.1256717634,13.1 +3326,1133,5.6,0.0035087719,13.1256717634,13.1 +3216,1033,5.6,0.0035087719,13.1256717634,13.1 +3300,1169,5.6,0.0035087719,13.1256717634,13.1 +3280,1019,5.6,0.0035087719,13.1256717634,13.1 +3227,1156,5.6,0.0035087719,13.1256717634,13.1 +3310,1082,5.6,0.0035087719,13.1256717634,13.1 +3182,1082,5.6,0.0035087719,13.1256717634,13.1 +3319,1133,5.6,0.0035087719,13.1256717634,13.1 +3215,1019,5.6,0.0035087719,13.1256717634,13.1 +3283,1162,5.6,0.0035087719,13.1256717634,13.1 +3274,1013,5.6,0.0035087719,13.1256717634,13.1 +3215,1142,5.6,0.0035087719,13.1256717634,13.1 +3309,1079,5.6,0.0035087719,13.1256717634,13.1 +3705,1788,5.6,0.00125,14.6147098441,14.6 +3652,1916,5.6,0.00125,14.6147098441,14.6 +3737,1941,5.6,0.00125,14.6147098441,14.6 +3653,1797,5.6,0.00125,14.6147098441,14.6 +3722,2028,5.6,0.00125,14.6147098441,14.6 +3714,1761,5.6,0.00125,14.6147098441,14.6 +3689,2021,5.6,0.00125,14.6147098441,14.6 +3737,1903,5.6,0.00125,14.6147098441,14.6 +3645,1874,5.6,0.00125,14.6147098441,14.6 +3745,1982,5.6,0.00125,14.6147098441,14.6 +3685,1770,5.6,0.00125,14.6147098441,14.6 +3721,2021,5.6,0.00125,14.6147098441,14.6 +3715,1783,5.6,0.00125,14.6147098441,14.6 +3837,2612,16,0.0025,16.6438561898,16.6 +3889,2503,16,0.0025,16.6438561898,16.6 +3804,2367,16,0.0025,16.6438561898,16.6 +3887,2609,16,0.0025,16.6438561898,16.6 +3865,2239,16,0.0025,16.6438561898,16.6 +3836,2611,16,0.0025,16.6438561898,16.6 +3888,2500,16,0.0025,16.6438561898,16.6 +3808,2353,16,0.0025,16.6438561898,16.6 +3886,2619,16,0.0025,16.6438561898,16.6 +3868,2246,16,0.0025,16.6438561898,16.6 +3834,2601,16,0.0025,16.6438561898,16.6 +3891,2507,16,0.0025,16.6438561898,16.6 +3806,2354,16,0.0025,16.6438561898,16.6 +3887,2617,16,0.0025,16.6438561898,16.6 +3866,2244,16,0.0025,16.6438561898,16.6 +3834,2596,16,0.0025,16.6438561898,16.6 +3889,2518,16,0.0025,16.6438561898,16.6 +3810,2357,16,0.0025,16.6438561898,16.6 +3885,2623,16,0.0025,16.6438561898,16.6 +3869,2276,16,0.0025,16.6438561898,16.6 +3829,2586,16,0.0025,16.6438561898,16.6 +3893,2524,16,0.0025,16.6438561898,16.6 +3815,2346,16,0.0025,16.6438561898,16.6 +3881,2623,16,0.0025,16.6438561898,16.6 +3873,2301,16,0.0025,16.6438561898,16.6 +3828,2551,16,0.0025,16.6438561898,16.6 +3892,2538,16,0.0025,16.6438561898,16.6 +3825,2320,16,0.0025,16.6438561898,16.6 +3873,2631,16,0.0025,16.6438561898,16.6 +3873,2337,16,0.0025,16.6438561898,16.6 +3824,2527,16,0.0025,16.6438561898,16.6 +3937,2935,22,0.0015625,18.2407913322,18.2 +3983,3207,22,0.0015625,18.2407913322,18.2 +3980,2920,22,0.0015625,18.2407913322,18.2 +3943,3114,22,0.0015625,18.2407913322,18.2 +3992,3136,22,0.0015625,18.2407913322,18.2 +3950,2891,22,0.0015625,18.2407913322,18.2 +3976,3212,22,0.0015625,18.2407913322,18.2 +3981,2947,22,0.0015625,18.2407913322,18.2 +3941,3099,22,0.0015625,18.2407913322,18.2 +3990,3155,22,0.0015625,18.2407913322,18.2 +3954,2877,22,0.0015625,18.2407913322,18.2 +3972,3215,22,0.0015625,18.2407913322,18.2 +3983,2961,22,0.0015625,18.2407913322,18.2 +3940,3076,22,0.0015625,18.2407913322,18.2 +3990,3154,22,0.0015625,18.2407913322,18.2 +3954,2871,22,0.0015625,18.2407913322,18.2 +3973,3215,22,0.0015625,18.2407913322,18.2 +3981,2965,22,0.0015625,18.2407913322,18.2 +3937,3061,22,0.0015625,18.2407913322,18.2 +3990,3159,22,0.0015625,18.2407913322,18.2 +,,,,, +3659,1757,22,0.02,14.562719427,14.6 +3579,1649,22,0.02,14.562719427,14.6 +3660,1829,22,0.02,14.562719427,14.6 +3635,1553,22,0.02,14.562719427,14.6 +3573,1757,22,0.02,14.562719427,14.6 +3666,1741,22,0.02,14.562719427,14.6 +3573,1595,22,0.02,14.562719427,14.6 +3633,1795,22,0.02,14.562719427,14.6 +3641,1566,22,0.02,14.562719427,14.6 +3546,1617,22,0.02,14.562719427,14.6 +3652,1677,22,0.02,14.562719427,14.6 +3559,1487,22,0.02,14.562719427,14.6 +3589,1789,22,0.02,14.562719427,14.6 +3629,1594,22,0.02,14.562719427,14.6 +270,34,8,15,2.0931094044,2.1 +270,33,8,15,2.0931094044,2.1 +274,25,8,15,2.0931094044,2.1 +275,31,8,15,2.0931094044,2.1 +274,32,8,15,2.0931094044,2.1 +274,35,8,15,2.0931094044,2.1 +271,34,8,15,2.0931094044,2.1 +273,33,8,15,2.0931094044,2.1 +271,33,8,15,2.0931094044,2.1 +274,34,8,15,2.0931094044,2.1 +271,32,8,15,2.0931094044,2.1 +273,33,8,15,2.0931094044,2.1 +273,31,8,15,2.0931094044,2.1 +274,32,8,15,2.0931094044,2.1 +272,32,8,15,2.0931094044,2.1 +,,,,, +314,37,8,5,3.6780719051,3.7 +315,36,8,5,3.6780719051,3.7 +317,37,8,5,3.6780719051,3.7 +319,37,8,5,3.6780719051,3.7 +316,37,8,5,3.6780719051,3.7 +317,36,8,5,3.6780719051,3.7 +317,37,8,5,3.6780719051,3.7 +319,37,8,5,3.6780719051,3.7 +318,38,8,5,3.6780719051,3.7 +320,37,8,5,3.6780719051,3.7 +320,38,8,5,3.6780719051,3.7 +317,38,8,5,3.6780719051,3.7 +,,,,, +302,35,5.6,2.85,3.4598917351,3.5 +301,36,5.6,2.85,3.4598917351,3.5 +300,34,5.6,2.85,3.4598917351,3.5 +298,36,5.6,2.85,3.4598917351,3.5 +295,37,5.6,2.85,3.4598917351,3.5 +294,36,5.6,2.85,3.4598917351,3.5 +296,36,5.6,2.85,3.4598917351,3.5 +295,36,5.6,2.85,3.4598917351,3.5 +291,38,5.6,2.85,3.4598917351,3.5 +293,35,5.6,2.85,3.4598917351,3.5 +292,36,5.6,2.85,3.4598917351,3.5 +292,34,5.6,2.85,3.4598917351,3.5 +,,,,, +398,47,5.6,1,4.9708536543,5 +401,49,5.6,1,4.9708536543,5 +399,46,5.6,1,4.9708536543,5 +401,47,5.6,1,4.9708536543,5 +400,45,5.6,1,4.9708536543,5 +399,46,5.6,1,4.9708536543,5 +401,47,5.6,1,4.9708536543,5 +399,47,5.6,1,4.9708536543,5 +401,47,5.6,1,4.9708536543,5 +400,46,5.6,1,4.9708536543,5 +400,46,5.6,1,4.9708536543,5 +400,46,5.6,1,4.9708536543,5 +401,47,5.6,1,4.9708536543,5 +400,46,5.6,1,4.9708536543,5 diff --git a/calibration/20180123_prototype_calibration.csv b/calibration/20180123_prototype_calibration.csv new file mode 100644 index 0000000..42c3845 --- /dev/null +++ b/calibration/20180123_prototype_calibration.csv @@ -0,0 +1,248 @@ +low,bright,Aperature(at iso 100),shutter time,EV,EV Norm +793,101,5.6,0.25,6.9708536543,7 +794,100,5.6,0.25,6.9708536543,7 +797,99,5.6,0.25,6.9708536543,7 +790,97,5.6,0.25,6.9708536543,7 +799,98,5.6,0.25,6.9708536543,7 +794,99,5.6,0.25,6.9708536543,7 +793,99,5.6,0.25,6.9708536543,7 +797,97,5.6,0.25,6.9708536543,7 +791,98,5.6,0.25,6.9708536543,7 +797,99,5.6,0.25,6.9708536543,7 +796,97,5.6,0.25,6.9708536543,7 +793,99,5.6,0.25,6.9708536543,7 +800,100,5.6,0.25,6.9708536543,7 +793,101,5.6,0.25,6.9708536543,7 +,,,,, +791,98,5.6,0.25,6.9708536543,7 +791,97,5.6,0.25,6.9708536543,7 +793,98,5.6,0.25,6.9708536543,7 +792,99,5.6,0.25,6.9708536543,7 +792,98,5.6,0.25,6.9708536543,7 +794,99,5.6,0.25,6.9708536543,7 +794,101,5.6,0.25,6.9708536543,7 +793,99,5.6,0.25,6.9708536543,7 +792,99,5.6,0.25,6.9708536543,7 +791,97,5.6,0.25,6.9708536543,7 +794,99,5.6,0.25,6.9708536543,7 +792,98,5.6,0.25,6.9708536543,7 +,,,,, +525,63,5.6,8,1.9708536543,2 +527,63,5.6,8,1.9708536543,2 +525,61,5.6,8,1.9708536543,2 +524,62,5.6,8,1.9708536543,2 +526,62,5.6,8,1.9708536543,2 +527,61,5.6,8,1.9708536543,2 +523,64,5.6,8,1.9708536543,2 +524,60,5.6,8,1.9708536543,2 +525,62,5.6,8,1.9708536543,2 +811,102,5.6,0.2,7.2927817492,7.3 +812,100,5.6,0.2,7.2927817492,7.3 +811,100,5.6,0.2,7.2927817492,7.3 +812,100,5.6,0.2,7.2927817492,7.3 +812,99,5.6,0.2,7.2927817492,7.3 +811,101,5.6,0.2,7.2927817492,7.3 +812,103,5.6,0.2,7.2927817492,7.3 +810,100,5.6,0.2,7.2927817492,7.3 +811,100,5.6,0.2,7.2927817492,7.3 +2194,413,5.6,0.02,10.6147098441,10.6 +2193,413,5.6,0.02,10.6147098441,10.6 +2195,413,5.6,0.02,10.6147098441,10.6 +2190,410,5.6,0.02,10.6147098441,10.6 +2195,411,5.6,0.02,10.6147098441,10.6 +2193,409,5.6,0.02,10.6147098441,10.6 +2193,413,5.6,0.02,10.6147098441,10.6 +2199,414,5.6,0.02,10.6147098441,10.6 +2201,412,5.6,0.02,10.6147098441,10.6 +2205,413,5.6,0.02,10.6147098441,10.6 +2202,412,5.6,0.02,10.6147098441,10.6 +2203,412,5.6,0.02,10.6147098441,10.6 +2194,413,5.6,0.008,11.936637939,11.9 +2193,413,5.6,0.008,11.936637939,11.9 +2195,413,5.6,0.008,11.936637939,11.9 +2190,410,5.6,0.008,11.936637939,11.9 +2195,411,5.6,0.008,11.936637939,11.9 +2193,409,5.6,0.008,11.936637939,11.9 +2193,413,5.6,0.008,11.936637939,11.9 +2199,414,5.6,0.008,11.936637939,11.9 +2201,412,5.6,0.008,11.936637939,11.9 +2205,413,5.6,0.008,11.936637939,11.9 +2202,412,5.6,0.008,11.936637939,11.9 +2203,412,5.6,0.008,11.936637939,11.9 +,,,,, +3445,1297,5.6,0.0025,13.6147098441,13.6 +3342,1216,5.6,0.0025,13.6147098441,13.6 +3444,1354,5.6,0.0025,13.6147098441,13.6 +3402,1176,5.6,0.0025,13.6147098441,13.6 +3396,1335,5.6,0.0025,13.6147098441,13.6 +3401,1163,5.6,0.0025,13.6147098441,13.6 +3341,1329,5.6,0.0025,13.6147098441,13.6 +3429,1223,5.6,0.0025,13.6147098441,13.6 +3313,1295,5.6,0.0025,13.6147098441,13.6 +3462,1306,5.6,0.0025,13.6147098441,13.6 +3326,1217,5.6,0.0025,13.6147098441,13.6 +3447,1334,5.6,0.0025,13.6147098441,13.6 +3367,1185,5.6,0.0025,13.6147098441,13.6 +3423,1383,5.6,0.0025,13.6147098441,13.6 +3093,853,5.6,0.005,12.6147098441,12.6 +3077,984,5.6,0.005,12.6147098441,12.6 +3145,911,5.6,0.005,12.6147098441,12.6 +3055,959,5.6,0.005,12.6147098441,12.6 +3189,969,5.6,0.005,12.6147098441,12.6 +3056,877,5.6,0.005,12.6147098441,12.6 +3139,981,5.6,0.005,12.6147098441,12.6 +3106,856,5.6,0.005,12.6147098441,12.6 +3062,969,5.6,0.005,12.6147098441,12.6 +3136,893,5.6,0.005,12.6147098441,12.6 +2996,896,5.6,0.005,12.6147098441,12.6 +3147,938,5.6,0.005,12.6147098441,12.6 +3038,856,5.6,0.005,12.6147098441,12.6 +3191,1109,5.6,0.0035087719,13.1256717634,13.1 +3326,1133,5.6,0.0035087719,13.1256717634,13.1 +3216,1033,5.6,0.0035087719,13.1256717634,13.1 +3300,1169,5.6,0.0035087719,13.1256717634,13.1 +3280,1019,5.6,0.0035087719,13.1256717634,13.1 +3227,1156,5.6,0.0035087719,13.1256717634,13.1 +3310,1082,5.6,0.0035087719,13.1256717634,13.1 +3182,1082,5.6,0.0035087719,13.1256717634,13.1 +3319,1133,5.6,0.0035087719,13.1256717634,13.1 +3215,1019,5.6,0.0035087719,13.1256717634,13.1 +3283,1162,5.6,0.0035087719,13.1256717634,13.1 +3274,1013,5.6,0.0035087719,13.1256717634,13.1 +3215,1142,5.6,0.0035087719,13.1256717634,13.1 +3309,1079,5.6,0.0035087719,13.1256717634,13.1 +3705,1788,5.6,0.00125,14.6147098441,14.6 +3652,1916,5.6,0.00125,14.6147098441,14.6 +3737,1941,5.6,0.00125,14.6147098441,14.6 +3653,1797,5.6,0.00125,14.6147098441,14.6 +3722,2028,5.6,0.00125,14.6147098441,14.6 +3714,1761,5.6,0.00125,14.6147098441,14.6 +3689,2021,5.6,0.00125,14.6147098441,14.6 +3737,1903,5.6,0.00125,14.6147098441,14.6 +3645,1874,5.6,0.00125,14.6147098441,14.6 +3745,1982,5.6,0.00125,14.6147098441,14.6 +3685,1770,5.6,0.00125,14.6147098441,14.6 +3721,2021,5.6,0.00125,14.6147098441,14.6 +3715,1783,5.6,0.00125,14.6147098441,14.6 +3837,2612,16,0.0025,16.6438561898,16.6 +3889,2503,16,0.0025,16.6438561898,16.6 +3804,2367,16,0.0025,16.6438561898,16.6 +3887,2609,16,0.0025,16.6438561898,16.6 +3865,2239,16,0.0025,16.6438561898,16.6 +3836,2611,16,0.0025,16.6438561898,16.6 +3888,2500,16,0.0025,16.6438561898,16.6 +3808,2353,16,0.0025,16.6438561898,16.6 +3886,2619,16,0.0025,16.6438561898,16.6 +3868,2246,16,0.0025,16.6438561898,16.6 +3834,2601,16,0.0025,16.6438561898,16.6 +3891,2507,16,0.0025,16.6438561898,16.6 +3806,2354,16,0.0025,16.6438561898,16.6 +3887,2617,16,0.0025,16.6438561898,16.6 +3866,2244,16,0.0025,16.6438561898,16.6 +3834,2596,16,0.0025,16.6438561898,16.6 +3889,2518,16,0.0025,16.6438561898,16.6 +3810,2357,16,0.0025,16.6438561898,16.6 +3885,2623,16,0.0025,16.6438561898,16.6 +3869,2276,16,0.0025,16.6438561898,16.6 +3829,2586,16,0.0025,16.6438561898,16.6 +3893,2524,16,0.0025,16.6438561898,16.6 +3815,2346,16,0.0025,16.6438561898,16.6 +3881,2623,16,0.0025,16.6438561898,16.6 +3873,2301,16,0.0025,16.6438561898,16.6 +3828,2551,16,0.0025,16.6438561898,16.6 +3892,2538,16,0.0025,16.6438561898,16.6 +3825,2320,16,0.0025,16.6438561898,16.6 +3873,2631,16,0.0025,16.6438561898,16.6 +3873,2337,16,0.0025,16.6438561898,16.6 +3824,2527,16,0.0025,16.6438561898,16.6 +3937,2935,22,0.0015625,18.2407913322,18.2 +3983,3207,22,0.0015625,18.2407913322,18.2 +3980,2920,22,0.0015625,18.2407913322,18.2 +3943,3114,22,0.0015625,18.2407913322,18.2 +3992,3136,22,0.0015625,18.2407913322,18.2 +3950,2891,22,0.0015625,18.2407913322,18.2 +3976,3212,22,0.0015625,18.2407913322,18.2 +3981,2947,22,0.0015625,18.2407913322,18.2 +3941,3099,22,0.0015625,18.2407913322,18.2 +3990,3155,22,0.0015625,18.2407913322,18.2 +3954,2877,22,0.0015625,18.2407913322,18.2 +3972,3215,22,0.0015625,18.2407913322,18.2 +3983,2961,22,0.0015625,18.2407913322,18.2 +3940,3076,22,0.0015625,18.2407913322,18.2 +3990,3154,22,0.0015625,18.2407913322,18.2 +3954,2871,22,0.0015625,18.2407913322,18.2 +3973,3215,22,0.0015625,18.2407913322,18.2 +3981,2965,22,0.0015625,18.2407913322,18.2 +3937,3061,22,0.0015625,18.2407913322,18.2 +3990,3159,22,0.0015625,18.2407913322,18.2 +,,,,, +3659,1757,22,0.02,14.562719427,14.6 +3579,1649,22,0.02,14.562719427,14.6 +3660,1829,22,0.02,14.562719427,14.6 +3635,1553,22,0.02,14.562719427,14.6 +3573,1757,22,0.02,14.562719427,14.6 +3666,1741,22,0.02,14.562719427,14.6 +3573,1595,22,0.02,14.562719427,14.6 +3633,1795,22,0.02,14.562719427,14.6 +3641,1566,22,0.02,14.562719427,14.6 +3546,1617,22,0.02,14.562719427,14.6 +3652,1677,22,0.02,14.562719427,14.6 +3559,1487,22,0.02,14.562719427,14.6 +3589,1789,22,0.02,14.562719427,14.6 +3629,1594,22,0.02,14.562719427,14.6 +270,34,8,15,2.0931094044,2.1 +270,33,8,15,2.0931094044,2.1 +274,25,8,15,2.0931094044,2.1 +275,31,8,15,2.0931094044,2.1 +274,32,8,15,2.0931094044,2.1 +274,35,8,15,2.0931094044,2.1 +271,34,8,15,2.0931094044,2.1 +273,33,8,15,2.0931094044,2.1 +271,33,8,15,2.0931094044,2.1 +274,34,8,15,2.0931094044,2.1 +271,32,8,15,2.0931094044,2.1 +273,33,8,15,2.0931094044,2.1 +273,31,8,15,2.0931094044,2.1 +274,32,8,15,2.0931094044,2.1 +272,32,8,15,2.0931094044,2.1 +,,,,, +314,37,8,5,3.6780719051,3.7 +315,36,8,5,3.6780719051,3.7 +317,37,8,5,3.6780719051,3.7 +319,37,8,5,3.6780719051,3.7 +316,37,8,5,3.6780719051,3.7 +317,36,8,5,3.6780719051,3.7 +317,37,8,5,3.6780719051,3.7 +319,37,8,5,3.6780719051,3.7 +318,38,8,5,3.6780719051,3.7 +320,37,8,5,3.6780719051,3.7 +320,38,8,5,3.6780719051,3.7 +317,38,8,5,3.6780719051,3.7 +,,,,, +302,35,5.6,2.85,3.4598917351,3.5 +301,36,5.6,2.85,3.4598917351,3.5 +300,34,5.6,2.85,3.4598917351,3.5 +298,36,5.6,2.85,3.4598917351,3.5 +295,37,5.6,2.85,3.4598917351,3.5 +294,36,5.6,2.85,3.4598917351,3.5 +296,36,5.6,2.85,3.4598917351,3.5 +295,36,5.6,2.85,3.4598917351,3.5 +291,38,5.6,2.85,3.4598917351,3.5 +293,35,5.6,2.85,3.4598917351,3.5 +292,36,5.6,2.85,3.4598917351,3.5 +292,34,5.6,2.85,3.4598917351,3.5 +,,,,, +398,47,5.6,1,4.9708536543,5 +401,49,5.6,1,4.9708536543,5 +399,46,5.6,1,4.9708536543,5 +401,47,5.6,1,4.9708536543,5 +400,45,5.6,1,4.9708536543,5 +399,46,5.6,1,4.9708536543,5 +401,47,5.6,1,4.9708536543,5 +399,47,5.6,1,4.9708536543,5 +401,47,5.6,1,4.9708536543,5 +400,46,5.6,1,4.9708536543,5 +400,46,5.6,1,4.9708536543,5 +400,46,5.6,1,4.9708536543,5 +401,47,5.6,1,4.9708536543,5 +400,46,5.6,1,4.9708536543,5 diff --git a/calibration/20180123_prototype_calibration_bright_3_ab12.5.png b/calibration/20180123_prototype_calibration_bright_3_ab12.5.png new file mode 100644 index 0000000..5210ff1 Binary files /dev/null and b/calibration/20180123_prototype_calibration_bright_3_ab12.5.png differ diff --git a/calibration/20180123_prototype_calibration_low_3.png b/calibration/20180123_prototype_calibration_low_3.png new file mode 100644 index 0000000..c3a8574 Binary files /dev/null and b/calibration/20180123_prototype_calibration_low_3.png differ diff --git a/calibration/20180123_prototype_valuesTest.csv b/calibration/20180123_prototype_valuesTest.csv new file mode 100644 index 0000000..378e005 --- /dev/null +++ b/calibration/20180123_prototype_valuesTest.csv @@ -0,0 +1,154 @@ +low,bright +768,95 +761,96 +769,93 +759,93 +766,96 +766,93 +758,94 +769,97 +765,93 +765,95 +770,93 +759,94 +773,95 +762,93 +462,53 +457,54 +453,53 +453,52 +447,52 +444,53 +441,53 +441,51 +440,52 +439,50 +437,50 +434,52 +434,51 +431,51 +431,50 +431,49 +488,57 +490,54 +490,56 +489,57 +488,59 +488,59 +489,59 +487,58 +490,57 +491,58 + +434,52 +434,52 +433,49 +432,49 +431,50 +430,51 +431,52 +430,51 +431,51 +430,50 +429,50 +429,50 +427,49 +428,51 +428,49 +560,67 +561,67 +562,67 +565,66 +568,67 +569,70 +569,67 +569,70 +571,67 +571,67 +573,68 +574,69 +576,71 +573,68 +575,69 +1581,241 +1583,238 +1581,239 +1582,239 +1582,239 +1583,237 +1584,238 +1580,243 +1581,239 +1581,241 +1583,237 + +3292,1128 +3293,1133 +3294,1134 +3295,1133 +3295,1132 +3293,1137 +3294,1134 +3296,1133 +3297,1134 +3296,1133 +3297,1135 +3293,1135 +3298,1135 +3297,1137 + +3589,1619 +3589,1618 +3589,1620 +3589,1619 +3589,1618 +3589,1618 +3588,1619 +3588,1619 +3588,1619 +3589,1618 +3588,1619 +3634,1730 +3635,1728 +3634,1727 +3637,1731 +3635,1728 +3634,1726 +3637,1727 +3635,1726 +3636,1728 +3636,1726 +3635,1726 +3635,1727 +4087,4031 +4087,4031 +4087,4031 +4088,4033 +4087,4031 +4088,4031 +4087,4031 +4087,4029 +4087,4033 +4082,3992 +4085,3989 +4082,3991 +4082,3990 +4083,3977 +4081,3965 +4083,3988 +4081,3976 +4082,3996 +4084,3992 +4084,3991 +4049,3628 +4048,3653 +4049,3659 +4046,3609 +4038,3581 +4041,3592 +4043,3605 +4047,3616 +4040,3613 +4046,3662 +4048,3688 +4054,3668 \ No newline at end of file diff --git a/calibration/calibration.py b/calibration/calibration.py new file mode 100644 index 0000000..24816ee --- /dev/null +++ b/calibration/calibration.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +import numpy as np +import csv +import matplotlib.pyplot as plt + +xcolumn=1 #column with readings +ycolumn=4 #column with calibration data +ncoefs=3 #number of coefficients + +xvalues=[] +yvalues=[] + +with open('20180123_prototype_calibration.csv', 'r') as csvfile: + csvreader = csv.reader(csvfile, delimiter=',') + firstrow=True + for row in csvreader: + xvalue=row[xcolumn] + yvalue=row[ycolumn] + if len(xvalue)>0 and len(yvalue)>0 and not firstrow: + xvalue=float(xvalue) + yvalue=float(yvalue) + if yvalue>12.5: + #print(""+str(xvalue)+" - "+str(yvalue)) + xvalues.append(xvalue) + yvalues.append(yvalue) + firstrow=False + + coefs=np.polyfit(xvalues,yvalues,ncoefs) #fit polynomial curve + print(coefs) #coef 0 is the one with highest polynomial + + xtest=np.arange(max(xvalues)) #x values for test visualization + ytest=np.polyval(coefs, xtest) #calculate y values with polynomial function + #ytest=[coefs[3]+coefs[2]*pow(x,1)+coefs[1]*pow(x,2)+coefs[0]*pow(x,3) for x in xtest] + + plt.scatter(xvalues,yvalues,s=0.25,c='g') #plot sample data + plt.plot(xtest,ytest,c='r') #plot approximated curve + plt.xlabel('LDR Value') + plt.ylabel('Ev') + plt.show() diff --git a/lightmeter.ino b/lightmeter.ino new file mode 100644 index 0000000..7ce6ad4 --- /dev/null +++ b/lightmeter.ino @@ -0,0 +1,854 @@ +//STM32F103C, 64k flash +//upload method: serial (A9 to RX, A10 to TX) +//To upload set Boot0 jumper to 1 (the one further away from reset btn) and press reset (stm will boot from flash wich contains uart to flash uploader) +//upload via arduino IDE +//To boot program after restart set Boot0 jumper to 0 + +//Letters 5x7 at Size 1 + + +//#include +#include +#include +#include // http://www.instructables.com/id/Monochrome-096-i2c-OLED-display-with-arduino-SSD13/ +//128 x 64 px + +#include //from: https://github.com/mysensors/MySensorsArduinoExamples/tree/master/libraries/BH1750 +BH1750 lightMeter; + +#define PIN_LDR 0 //A0 +#define PIN_BRIGHTMODE 1 //A1 +#define PIN_VBAT 2 //A2 + +#define PIN_TRIGGER PB8 +#define PIN_BTNLEFT PA15 +#define PIN_BTNCENTER PB4 +#define PIN_BTNRIGHT PB5 + +#define PIN_ON PB9 +#define TIME_AUTOPOWEROFF 120000 +#define LDRDELAY 50 //minimum delay between ldr readings. Transistor for lower value pulldown resistor switches in between +#define DEBOUNCETIME 50 //time to not check for inputs after key press +#define BUTTONTIMEHOLD 1000 //time for button hold + +#define voltage_warn 3.4 //voltage per cell //TODO implement warning + +//float shuttertimes1[]={1,1.0/2, 1.0/4, 1.0/8, 1.0/15, 1.0/30, 1.0/60, 1.0/125, 1.0/250, 1.0/500, 1.0/1000, 1.0/2000, 1.0/4000, 1.0/8000}; +float shuttertimes1[]={64,32,16,8,4,2,1,1.0/2, 1.0/4, 1.0/8, 1.0/15, 1.0/30, 1.0/60, 1.0/125, 1.0/250, 1.0/500, 1.0/1000, 1.0/2000, 1.0/4000, 1.0/8000}; +String settingsnameShutterSelectionMode[]={"Analog"}; //names for tables +#define MAXIMUM_SHUTTERSELECTIONMODES 1 + +float aperaturesFull[]={1,1.4, 2, 2.8, 4, 5.6, 8, 11, 16, 22, 32}; +float aperaturesHalf[]={1, 1.2, 1.4, 1.7, 2, 2.4, 2.8, 3.4, 4, 4.8, 5.6, 6.7, 8, 9.5, 11, 13, 16, 19, 22}; +float aperaturesThird[]={1, 1.1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.5, 2.8, 3.2, 3.5, 4, 4.5, 5.0, 5.6, 6.3, 7.1, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 25, 29, 32, 36, 40, 45}; +String settingsnameAperatureSelectionMode[]={"Full","Half","Third"}; //names for tables +#define MAXIMUM_APERATURESELECTIONMODES 3 + +float isoFull[]={12,25,50,100,200,400,800,1600,3200,6400,12500,25600}; +float isoThird[]={12,16,20,25,32,40,50,64,80,100,125,160,200,250,320,400,500,640,800,1000,1250,1600,2000,2500,3200,4000,5000,6400,8000,10000,12500,16000,20000,25600}; + + + +long loopmillis=0; //only use one millis reading each loop +long last_ldrReading=0; +long millis_lastchange=0; +long millis_lastinput=0; + +long timebuttonpressed_trigger; +long timebuttonpressed_left; +long timebuttonpressed_center; +long timebuttonpressed_right; + +//Short press (true when button short pressed, on release) +boolean button_trigger=false; +boolean button_left=false; +boolean button_center=false; +boolean button_right=false; + +//long press (true when button is held down for BUTTONTIMEHOLD, on time elapsed) +boolean button_hold_trigger=false; +boolean button_hold_left=false; +boolean button_hold_center=false; +boolean button_hold_right=false; + +float vbat=0; + +struct Settings { + uint8_t minimumAperatureIndex; //see corresponding aperatures table + uint8_t aperatureSelectionMode; //1=Full, 2=Half, 3=Third + uint8_t shutterSelectionMode; //index for which shuttertimes table to use + uint8_t ISOSelectionMode; //1=Full, 2=Thirds +}; + +Settings userSettings= {1,1, 1,2}; + + + + +#define OLED_RESET 4 +Adafruit_SSD1306 display(OLED_RESET); + +uint16_t analog_low=0; //better for low light +uint16_t analog_high=0; //better for bright light (higher pulldown resistor for ldr) +float ev=0; //calculated EV from LDR readings (reflected) or from Luxmeter (incident) + +float ev_min=6,ev_max=12,ev_last=8; + +float showAperature=0; +float showShutter=0; + +//Usersettings +float setAperature=8; //set to use aperature. 0 for auto +float setShutter=0; //set to use shutter time, 0 for auto +uint16_t setISO=100; //set to ISO + +enum displaymode { + lightmeter, + settings +}; +displaymode displaymode=lightmeter; +uint8_t settings_selectedItem=0; //in settings display +String settingStrings[]={"ISO:","F-Stops:","Timetable:","Turn Off"}; +#define SETTINGS_SELECTEDITEM_MAX 3 //inclusive. 2 means 3 items available +boolean settings_itemActive=false; //item in settings selected to change value + + +char tempstring[16]; //for dtostrf //dtostrf(modefactor,1,3,tempstring); + +#if (SSD1306_LCDHEIGHT != 64) +#error("Height incorrect, please fix Adafruit_SSD1306.h!"); +#endif + +void setup() { + Serial.begin(9600); + Serial.println("Started"); + + + display.begin(SSD1306_SWITCHCAPVCC, 0x3C); + display.clearDisplay(); + display.display(); + + lightMeter.begin(BH1750_CONTINUOUS_HIGH_RES_MODE_2); + //set measurement time (for higher resolution) http://www.raspberry-pi-geek.de/Magazin/2015/04/Digital-Light-Sensor-BH1750-am-Raspberry-Pi + //lightMeter.write8(71); //01000111 //high bit: 01000xxx bits 7,6,5 + //lightMeter.write8(126); //01111110 //log bit: 011xxxxx bits 4,3,2,1,0 + + pinMode(PIN_LDR, INPUT_ANALOG); + pinMode(PIN_VBAT, INPUT_ANALOG); + pinMode(PIN_TRIGGER, INPUT_PULLUP); + pinMode(PIN_BTNLEFT, INPUT_PULLUP); + pinMode(PIN_BTNCENTER, INPUT_PULLUP); + pinMode(PIN_BTNRIGHT, INPUT_PULLUP); + pinMode(PIN_BRIGHTMODE, OUTPUT); + digitalWrite(PIN_BRIGHTMODE, LOW); + pinMode(PIN_ON, OUTPUT); + digitalWrite(PIN_ON, HIGH); + millis_lastchange=millis(); + + + Serial.println("Initialized"); + + + //display.drawPixel(10, 10, WHITE); + +} + + +void loop() { + loopmillis=millis(); //read millis for this cycle + + + + uint16_t lux = lightMeter.readLightLevel(); + + + handleInputs(); + + calculateEV(); + + updateDisplay(); + + + +} + + +void handleInputs() +{ + //Short press (true when button short pressed, on release) + button_trigger=false; + button_left=false; + button_center=false; + button_right=false; + + //long press (true when button is held down for BUTTONTIMEHOLD, on time elapsed) + button_hold_trigger=false; + button_hold_left=false; + button_hold_center=false; + button_hold_right=false; + + if (millis()-millis_lastinput>DEBOUNCETIME) //Button debouncing + { + //Trigger + if (timebuttonpressed_trigger == 0 && !digitalRead(PIN_TRIGGER)){ //first time pressed down. (low when pressed) + timebuttonpressed_trigger=loopmillis; //set time of button press + }else if(timebuttonpressed_trigger != 0 && digitalRead(PIN_TRIGGER)){ //button released (was pressed) + if (loopmillis-timebuttonpressed_trigger < BUTTONTIMEHOLD){ //short press + button_trigger=true; + } + timebuttonpressed_trigger=0; //re-enable after short press and release from hold + }else if(loopmillis-timebuttonpressed_trigger >= BUTTONTIMEHOLD && timebuttonpressed_trigger>0){ //held down long enough and not already hold triggered + button_hold_trigger=true; + timebuttonpressed_trigger=-1; //-1 as flag for hold triggered + } + + //Left + if (timebuttonpressed_left == 0 && !digitalRead(PIN_BTNLEFT)){ //first time pressed down. (low when pressed) + timebuttonpressed_left=loopmillis; //set time of button press + }else if(timebuttonpressed_left != 0 && digitalRead(PIN_BTNLEFT)){ //button released (was pressed) + if (loopmillis-timebuttonpressed_left < BUTTONTIMEHOLD){ //short press + button_left=true; + } + timebuttonpressed_left=0; //re-enable after short press and release from hold + }else if(loopmillis-timebuttonpressed_left >= BUTTONTIMEHOLD && timebuttonpressed_left>0){ //held down long enough and not already hold triggered + button_hold_left=true; + timebuttonpressed_left=-1; //-1 as flag for hold triggered + } + + //Center + if (timebuttonpressed_center == 0 && !digitalRead(PIN_BTNCENTER)){ //first time pressed down. (low when pressed) + timebuttonpressed_center=loopmillis; //set time of button press + }else if(timebuttonpressed_center != 0 && digitalRead(PIN_BTNCENTER)){ //button released (was pressed) + if (loopmillis-timebuttonpressed_center < BUTTONTIMEHOLD){ //short press + button_center=true; + } + timebuttonpressed_center=0; //re-enable after short press and release from hold + }else if(loopmillis-timebuttonpressed_center >= BUTTONTIMEHOLD && timebuttonpressed_center>0){ //held down long enough and not already hold triggered + button_hold_center=true; + timebuttonpressed_center=-1; //-1 as flag for hold triggered + } + + //Right + if (timebuttonpressed_right == 0 && !digitalRead(PIN_BTNRIGHT)){ //first time pressed down. (low when pressed) + timebuttonpressed_right=loopmillis; //set time of button press + }else if(timebuttonpressed_right != 0 && digitalRead(PIN_BTNRIGHT)){ //button released (was pressed) + if (loopmillis-timebuttonpressed_right < BUTTONTIMEHOLD){ //short press + button_right=true; + } + timebuttonpressed_right=0; //re-enable after short press and release from hold + }else if(loopmillis-timebuttonpressed_right >= BUTTONTIMEHOLD && timebuttonpressed_right>0){ //held down long enough and not already hold triggered + button_hold_right=true; + timebuttonpressed_right=-1; //-1 as flag for hold triggered + } + } + + /* + if (button_trigger || button_left || button_center || button_right){ + Serial.println("Buttons short:"); + Serial.print(button_trigger); + Serial.print(button_left); + Serial.print(button_center); + Serial.println(button_right); + } + if (button_hold_trigger || button_hold_left || button_hold_center || button_hold_right){ + Serial.println("Buttons long:"); + Serial.print(button_hold_trigger); + Serial.print(button_hold_left); + Serial.print(button_hold_center); + Serial.println(button_hold_right); + } + */ + + //Voltage + vbat=map(analogRead(PIN_VBAT), 0,3910,0,8400)/1000.0; //180k and 300k voltage divider. 8,4V -> 3,15V=3910 + + if ( loopmillis-last_ldrReading>LDRDELAY ) + { + if (!digitalRead(PIN_BRIGHTMODE)){ + analog_low=analogRead(PIN_LDR); + }else{ + analog_high=analogRead(PIN_LDR); + } + digitalWrite(PIN_BRIGHTMODE, !digitalRead(PIN_BRIGHTMODE)); //switch modes + last_ldrReading=loopmillis; + } + + + //Test asdf + /* + if ( !digitalRead(PIN_TRIGGER) ) { + Serial.println("roundAperature"); + for (float i=0.1;i<30;i+=0.5){ + Serial.print(i); + Serial.print(" -> "); + Serial.println(roundAperature(i,1)); + } + Serial.println("roundShutter"); + for (float i=1.0/8000;i<32;i*=2){ + Serial.print(i,6); + Serial.print(" -> "); + Serial.print(roundShutter(i,1),6); + Serial.print(" -- "); + Serial.println(reciprocFloat(roundShutter(i,1))); + } + + + Serial.println("calculateShutter at iso 100 f8"); + for (int8_t i=-2;i<18;i++){ + Serial.print(i); + Serial.print(" -> "); + Serial.println(calculateShutter(i, (uint16_t)100, 8.0),6); + } + + Serial.println("calculateAperature at iso 100 1/125s"); + for (int8_t i=-2;i<18;i++){ + Serial.print(i); + Serial.print(" -> "); + Serial.println(calculateAperature(i, (uint16_t)100, 1.0/125),6); + } + + } + */ + + + switch(displaymode){ + case lightmeter: + handleInputs_Lightmeter(); + break; + case settings: + handleInputs_Settings(); + break; + } + + + + if (millis()-millis_lastchange>TIME_AUTOPOWEROFF){ + digitalWrite(PIN_ON, LOW); + } + + if ( button_trigger || button_left || button_center || button_right ) { + millis_lastchange=millis(); //for auto poweroff + millis_lastinput=millis(); //for debouncing + } + +} + +void handleInputs_Lightmeter() +{ + if ( button_hold_center ) { //Go to Settings + displaymode=settings; + } + + if (setShutter==0 && setAperature==0){ //Auto + //Value Change + if ( button_left ) { + + } + if ( button_right ) { + + } + //Change Mode + if ( button_hold_left ){ //Auto -> T + setShutter=showShutter; + setAperature=0; + } + if ( button_hold_right ){ //Auto -> Av + setAperature=showAperature; + setShutter=0; + } + }else if(setShutter==0){ //Aperature Priority + //Value Change + if ( button_left ) { + changeAperature(1); //Decrement Aperature + } + if ( button_right ) { + changeAperature(-1); //Increment Aperature + } + //Change Mode + if ( button_hold_left ){ //change from Aperature Priority to Auto, Av -> Auto + setAperature=0; + setShutter=0; + } + if ( button_hold_right ){ //Av -> T + setShutter=showShutter; + setAperature=0; + } + }else if (setAperature==0){ //Shutter Priority + //Value Change + if ( button_left ) { + changeShutter(1); //Decrement Aperature + } + if ( button_right ) { + changeShutter(-1); //Increment Aperature + } + //Change Mode + if ( button_hold_left ){ //T -> Av + setAperature=showAperature; + setShutter=0; + } + if ( button_hold_right ){ //T -> Auto + setAperature=0; + setShutter=0; + } + } + + +} + + +void handleInputs_Settings() +{ + if ( button_hold_center ) { //Go to Lightmeter + displaymode=lightmeter; + } + + + + if (!settings_itemActive){ //select items + if ( button_left ) { + if (settings_selectedItem>0){ //not first item + settings_selectedItem-=1; + } + } + if ( button_right ) { + if (settings_selectedItem1){ + userSettings.aperatureSelectionMode-=1; + } + } + if ( button_right ) { + if (userSettings.aperatureSelectionMode1){ + userSettings.shutterSelectionMode-=1; + } + } + if ( button_right ) { + if (userSettings.shutterSelectionMode14){ + ev=highev; + }else if(lowev<12.5){ + ev=lowev; + }else{ //mix of both + float mix=min(1.0, max(0.0,(lowev-12.5)/(14-12.5))); //0 to 1, 0-> use only lowev, 1-> use only highev + ev=lowev*(1-mix)+highev*mix; + } + + if (setAperature>0){ //Aperature Priority + showAperature=setAperature; //use user set Aperature + showShutter=calculateShutter(ev,setISO, setAperature); + }else if(setShutter>0){ //Shutter Priority + showShutter=setShutter; //use user set Shutter + showAperature=calculateAperature(ev, setISO, setShutter); + }else{ //Auto + //TODO + showAperature=42; + showShutter=42; + } + +} + +float calculateShutter(float pEv, uint16_t pIso, uint16_t pAperature) //returns calculated Shutter speed given Ev, ISO and Aperature +{ + //EV = log2 ( 100* Aperature^2 / (ISO * Time )) + //100* Aperature^2 / (2^EV * ISO) = Time + return (100.0 * pow( pAperature,2) ) / (pow(2,pEv)*pIso); +} +float calculateAperature(float pEv, uint16_t pIso, float pShutter) //returns mathematical aperature in x1 +{ + //EV = log2 ( 100* Aperature^2 / (ISO * Time )) + // sqrt( 2^EV *(ISO * Time ) /100 ) = Aperature + return sqrt( pow(2,pEv) * pIso * pShutter / 100.0 ) ; +} +float roundShutter(float pShutter, uint8_t pMethod) //round shutter to typical values +{ + uint8_t _index=findShutterIndex(pShutter,pMethod); + + //use closest shutter value + switch(pMethod){ + case 1: // + return shuttertimes1[_index]; + break; + } +} + +float roundAperature(float pAperature, uint8_t pMethod) //round Aperature (x1) to typical values. method=0 -> leave, 1=full stops, 2=half stops, 3=third stops +{ + if (pMethod==0){ + return pAperature; + } + + uint8_t closest_index=findAperatureIndex(pAperature,pMethod); + + //use closest aperature value + switch(pMethod){ + case 1: //full stops + return aperaturesFull[closest_index]; + break; + case 2: //half stops + //return float ( pow(sqrt(sqrt(2)), _index-2) ); + return aperaturesHalf[closest_index]; + break; + case 3: //third stops + return aperaturesThird[closest_index]; + //return float ( pow(cbrt(sqrt(2)), _index-2) ); + break; + } +} + +void changeAperature(int8_t pchange){ //pchange>0 means more light exposure (brighter image) + uint8_t _newAperatureIndex=findAperatureIndex(setAperature,userSettings.aperatureSelectionMode); + + uint8_t _maximumAperatureIndex=0; + switch(userSettings.aperatureSelectionMode){ //check max + case 1: //full stops + _maximumAperatureIndex=sizeof(aperaturesFull)/sizeof(float); + break; + case 2: //half stops + _maximumAperatureIndex=sizeof(aperaturesHalf)/sizeof(float); + break; + case 3: //third stops + _maximumAperatureIndex=sizeof(aperaturesThird)/sizeof(float); + break; + } + _newAperatureIndex-=pchange; //change aperature + _newAperatureIndex=min(_newAperatureIndex,_maximumAperatureIndex-1); //maximum limit + _newAperatureIndex=max(_newAperatureIndex,userSettings.minimumAperatureIndex); //minimum limit + + switch(userSettings.aperatureSelectionMode){ + case 1: //full stops + setAperature=aperaturesFull[_newAperatureIndex]; + break; + case 2: //half stops + setAperature=aperaturesHalf[_newAperatureIndex]; + break; + case 3: //third stops + setAperature=aperaturesThird[_newAperatureIndex]; + break; + } +} +uint8_t findAperatureIndex(float pAperature,uint8_t pMethod) //find index of closest aperature from given aperature tables (pMethod +{ + float _minDistance=90000; + float _lastminDistance=100000; + uint8_t _index=userSettings.minimumAperatureIndex; + + while (_lastminDistance>_minDistance) //until distance increases + { + _lastminDistance=_minDistance; + + switch(pMethod){ + case 1: //full stops + _minDistance=abs( pAperature - aperaturesFull[_index] ); + break; + case 2: //half stops + _minDistance=abs( pAperature - aperaturesHalf[_index] ); + break; + case 3: //third stops + _minDistance=abs( pAperature - aperaturesThird[_index] ); + break; + } + _index++; //next + } + return _index-2; +} + + +void changeShutter(int8_t pchange){ //pchange>0 means more light exposure (brighter image) + + + uint8_t _newShutterIndex=findShutterIndex(setShutter,userSettings.shutterSelectionMode); + + uint8_t _maximumShutterIndex=0; + switch(userSettings.shutterSelectionMode){ //get max index from array + case 1: + _maximumShutterIndex=sizeof(shuttertimes1)/sizeof(float); + break; + } + + if (!( -pchange<0 && _newShutterIndex==0)){ //changed value would not yield negative index + _newShutterIndex-=pchange; //change aperature + _newShutterIndex=min(_newShutterIndex,_maximumShutterIndex-1); //maximum limit from array + //_newShutterIndex=min(_newShutterIndex,maximumShutterIndex); //maximum limit from user settings + } + + switch(userSettings.shutterSelectionMode){ + case 1: // + setShutter=shuttertimes1[_newShutterIndex]; + break; + } +} +uint8_t findShutterIndex(float pShutter,uint8_t pMethod) //find index of closest aperature from given aperature tables (pMethod +{ + float _minDistance=abs(pShutter-shuttertimes1[0]); + float _lastminDistance=_minDistance; + uint8_t _index=0; + + + while (_lastminDistance>=_minDistance) //until distance increases + { + _lastminDistance=_minDistance; + + switch(pMethod){ + case 1: + _minDistance=abs(pShutter - shuttertimes1[_index]); + break; + } + _index++; //next + } + return _index-2; +} + +void changeISO(int8_t pchange){ //pchange>0 means more light exposure (brighter image), higher iso + + + uint8_t _newISOIndex=findISOIndex(setISO,userSettings.ISOSelectionMode); + + uint8_t _maximumISOIndex=0; + switch(userSettings.ISOSelectionMode){ //get max index from array + case 1: + _maximumISOIndex=sizeof(isoFull)/sizeof(float); + break; + case 2: + _maximumISOIndex=sizeof(isoThird)/sizeof(float); + break; + } + if (!( pchange<0 && _newISOIndex==0)){ //changed value would not yield negative index + _newISOIndex+=pchange; //change iso + _newISOIndex=min(_newISOIndex,_maximumISOIndex-1); //maximum limit from array + //_newISOIndex=min(_newISOIndex,maximumISOIndex); //maximum limit from user settings + } + + switch(userSettings.ISOSelectionMode){ + case 1: // + setISO=isoFull[_newISOIndex]; + break; + case 2: // + setISO=isoThird[_newISOIndex]; + break; + } +} + +uint8_t findISOIndex(float pISO,uint8_t pMethod) //find index of closest iso from given iso table (pMethod) +{ + float _minDistance=abs(pISO-isoFull[0]); + float _lastminDistance=_minDistance; + uint8_t _index=0; + + + while (_lastminDistance>=_minDistance) //until distance increases + { + _lastminDistance=_minDistance; + + switch(pMethod){ + case 1: + _minDistance=abs(pISO - isoFull[_index]); + break; + case 2: + _minDistance=abs(pISO - isoThird[_index]); + break; + } + _index++; //next + } + return _index-2; +} + +void updateDisplay() +{ + switch(displaymode){ + case lightmeter: + updateDisplay_Lightmeter(); + break; + case settings: + updateDisplay_Settings(); + break; + } + + + display.display(); +} + +void updateDisplay_Lightmeter() //Lightmeter display +{ + #define xpos_aperature 2 + #define ypos_aperature 29 + #define xpos_shutter 60 + #define ypos_shutter 29 + + #define xpos_debug 0 + #define ypos_debug 63-7 + + #define xpos_iso 2 + #define ypos_iso 63-7-9 + + display.clearDisplay(); + display.setTextColor(WHITE); + + //Aperature + float _showAperature=roundAperature(showAperature,userSettings.aperatureSelectionMode); + display.setTextSize(1); + display.setCursor(xpos_aperature,ypos_aperature); display.print("F"); + display.setTextSize(2); + display.setCursor(display.getCursorX(),display.getCursorY()); display.print(int(_showAperature)); + if ( int( (_showAperature-int(_showAperature) )*10 ) !=0){ //has a decimal + display.setTextSize(1); + display.setCursor(display.getCursorX()-2,display.getCursorY()+7); display.print("."); display.setCursor(display.getCursorX()+1,display.getCursorY()-7); + display.setTextSize(2); + display.setCursor(display.getCursorX()-2,display.getCursorY()); + display.print( (int)round( (_showAperature-int(_showAperature) )*10)); + } + //Aperature border + if (setAperature>0){ //Aperature Priority Mode + display.drawRect(xpos_aperature-2, ypos_aperature-2, 40, 18, WHITE); + } + + + //Shutter + display.setCursor(xpos_shutter,ypos_shutter); + float _showShutter=roundShutter(showShutter,userSettings.shutterSelectionMode); + //Serial.print("rounded Shutter from "); Serial.print(showShutter); Serial.print(" to "); Serial.println(_showShutter); //asdf + if (_showShutter>=1) //check time + { //show full seconds + display.print(int(_showShutter)); + if (_showShutter-int(_showShutter)>0){ //has decimals + display.setTextSize(1); + display.setCursor(display.getCursorX()-2,display.getCursorY()+7); display.print("."); display.setCursor(display.getCursorX()+1,display.getCursorY()-7); + display.setTextSize(2); + display.setCursor(display.getCursorX()-2,display.getCursorY()); + display.print( (int)round( (_showShutter-int(_showShutter))*10)); //show one decimal + } + display.setTextSize(1); display.setCursor(display.getCursorX(),display.getCursorY()+7); + display.print("s"); + }else{ //show fraction of a second + display.setTextSize(1); display.print("1"); + display.drawLine(display.getCursorX()+1,display.getCursorY(), display.getCursorX()-1, display.getCursorY()+9, WHITE); + display.setTextSize(2); display.setCursor(display.getCursorX()+2,display.getCursorY()); + int _frac_showShutter = (int) ( (1.0f/( (int)(_showShutter*1000000) ) )*1000000 ); + display.print( _frac_showShutter ); + display.setTextSize(1); display.setCursor(display.getCursorX(),display.getCursorY()+7); + display.print("s"); + } + //Shutter border + if (setShutter>0){ //Shutter Priority Mode + display.drawRect(xpos_shutter-2, ypos_shutter-2, 40, 18, WHITE); + } + + //ISO + display.setCursor(xpos_iso,ypos_iso); display.setTextSize(1); display.print("ISO "); display.print(setISO); + + //DEBUG Message + display.setTextSize(1); + display.setCursor(xpos_debug,ypos_debug); + display.print(vbat); + display.print("V "); + display.print("Ev="); + display.print(ev); +} + +void updateDisplay_Settings() +{ + display.clearDisplay(); + display.setTextColor(WHITE); + display.setTextSize(1); + #define SETTINGS_YPOS_INCREMENT 9 + #define SETTINGS_XPOS_OFFSET 1 + + + + display.setCursor(SETTINGS_XPOS_OFFSET,0); //absolute position for first item + + for (uint8_t _currentItemIndex=0;_currentItemIndex<=SETTINGS_SELECTEDITEM_MAX;_currentItemIndex++) + { + if (settings_selectedItem==_currentItemIndex){ + if (settings_itemActive){ + display.drawRect(0, display.getCursorY()-2, 126 , 11, WHITE); + }else{ + display.fillCircle(2, display.getCursorY()+3,2, WHITE); //x,y,r,color + } + display.setCursor(display.getCursorX()+5,display.getCursorY()); //move text to the right + } + display.print(settingStrings[_currentItemIndex]); + switch(_currentItemIndex){ //if values need to be shown + case 0: display.print(setISO); + break; + case 1: display.print(settingsnameAperatureSelectionMode[userSettings.aperatureSelectionMode-1]); + break; + case 2: display.print(settingsnameShutterSelectionMode[userSettings.shutterSelectionMode-1]); + break; + } + + display.setCursor(SETTINGS_XPOS_OFFSET,display.getCursorY()+SETTINGS_YPOS_INCREMENT); //move cursor to next entry + } + + + + /* + if (settings_selectedItem==1){ + if (settings_itemActive){ + display.drawRect(display.getCursorX()-2, display.getCursorY()-2, 126 , 11, WHITE); + }else{ + display.drawCircle(0, display.getCursorY()+4,2, display.getCursorY()+6); + } + } + display.print("TestTest");*/ + +} +