-
Notifications
You must be signed in to change notification settings - Fork 0
/
shutter-lowlevel.inc
216 lines (150 loc) · 2.65 KB
/
shutter-lowlevel.inc
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
radix dec ; Default to Decimal numbers
extern ToSevenSegDec
extern ToSevenSegLET
LEDOFFNEG equ b'00001111'
BUTTONNEG equ b'00010000'
PORTAInputs equ b'00110000'
PORTBInputs equ b'00000000'
;DEEPROM code
;EEShutter dw 0, 0, 0
;EETimer dw 0, 0, 0
;EERepeat dw 0, 0, 0
udata
MenuState res 1
TimerMode res 1
ShutterState res 1
SHUTTER_HALFWAY equ 6
SHUTTER_CLICK equ 7
Buttons res 1
BTN_DOWN equ 0
BTN_UP equ 1
BTN_CANCEL equ 2
BTN_OK equ 3
OldButtons res 1
HoldDelay res 1
Display res 2
Display2 res 2
DECIMALSEG equ 2
DisplayPointer res 1
quicke res 1
quickt res 1
quickr res 1
exposure res 3
timer res 3
repeat res 3
exposurew res 3
timerw res 3
Loopv1 res 1
DisplayLoop res 1
code
RST code 0x0000
goto main
INT code 0x0004 ; Interrupt Vector
SaveState
call interupt
RestoreState
retfie ; End Interrupt Vector
MYINIT macro
errorlevel -302
bsf STATUS, RP0
bcf OPTION_REG, 7 ; Port B pullups
bcf OPTION_REG, T0CS
bsf PIE1, TMR2IE ; TIMER2 interrupt
movlw 250
movwf PR2 ; TIMER2 period
bcf STATUS, RP0
errorlevel +302
movlw 1
movwf Loopv1
;timer2
clrf T2CON
clrf TMR2
movlw ((10-1) << 3) | 1
movwf T2CON
bsf INTCON, GIE ; interrupts
bsf INTCON, PEIE; peripheral interrupts
clrf ShutterState
clrf MenuState
clrf TimerMode
clrf DisplayPointer
clrf DisplayLoop
movlw 0
movwf quicke
movlw 4
movwf quickt
movlw 4
movwf quickr
LoadTime exposure, 0, 1, 0
LoadTime timer, 0, 2, 0
clrf repeat
clrf repeat+2
movlw 5
movwf repeat+1
endm
ReadButtons
clrf PORTA
movlw LEDOFFNEG
iorwf ShutterState, w
movwf PORTB
errorlevel -302
bsf STATUS, RP0
movlw b'00001111'
movwf TRISB
bcf TRISA, 4
bcf STATUS, RP0
errorlevel +302
movfw ShutterState
movwf PORTB
movfw PORTB
andlw 0x0f
movwf Buttons
errorlevel -302
bsf STATUS, RP0
movlw PORTBInputs
movwf TRISB
bsf TRISA, 4
bcf STATUS, RP0
errorlevel +302
movlw LEDOFFNEG
iorwf ShutterState, w
movwf PORTB
return
ShowDigit macro value, digit
movlw LEDOFFNEG
iorwf ShutterState, w
movwf PORTB
movfw value
movwf PORTA
;movfw value
andlw b'00110000'
iorlw ((~(1 << digit)) & b'00001111')
iorwf ShutterState, w
movwf PORTB
;call DigitDisplayDelay
endm
FrameDelay
decfsz Loopv1, f
retlw 0
movlw 50
movwf Loopv1
bsf STATUS, Z
return
#define ToBD(X) (X / 10 << 4) | (X % 10)
BD7Seg macro DSTF, BDF
movfw BDF
andlw 0x0f
call ToSevenSegDec
movwf DSTF+0
swapf BDF, w
andlw 0x0f
call ToSevenSegDec
movwf DSTF+1
endm
LoadTime macro DST, XX, YY, ZZ
movlw ToBD(ZZ)
movwf DST
movlw ToBD(YY)
movwf DST+1
movlw ToBD(XX)
movwf DST+2
endm