root/platform/sx20/main.c

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

DEFINITIONS

This source file includes following definitions.
  1. startup
  2. screen_opened
  3. screen_rotated
  4. get_effective_focal_length
  5. get_focal_length
  6. get_zoom_x
  7. get_vbatt_min
  8. 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 int screen_opened(void) {
  30 //      mode |= (physw_status[1] & 0x01000000)?0:MODE_SCREEN_OPENED;
  31         return !(physw_status[1] & 0x01000000);
  32 }
  33 
  34 int screen_rotated(void) {
  35 //      mode |= (physw_status[1] & 0x00080000)?0:MODE_SCREEN_ROTATED;
  36         return !(physw_status[1] & 0x00080000);
  37 }
  38 
  39 static const struct {
  40         int zp, fl;
  41 } fl_tbl[] = {
  42         {   0,   5000 },
  43         {  11,   6190 },
  44         {  41,  12610 },
  45         {  64,  25240 },
  46         {  86,  45470 },
  47         { 105,  65880 },
  48         { 128, 100000 },
  49 };
  50 #define NUM_FL (int)(sizeof(fl_tbl)/sizeof(fl_tbl[0]))
  51 #define CF_EFL 5600
  52 
  53 const int zoom_points = 129;
  54 
  55 int get_effective_focal_length(int zp) {
  56         return (CF_EFL*get_focal_length(zp))/1000;
  57 }
  58 
  59 int get_focal_length(int zp) {
  60         int i;
  61 
  62         if (zp<fl_tbl[0].zp)
  63                 return fl_tbl[0].fl;
  64         else if (zp>fl_tbl[NUM_FL-1].zp)
  65                 return fl_tbl[NUM_FL-1].fl;
  66         else 
  67                 for (i=1; i<NUM_FL; ++i) {
  68                         if (zp==fl_tbl[i-1].zp) 
  69                                 return fl_tbl[i-1].fl;
  70                         else if (zp==fl_tbl[i].zp) 
  71                                 return fl_tbl[i].fl;
  72                         else if (zp<fl_tbl[i].zp)
  73                                 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);
  74                 }
  75         return fl_tbl[NUM_FL-1].fl;
  76 }
  77 
  78 int get_zoom_x(int zp) {
  79         return get_focal_length(zp)*10/fl_tbl[0].fl;
  80 }
  81 
  82 long get_vbatt_min()
  83 {
  84         return 4550;
  85 }
  86 
  87 long get_vbatt_max()
  88 {
  89         return 5150;
  90 }
  91 

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