Changeset 657


Ignore:
Timestamp:
05/06/11 08:27:20 (2 years ago)
Author:
msl
Message:

Skript-Befehle fuer Multipartition-Untetstuetzung

+ get_partitionInfo() Liefert eine Tabelle mit folgenden Einträgen:

info["count"] Liefert die Anzahl der Partitionen auf der SD-Karte
info["active"]
Gibt die aktive Partitionsnummer zurück. (Beginnend bei "1" und nicht bei "0")
info["type"] Gibt den Partitionstyp der aktiven Partition zurück.
info["size"]
Gibt den Größe in MB der aktiven Partition zurück.
swap_partition(nr) Wechselt auf die angegebene Partition. (Neustart notwendig!)
swap_partition()
swap_partition() ohne Parameter wechselt auf die nächste Partition auf der Karte.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/luascript.c

    r646 r657  
    300300} 
    301301 
     302#ifdef CAM_MULTIPART 
     303static int luaCB_get_partitionInfo( lua_State* L ) 
     304{ 
     305  lua_createtable(L, 0, 4); 
     306  SET_INT_FIELD("count",  get_part_count()); 
     307  SET_INT_FIELD("active", get_active_partition()); 
     308  SET_INT_FIELD("type",   get_part_type()); 
     309  SET_INT_FIELD("size",   GetTotalCardSpaceKb()>>10); 
     310  return 1; 
     311} 
     312 
     313static int luaCB_swap_partitions( lua_State* L ) 
     314{ 
     315  int partNr; 
     316 
     317  if( lua_gettop(L)==1 ) 
     318  { 
     319    partNr = luaL_checknumber(L, 1); 
     320  } 
     321  else 
     322  { 
     323    int partCount = get_part_count(); 
     324    partNr = get_active_partition()+1; 
     325    if( partNr > partCount ) partNr = 1; 
     326  } 
     327  lua_pushboolean(L, swap_partitions(partNr)); 
     328  return 1; 
     329} 
     330#endif 
     331 
    302332static int luaCB_get_av96( lua_State* L ) 
    303333{ 
     
    18101840  FUNC(print_screen); 
    18111841 
     1842#ifdef CAM_MULTIPART 
     1843  FUNC(get_partitionInfo); 
     1844  FUNC(swap_partitions); 
     1845#endif 
     1846   
    18121847  FUNC(get_focus_mode); 
    18131848  FUNC(get_focus_state); 
  • trunk/include/platform.h

    r643 r657  
    460460 
    461461 
    462 void swap_partitions(int new_partition); 
     462int swap_partitions(int new_partition); 
    463463unsigned char get_active_partition(void); 
     464int get_part_type(void); 
    464465int get_part_count(void); 
    465466int is_partition_changed(void); 
  • trunk/lib/ubasic/tokenizer.c

    r406 r657  
    152152  {"get_exp_count",           TOKENIZER_GET_EXP_COUNT}, 
    153153  {"get_config_value",        TOKENIZER_GET_CONFIG_VALUE}, 
    154  
     154  {"get_partitionInfo",       TOKENIZER_GET_PARTITION_INFO}, 
     155  {"swap_partitions",         TOKENIZER_SWAP_PARTITIONS}, 
    155156//SET 
    156157  {"set_av96_direct",         TOKENIZER_SET_AV96_DIRECT}, 
  • trunk/lib/ubasic/tokenizer.h

    r406 r657  
    203203  TOKENIZER_GET_CONFIG_VALUE, 
    204204  TOKENIZER_SET_CONFIG_VALUE, 
    205    
     205  TOKENIZER_GET_PARTITION_INFO, 
     206  TOKENIZER_SWAP_PARTITIONS 
    206207} ubasic_token; 
    207208 
  • trunk/lib/ubasic/ubasic.c

    r574 r657  
    241241    r = ! relation(); 
    242242    break; 
    243 case TOKENIZER_GET_VBATT: 
     243  case TOKENIZER_GET_VBATT: 
    244244    accept(TOKENIZER_GET_VBATT); 
    245245    r = (unsigned short) stat_get_vbatt(); 
    246246    break; 
    247  case TOKENIZER_GET_DAY_SECONDS: 
     247  case TOKENIZER_GET_DAY_SECONDS: 
    248248    accept(TOKENIZER_GET_DAY_SECONDS); 
    249249    r = shooting_get_day_seconds(); 
    250250    break; 
    251  case TOKENIZER_GET_TICK_COUNT: 
     251  case TOKENIZER_GET_TICK_COUNT: 
    252252    accept(TOKENIZER_GET_TICK_COUNT); 
    253253    r = shooting_get_tick_count();      
    254    break; 
    255  case TOKENIZER_GET_MODE: 
     254    break; 
     255  case TOKENIZER_GET_MODE: 
    256256    accept(TOKENIZER_GET_MODE); 
    257257    int m=mode_get()&MODE_SHOOTING_MASK; 
     
    260260    if ((mode_get()&MODE_MASK) == MODE_PLAY) r = 1; 
    261261    if (((mode_get()&MODE_MASK) != MODE_PLAY) && mode_video) r = 2; 
    262    break; 
    263  case TOKENIZER_GET_RAW_NR: 
     262  break; 
     263  case TOKENIZER_GET_RAW_NR: 
    264264    accept(TOKENIZER_GET_RAW_NR); 
    265265    r = camera_get_nr();      
    266266    break; 
    267  case TOKENIZER_IS_KEY: 
     267  case TOKENIZER_IS_KEY: 
    268268    accept(TOKENIZER_IS_KEY); 
    269269    r = script_key_is_clicked(ubasic_get_key_arg()); 
    270270    break; 
    271 case TOKENIZER_SCRIPT_AUTOSTARTED: 
     271  case TOKENIZER_SCRIPT_AUTOSTARTED: 
    272272    accept(TOKENIZER_SCRIPT_AUTOSTARTED); 
    273273    r = camera_get_script_autostart(); 
    274274    break; 
    275 case TOKENIZER_GET_SCRIPT_AUTOSTART: 
     275  case TOKENIZER_GET_SCRIPT_AUTOSTART: 
    276276    accept(TOKENIZER_GET_SCRIPT_AUTOSTART); 
    277277#ifdef UBASIC_TEST 
    278         r = 0; 
    279 #else    
     278    r = 0; 
     279#else 
    280280    r = conf.script_startup; 
    281281#endif 
    282282    break; 
    283 case TOKENIZER_GET_USB_POWER: 
     283  case TOKENIZER_GET_USB_POWER: 
    284284    accept(TOKENIZER_GET_USB_POWER); 
    285285    r = get_usb_power(0);      
    286286    break; 
    287 case TOKENIZER_GET_EXP_COUNT: 
     287  case TOKENIZER_GET_EXP_COUNT: 
    288288    accept(TOKENIZER_GET_EXP_COUNT); 
    289289    r = get_exposure_counter(); 
    290290    break; 
    291 case TOKENIZER_IS_PRESSED: 
     291  case TOKENIZER_IS_PRESSED: 
    292292    accept(TOKENIZER_IS_PRESSED); 
    293293    r = script_key_is_clicked(ubasic_get_key_arg()); 
     
    302302    action_push_delay(rand()%10); 
    303303    r = min + rand()%(max-min+1); 
    304   break; 
     304    break; 
    305305  case TOKENIZER_GET_MOVIE_STATUS: 
    306306    accept(TOKENIZER_GET_MOVIE_STATUS); 
    307307    r = movie_status; 
    308    break; 
     308    break; 
    309309  case TOKENIZER_GET_PLATFORM_ID: 
    310310    accept(TOKENIZER_GET_PLATFORM_ID); 
    311311    r = PLATFORMID; 
    312    break; 
     312    break; 
    313313  case TOKENIZER_GET_DRIVE_MODE: 
    314314    accept(TOKENIZER_GET_DRIVE_MODE); 
    315315    r = shooting_get_drive_mode(); 
    316    break; 
     316    break; 
    317317   case TOKENIZER_GET_FOCUS_MODE: 
    318318    accept(TOKENIZER_GET_FOCUS_MODE); 
    319319    r = shooting_get_real_focus_mode(); 
    320    break; 
     320    break; 
    321321  case TOKENIZER_GET_FOCUS_STATE: 
    322322    accept(TOKENIZER_GET_FOCUS_STATE); 
    323323    r = shooting_get_focus_state(); 
    324    break; 
     324    break; 
    325325  case TOKENIZER_GET_FOCUS_OK: 
    326326    accept(TOKENIZER_GET_FOCUS_OK); 
    327327    r = shooting_get_focus_ok(); 
    328    break; 
    329         case TOKENIZER_GET_DISPLAY_MODE: 
     328    break; 
     329  case TOKENIZER_GET_DISPLAY_MODE: 
    330330    accept(TOKENIZER_GET_DISPLAY_MODE); 
    331331    r = shooting_get_prop(PROPCASE_DISPLAY_MODE); 
    332    break; 
     332    break; 
    333333  case TOKENIZER_GET_FLASH_MODE: 
    334334    accept(TOKENIZER_GET_FLASH_MODE); 
    335335    r = shooting_get_prop(PROPCASE_FLASH_MODE); 
    336    break; 
     336    break; 
    337337  case TOKENIZER_GET_SHOOTING: 
    338338    accept(TOKENIZER_GET_SHOOTING); 
    339339    r = shooting_get_prop(PROPCASE_SHOOTING); 
    340    break; 
     340    break; 
    341341  case TOKENIZER_GET_FLASH_READY: 
    342342    accept(TOKENIZER_GET_FLASH_READY); 
    343343    r = shooting_get_prop(PROPCASE_IS_FLASH_READY); 
    344    break; 
     344    break; 
    345345  case TOKENIZER_GET_IS_MODE: 
    346346    accept(TOKENIZER_GET_IS_MODE); 
    347347    r = shooting_get_prop(PROPCASE_IS_MODE); 
    348    break; 
     348    break; 
    349349  case TOKENIZER_GET_EV: 
    350350    accept(TOKENIZER_GET_EV); 
    351351    r = shooting_get_prop(PROPCASE_EV_CORRECTION_1); 
    352    break; 
     352    break; 
    353353  case TOKENIZER_GET_RESOLUTION: 
    354354    accept(TOKENIZER_GET_RESOLUTION); 
    355355    r = shooting_get_prop(PROPCASE_RESOLUTION); 
    356    break; 
     356    break; 
    357357  case TOKENIZER_GET_QUALITY: 
    358358    accept(TOKENIZER_GET_QUALITY); 
    359359    r = shooting_get_prop(PROPCASE_QUALITY); 
    360    break; 
     360    break; 
    361361  case TOKENIZER_GET_ORIENTATION_SENSOR: 
    362362    accept(TOKENIZER_GET_ORIENTATION_SENSOR); 
    363363    r = shooting_get_prop(PROPCASE_ORIENTATION_SENSOR); 
    364    break; 
     364    break; 
    365365  case TOKENIZER_GET_ZOOM_STEPS: 
    366366    accept(TOKENIZER_GET_ZOOM_STEPS); 
    367367    r = zoom_points; 
    368    break; 
     368    break; 
    369369  case TOKENIZER_GET_ND_PRESENT: 
    370370    accept(TOKENIZER_GET_ND_PRESENT); 
     
    378378    r = 2; 
    379379    #endif 
    380    break; 
     380    break; 
    381381  case TOKENIZER_GET_PROPSET: 
    382382    accept(TOKENIZER_GET_PROPSET); 
    383383    r = CAM_PROPSET; 
    384    break; 
     384    break; 
    385385  case TOKENIZER_GET_TV96: 
    386386    accept(TOKENIZER_GET_TV96); 
     
    459459    r = GetFreeCardSpaceKb(); 
    460460    break; 
    461  
    462461  case TOKENIZER_GET_JPG_COUNT: 
    463462    accept(TOKENIZER_GET_JPG_COUNT); 
     
    493492    switch (temp) 
    494493    { 
    495         case 0: 
    496                 r = get_optical_temp();  
    497                 break; 
    498         case 1: 
    499                 r = get_ccd_temp();  
    500                 break; 
    501         case 2: 
    502                 r = get_battery_temp(); 
    503                 break; 
    504                 default: // do something sane if given a bad index 
    505                         r = 0; 
    506   } 
    507     break; 
    508   case TOKENIZER_GET_TIME: { 
     494    case 0: 
     495      r = get_optical_temp();  
     496      break; 
     497    case 1: 
     498      r = get_ccd_temp();  
     499      break; 
     500    case 2: 
     501      r = get_battery_temp(); 
     502      break; 
     503    default: // do something sane if given a bad index 
     504      r = 0; 
     505    } 
     506    break; 
     507  case TOKENIZER_GET_TIME: 
    509508    accept(TOKENIZER_GET_TIME); 
    510         unsigned long t2 = time(NULL); 
     509    unsigned long t2 = time(NULL); 
    511510    int tmode = expr(); 
    512      static struct tm *ttm; 
    513      ttm = localtime(&t2); 
     511    static struct tm *ttm; 
     512    ttm = localtime(&t2); 
    514513    if (tmode==0) r = ttm->tm_sec; 
    515514    else if (tmode==1) r = ttm->tm_min; 
     
    518517    else if (tmode==4) r = ttm->tm_mon+1; 
    519518    else if (tmode==5) r = 1900+ttm->tm_year; 
    520  break; 
    521  } 
    522  case TOKENIZER_GET_RAW: 
     519    break; 
     520  case TOKENIZER_GET_RAW: 
    523521    accept(TOKENIZER_GET_RAW); 
    524522#ifdef UBASIC_TEST 
    525         r = 1; 
    526 #else    
     523    r = 1; 
     524#else 
    527525    r = conf.save_raw; 
    528526#endif     
    529527    break; 
    530  // get CHDK capture mode value, or 0 if in playback or unknown (broken modemap) 
    531  // NOTE: different from get_mode, since this returns the actual value 
    532  case TOKENIZER_GET_CAPTURE_MODE: 
     528  // get CHDK capture mode value, or 0 if in playback or unknown (broken modemap) 
     529  // NOTE: different from get_mode, since this returns the actual value 
     530  case TOKENIZER_GET_CAPTURE_MODE: 
    533531    accept(TOKENIZER_GET_CAPTURE_MODE); 
    534532    r = mode_get(); 
    535533    if ( (r&MODE_MASK) == MODE_REC)  
    536         r &= MODE_SHOOTING_MASK; 
     534      r &= MODE_SHOOTING_MASK; 
    537535    else 
    538         r = 0; 
    539     break; 
    540  // check if CHDK capture mode exists in modemap of this camera 
    541  case TOKENIZER_IS_CAPTURE_MODE_VALID: { 
     536      r = 0; 
     537    break; 
     538  // check if CHDK capture mode exists in modemap of this camera 
     539  case TOKENIZER_IS_CAPTURE_MODE_VALID: 
    542540    accept(TOKENIZER_IS_CAPTURE_MODE_VALID); 
    543541    int modenum = expr(); 
    544542    if (shooting_mode_chdk2canon(modenum) == -1) 
    545         r = 0; 
     543      r = 0; 
    546544    else 
    547         r = 1; 
     545      r = 1; 
    548546    break; 
    549547  case TOKENIZER_GET_FOCAL_LENGTH: 
     
    557555  case TOKENIZER_GET_CONFIG_VALUE: 
    558556    accept(TOKENIZER_GET_CONFIG_VALUE); 
    559     int var = expr(); 
    560557    int var1 = expr(); 
    561     if( conf_getValue(var, &configVal) == CONF_VALUE) r = configVal.numb; else r = var1; 
    562     break; 
    563   } 
     558    int var2 = expr(); 
     559    if( conf_getValue(var1, &configVal) == CONF_VALUE) r = configVal.numb; else r = var2; 
     560    break; 
     561#ifdef CAM_MULTIPART 
     562  case TOKENIZER_SWAP_PARTITIONS: 
     563    accept(TOKENIZER_SWAP_PARTITIONS); 
     564    int partNr = expr(); 
     565    r = swap_partitions(partNr); 
     566    break; 
     567#endif 
    564568  default: 
    565569    r = varfactor(); 
  • trunk/platform/generic/wrappers.c

    r645 r657  
    923923  return count; 
    924924} 
     925int get_part_type() 
     926{ 
     927  int partType = 0x00; 
     928  if (is_mbr_loaded()) 
     929  { 
     930    partType=mbr_buf[0x1C2+(get_active_partition()-1)*16]; 
     931  } 
     932  return partType; 
     933}  
    925934 
    926935static int boot_partition = 0; 
     
    929938{ 
    930939  return partition_changed; 
    931  } 
    932   
    933 void swap_partitions(int new_partition) 
     940} 
     941 
     942int swap_partitions(int new_partition) 
    934943{ 
    935944  if (is_mbr_loaded()) 
     
    949958    if( new_partition > partition_count || new_partition <= 0 ) 
    950959    { 
    951       return; 
     960      return 0; 
    952961    } 
    953962    partition_changed = (new_partition==boot_partition)?0:1; 
     
    972981    _WriteSDCard(0,0,1,mbr_buf); 
    973982  } 
     983  return 1; 
    974984} 
    975985 
Note: See TracChangeset for help on using the changeset viewer.