root/platform/sx200is/main.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. startup
  2. get_effective_focal_length
  3. get_focal_length
  4. get_zoom_x
  5. get_vbatt_min
  6. 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         // sanity check
  17         if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){
  18                 started();
  19                 shutdown();
  20         }
  21 
  22         // initialize .bss senment
  23         while (bss<&link_bss_end)
  24                 *bss++ = 0;
  25 
  26         boot();
  27 }
  28 
  29 
  30 //zoom position is get_parameter_data(87)
  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 // Focal length range is 5.0 - 60,0 mm, 27.3 - 327.4 in 35-mm equivalent.
  46 // So, CF_EFL = 27.3/5.0*10000=54600 or327.4/60*10000=54566.6
  47 // diff = 54600 - 54566.6 = 33.3, split it 33.3 / 2 = 16.6
  48 // add to base 54566.6 + 16.6 = 54583.2
  49 // divide by 10 to avoid overflow in get_effective_focal_length()
  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;  // min observed was 3.408, then it died
  84 }
  85 
  86 long get_vbatt_max()
  87 {
  88         return 4057;  // fresh from change (actual was 4.127)
  89 }
  90 

/* [<][>][^][v][top][bottom][index][help] */