forked from 400plus/400plus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
viewfinder.c
183 lines (161 loc) · 3.51 KB
/
viewfinder.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include <vxworks.h>
#include "firmware.h"
#include "firmware/camera.h"
#include "main.h"
#include "macros.h"
#include "exposure.h"
#include "fexp.h"
#include "persist.h"
#include "qexp.h"
#include "msm.h"
#include "settings.h"
#include "utils.h"
#include "intercom.h"
#include "viewfinder.h"
dpr_data_t vf_DPData;
void viewfinder_change_iso (iso_t iso);
void viewfinder_display_iso(iso_t iso);
void viewfinder_change_evc(ec_t av_comp);
void viewfinder_right() {
if (settings.autoiso_enable) {
// AutoISO + M => change exposure compensation
if (DPData.ae == AE_MODE_M)
viewfinder_change_evc(ec_inc(persist.ev_comp, FALSE));
} else {
// Only for creative modes
if (AE_IS_CREATIVE(DPData.ae))
viewfinder_change_iso(iso_next(DPData.iso));
}
}
void viewfinder_left() {
if (settings.autoiso_enable) {
// AutoISO + M => change exposure compensation
if (DPData.ae == AE_MODE_M)
viewfinder_change_evc(ec_dec(persist.ev_comp, FALSE));
} else {
// Only for creative modes
if (AE_IS_CREATIVE(DPData.ae))
viewfinder_change_iso(iso_prev(DPData.iso));
}
}
void viewfinder_up() {
if (settings.autoiso_enable) {
// AutoISO + M => reset exposure compensation
if (DPData.ae == AE_MODE_M)
viewfinder_change_evc(EV_ZERO);
} else {
// Only for creative modes
if (AE_IS_CREATIVE(DPData.ae))
viewfinder_display_iso(DPData.iso);
}
}
void viewfinder_down() {
switch (DPData.ae) {
case AE_MODE_M:
qexp_enable();
break;
case AE_MODE_P:
case AE_MODE_TV:
case AE_MODE_AV:
msm_register();
break;
default:
break;
}
}
void viewfinder_set() {
switch (DPData.ae) {
case AE_MODE_M:
fexp_enable();
break;
case AE_MODE_P:
case AE_MODE_TV:
case AE_MODE_AV:
msm_start();
break;
default:
break;
}
}
void viewfinder_end() {
switch (status.vf_status) {
case(VF_STATUS_ISO):
switch (DPData.ae) {
case AE_MODE_M:
case AE_MODE_TV:
// Restore previous state
send_to_intercom(IC_SET_CF_EMIT_FLASH, vf_DPData.cf_emit_aux);
send_to_intercom(IC_SET_TV_VAL, vf_DPData.tv_val);
break;
case AE_MODE_P:
case AE_MODE_AV:
send_to_intercom(IC_SET_BURST_COUNTER, 9);
break;
default:
break;
}
break;
case(VF_STATUS_MSM):
msm_release();
break;
case(VF_STATUS_FEXP):
fexp_disable();
break;
case(VF_STATUS_QEXP):
qexp_disable();
break;
default:
break;
}
status.vf_status = VF_STATUS_NONE;
}
void viewfinder_change_iso(iso_t iso) {
// Set new ISO
send_to_intercom(IC_SET_ISO, iso);
// Display new ISO
viewfinder_display_iso(iso);
}
void viewfinder_display_iso(iso_t iso) {
// Save current state
vf_DPData = DPData;
switch (DPData.ae) {
// Display ISO as shutter speed
case AE_MODE_M:
case AE_MODE_TV:
// Change to Tv=ISO, no flash
send_to_intercom(IC_SET_CF_EMIT_FLASH, TRUE);
send_to_intercom(IC_SET_TV_VAL, (iso & 0xF8) + 0x25);
break;
// Display ISO as burst counter
case AE_MODE_P:
case AE_MODE_AV:
switch (iso) {
case ISO_100:
send_to_intercom(IC_SET_BURST_COUNTER, 1);
break;
case ISO_200:
send_to_intercom(IC_SET_BURST_COUNTER, 2);
break;
case ISO_400:
send_to_intercom(IC_SET_BURST_COUNTER, 4);
break;
case ISO_800:
send_to_intercom(IC_SET_BURST_COUNTER, 8);
break;
case ISO_1600:
send_to_intercom(IC_SET_BURST_COUNTER, 9);
break;
default:
break;
}
break;
default:
break;
}
// Set flag to restore viewfinder later
status.vf_status = VF_STATUS_ISO;
}
void viewfinder_change_evc(ec_t ev_comp) {
persist.ev_comp = CLAMP(ev_comp, EV_CODE(-2, 0), EV_CODE(2,0));
enqueue_action(persist_write);
}