This source file includes following definitions.
- startup
- get_effective_focal_length
- get_focal_length
- get_zoom_x
- get_vbatt_min
- get_vbatt_max
1 #include "lolevel.h"
2 #include "platform.h"
3 #include "core.h"
4 #include "keyboard.h"
5
6
7 extern long link_bss_start;
8 extern long link_bss_end;
9 extern void boot();
10
11
12 void startup()
13 {
14 long *bss = &link_bss_start;
15
16
17 if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){
18 started();
19 shutdown();
20 }
21
22
23 while (bss<&link_bss_end)
24 *bss++ = 0;
25
26 boot();
27 }
28
29
30
31 static const struct {
32 int zp, fl;
33 } fl_tbl[] = {
34 { 0, 5000},
35 { 16, 6800},
36 { 32, 9100},
37 { 62, 16200},
38 { 78, 22300},
39 { 102, 35900},
40 { 125, 60000},
41 };
42 #define NUM_FL (int)(sizeof(fl_tbl)/sizeof(fl_tbl[0]))
43
44
45
46
47
48
49
50 #define CF_EFL 5458
51 const int zoom_points = 126;
52
53 int get_effective_focal_length(int zp) {
54 return (CF_EFL*get_focal_length(zp))/1000;
55 }
56
57 int get_focal_length(int zp) {
58 int i;
59
60 if (zp<fl_tbl[0].zp)
61 return fl_tbl[0].fl;
62 else if (zp>fl_tbl[NUM_FL-1].zp)
63 return fl_tbl[NUM_FL-1].fl;
64 else
65 for (i=1; i<NUM_FL; ++i) {
66 if (zp==fl_tbl[i-1].zp)
67 return fl_tbl[i-1].fl;
68 else if (zp==fl_tbl[i].zp)
69 return fl_tbl[i].fl;
70 else if (zp<fl_tbl[i].zp)
71 return fl_tbl[i-1].fl+(zp-fl_tbl[i-1].zp)*(fl_tbl[i].fl-fl_tbl[i-1].fl)/(fl_tbl[i].zp-fl_tbl[i-1].zp);
72 }
73 return fl_tbl[NUM_FL-1].fl;
74 }
75
76 int get_zoom_x(int zp) {
77 return get_focal_length(zp)*10/fl_tbl[0].fl;
78 }
79
80
81 long get_vbatt_min()
82 {
83 return 3280;
84 }
85
86 long get_vbatt_max()
87 {
88 return 4057;
89 }
90