void msm_start(void) { if (status.msm_count > 0) { status.msm_active = TRUE; tv_t tv = ev_normalize(status.msm_tv / status.msm_count); av_t av = ev_normalize(status.msm_av / status.msm_count); av_t av_max = DPData.ef_lens_exist ? DPData.avmax : AV_MAX; av_t av_min = DPData.ef_lens_exist ? DPData.avo : AV_MIN; msm_ae_return = DPData.ae; send_to_intercom(IC_SET_AE, AE_MODE_M); msm_tv_return = DPData.tv_val; msm_av_return = DPData.av_val; send_to_intercom(IC_SET_TV_VAL, CLAMP(tv, TV_MIN, TV_MAX)); send_to_intercom(IC_SET_AV_VAL, CLAMP(av, av_min, av_max)); enqueue_action(beep); } }
void qexp(void) { int weight; ec_t diff, ec_tmp; av_t av = status.measured_av; tv_t tv = status.measured_tv; ec_t ec = status.measured_ec; av_t av_max = DPData.ef_lens_exist ? DPData.avmax : AV_MAX; av_t av_min = DPData.ef_lens_exist ? DPData.avo : AV_MIN; if (status.measuring) { // Set lens to maximum aperture diff = av_min - av; av += diff; ec -= diff; // Set shutter to 1/60 diff = settings.qexp_mintv - tv; tv += diff; ec -= diff; // If under-exposing, increase shutter speed if (ec < 0) { diff = MAX(tv + ec, TV_MIN) - tv; tv += diff; ec -= diff; } // If over-exposing, split the blame if (ec > 0) { ec_tmp = ec; switch (settings.qexp_weight) { default: case QEXP_WEIGHT_NONE: weight = 2; break; case QEXP_WEIGHT_AV : weight = 3; break; case QEXP_WEIGHT_TV : weight = 1; break; } diff = MIN(av + weight * ec_tmp / 4, av_max) - av; av += diff; ec -= diff; weight = 3 - weight; diff = MIN(tv + weight * ec_tmp / 4, TV_MAX) - tv; tv += diff; ec -= diff; } // If still over-exposing, one of Av / Tv reached a maximum if (ec > 0) { diff = MIN(tv + ec, TV_MAX) - tv; tv += diff; ec -= diff; diff = MIN(av + ec, av_max) - av; av += diff; ec -= diff; } send_to_intercom(IC_SET_AV_VAL, ev_normalize(av)); send_to_intercom(IC_SET_TV_VAL, ev_normalize(tv)); enqueue_action(beep); } }
tv_t tv_sub(tv_t ying, tv_t yang) { tv_t tv = ev_normalize(ying - yang); return MAX(tv, TV_MIN); // 30s }
tv_t tv_add(tv_t ying, tv_t yang) { tv_t tv = ev_normalize(ying + yang); return MIN(tv, TV_MAX); // 1/4000s }
av_t av_sub(av_t ying, av_t yang) { av_t av = ev_normalize(ying - yang); av_t min = DPData.ef_lens_exist ? DPData.avo : AV_MIN; return MAX(av, min); }
av_t av_add(av_t ying, av_t yang) { av_t av = ev_normalize(ying + yang); av_t max = DPData.ef_lens_exist ? DPData.avmax : AV_MAX; return MIN(av, max); }