| 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 | |
|---|
| 36 | // Focus length table in firmware @ 0xfffea1cc |
|---|
| 37 | #define NUM_FL 126 // 0 - 125, entries in firmware (3 words each entry, first is FL) |
|---|
| 38 | extern int focus_len_table[NUM_FL*3]; |
|---|
| 39 | |
|---|
| 40 | // Focal length range is 5.0 - 70,0 mm, 27.3 - 392 in 35-mm equivalent. |
|---|
| 41 | // So, CF_EFL = 27.3/5.0*10000=54600 or392/70*10000=56000 |
|---|
| 42 | // diff = 54600 - 54566.6 = 1400, split it 1400 / 2 = 700 |
|---|
| 43 | // add to base 56000 + 700 = 56700 |
|---|
| 44 | // divide by 10 to avoid overflow in get_effective_focal_length() |
|---|
| 45 | #define CF_EFL 5670 |
|---|
| 46 | const int zoom_points = NUM_FL; |
|---|
| 47 | |
|---|
| 48 | int get_effective_focal_length(int zp) { |
|---|
| 49 | return (CF_EFL*get_focal_length(zp))/1000; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | int get_focal_length(int zp) { |
|---|
| 53 | if (zp < 0) zp = 0; |
|---|
| 54 | else if (zp >= NUM_FL) zp = NUM_FL-1; |
|---|
| 55 | return focus_len_table[zp*3]; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | int get_zoom_x(int zp) { |
|---|
| 59 | return get_focal_length(zp)*10/focus_len_table[0]; |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | long get_vbatt_min() |
|---|
| 64 | { |
|---|
| 65 | return 3280; // min observed was 3.408, then it died |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | long get_vbatt_max() |
|---|
| 69 | { |
|---|
| 70 | return 4057; // fresh from change (actual was 4.127) |
|---|
| 71 | } |
|---|