| 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 | |
|---|
| 15 | |
|---|
| 16 | long *bss = &link_bss_start; |
|---|
| 17 | long *ptr; |
|---|
| 18 | |
|---|
| 19 | // sanity check |
|---|
| 20 | if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){ |
|---|
| 21 | started(); |
|---|
| 22 | shutdown(); |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | // initialize .bss senment |
|---|
| 26 | while (bss<&link_bss_end) |
|---|
| 27 | *bss++ = 0; |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | boot(); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | //zoom position is get_parameter_data(87) |
|---|
| 35 | static const struct { |
|---|
| 36 | int zp, fl; |
|---|
| 37 | } fl_tbl[] = { |
|---|
| 38 | { 0, 5000}, |
|---|
| 39 | { 16, 6800}, |
|---|
| 40 | { 32, 9100}, |
|---|
| 41 | { 62, 16200}, |
|---|
| 42 | { 78, 22300}, |
|---|
| 43 | { 102, 35900}, |
|---|
| 44 | { 125, 70000}, |
|---|
| 45 | }; |
|---|
| 46 | #define NUM_FL (sizeof(fl_tbl)/sizeof(fl_tbl[0])) |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | // Focal length range is 5.0 - 70,0 mm, 27.3 - 392 in 35-mm equivalent. |
|---|
| 50 | // So, CF_EFL = 27.3/5.0*10000=54600 or392/70*10000=56000 |
|---|
| 51 | // diff = 54600 - 54566.6 = 1400, split it 1400 / 2 = 700 |
|---|
| 52 | // add to base 56000 + 700 = 56700 |
|---|
| 53 | // divide by 10 to avoid overflow in get_effective_focal_length() |
|---|
| 54 | #define CF_EFL 5670 |
|---|
| 55 | const int zoom_points = 126; |
|---|
| 56 | |
|---|
| 57 | int get_effective_focal_length(int zp) { |
|---|
| 58 | return (CF_EFL*get_focal_length(zp))/1000; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | int get_focal_length(int zp) { |
|---|
| 62 | int i; |
|---|
| 63 | |
|---|
| 64 | if (zp<fl_tbl[0].zp) |
|---|
| 65 | return fl_tbl[0].fl; |
|---|
| 66 | else if (zp>fl_tbl[NUM_FL-1].zp) |
|---|
| 67 | return fl_tbl[NUM_FL-1].fl; |
|---|
| 68 | else |
|---|
| 69 | for (i=1; i<NUM_FL; ++i) { |
|---|
| 70 | if (zp==fl_tbl[i-1].zp) |
|---|
| 71 | return fl_tbl[i-1].fl; |
|---|
| 72 | else if (zp==fl_tbl[i].zp) |
|---|
| 73 | return fl_tbl[i].fl; |
|---|
| 74 | else if (zp<fl_tbl[i].zp) |
|---|
| 75 | 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); |
|---|
| 76 | } |
|---|
| 77 | return fl_tbl[NUM_FL-1].fl; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | int get_zoom_x(int zp) { |
|---|
| 81 | return get_focal_length(zp)*10/fl_tbl[0].fl; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | long get_vbatt_min() |
|---|
| 86 | { |
|---|
| 87 | return 3280; // min observed was 3.408, then it died |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | long get_vbatt_max() |
|---|
| 91 | { |
|---|
| 92 | return 4057; // fresh from change (actual was 4.127) |
|---|
| 93 | } |
|---|