⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cameraapp.c

📁 MTK6226修改平台UI的文件介绍
💻 C
📖 第 1 页 / 共 5 页
字号:
        gdi_lcd_set_active(GDI_LCD_MAIN_LCD_HANDLE);

        /* turn on led highlight */
        mmi_camera_turn_on_preview_led_highlight();


    mdi_camera_load_default_setting(&camera_setting_data);
    camera_setting_data.lcm = MDI_CAMERA_PREVIEW_LCM_SUBLCD;

    camera_setting_data.preview_width = SUBLCD_CAMERA_PREVIEW_WIDTH;
    camera_setting_data.preview_height = SUBLCD_CAMERA_PREVIEW_WIDTH;
    camera_setting_data.preview_rotate = CAMERA_PREVIEW_SUBLCD_CLAM_CLOSE_ROTATE;
    camera_setting_data.lcm_rotate = CAMERA_LCM_SUBLCD_CLAM_CLOSE_ROTATE;

    camera_setting_data.image_width = SUBLCD_CAMERA_CAPTURE_WIDTH;
    camera_setting_data.image_height = SUBLCD_CAMERA_CAPTURE_HEIGHT;

    camera_setting_data.continue_capture = g_camera_cntx.is_continue_capture;

    /* start preview */
    g_camera_cntx.last_error = mdi_camera_preview_start(
                                g_camera_cntx.sublcd_base_layer_handle,
                                (S32) 0,
                                (S32) 0,
                                (U16) sublcd_width,
                                (U16) sublcd_height,
                                GDI_LAYER_ENABLE_LAYER_0,
                                GDI_LAYER_ENABLE_LAYER_0,
                                TRUE,
                                CAMEAR_BG_TRASN_COLOR,  /* this value is use only CAMERA_MODULE_WITH_LCD */
                                FALSE,
                                &camera_setting_data);    
}
BOOL mmi_sublcd_camera_delete_screen_if_present(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 scrnid;
    BOOL ret = FALSE;
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for(scrnid= SCR_ID_CAMERA_SUBLCD_APP; scrnid <= SCR_ID_CAMERA_SUBLCD_OPTION_FLASH; scrnid++)
    {
        if (IsSubLCDScreenPresent(scrnid))
        {
            DeleteSubLCDScreen(scrnid);
            ret = TRUE;
        }
        else if (GetSubLCActiveScreenId()==scrnid)
            ret = TRUE;
    }

    return ret;
}
static void mmi_sublicd_camera_display_error_screen(void)
{
    DisplaySubLcdPopup(IMG_GLOBAL_WARNING);
    mmi_sublcd_camera_delete_screen_if_present();
}
U8 mmi_sublcd_camera_clam_close_event_hdlr(void *ptr)
{

}
static void mmi_sublcd_camera_set_flash(void)
{
    /* off */
    if(g_camera_cntx.cur_select_flash_idx == 1) 
    {
        #ifdef __CAMERA_FEATURE_FLASH__
        g_camera_cntx.setting.flash = CAMERA_SETTING_FLASH_OFF;
        #endif
        #ifdef __CAMERA_FEATURE_LED_HIGHLIGHT_ON_OFF__
        g_camera_cntx.setting.led_highlight = CAMERA_SETTING_LED_HIGHLIGHT_OFF;
        #endif
    }
    else
    {
        #ifdef __CAMERA_FEATURE_FLASH__
        g_camera_cntx.setting.flash = CAMERA_SETTING_FLASH_ON;
        #endif
        #ifdef __CAMERA_FEATURE_LED_HIGHLIGHT_ON_OFF__
        g_camera_cntx.setting.led_highlight = CAMERA_SETTING_LED_HIGHLIGHT_ON;
        #endif
    }
    mmi_camera_store_setting();
    ClearKeyEvents();
    ClearInputEventHandler(MMI_DEVICE_KEY);
    GoBackSubLCDHistory();
}
static void mmi_sublcd_camera_entry_preview_screen(void)
{
   DisplaySubLCDScreen(SCR_ID_CAMERA_SUBLCD_APP, mmi_sublcd_camera_entry_preview_screen_ex, 1);
}
static void mmi_sublcd_camera_entry_preview_screen_ex(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U8 *guiBuffer;
    U16 cur_storage;
    S32 create_result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ExecSubLCDCurrExitHandler();
    ClearInputEventHandler(MMI_DEVICE_KEY);

#ifdef __USB_IN_NORMAL_MODE__
    if (mmi_usb_is_in_mass_storage_mode())
    {
        /* in mass storage mode */

        if (mmi_usb_check_path_exported((PS8) MMI_IMGVIEW_STORAGE_FILEPATH_PHONE))
        {
            /* phone drive is exported, cant use this app */
            mmi_usb_app_unavailable_popup(0);   /* pass 0 will show default string */
            return;
        }
    }
#endif /* __USB_IN_NORMAL_MODE__ */ 

    g_camera_cntx.is_sublcd_previewing = TRUE;

    /* turn off 3D sound */
#ifdef __MMI_AUDIO_REVERB_EFFECT__
    g_camera_cntx.is_3d_sound_on = mmi_aud_reverb_get_status();
    if (g_camera_cntx.is_3d_sound_on == TRUE)
    {
        mdi_audio_reverb_turn_off();
    }
#endif /* __MMI_AUDIO_REVERB_EFFECT__ */ 

   /************ init/config framework's environment  ************/

    /* entry full screen app */
    entry_full_screen();

    /* 
     * This is used to solve a very rare situation. When playing a IMELODY 
     * with backlight on/off, and the screen previous to this screen is a 
     * horizontal screen. Before enter this screen, the IMELODY turn off the
     * backlight. While exit previous screen, the layer rotate back to normal
     * size and the content is not correct. So when calling TurnOnBacklight, 
     * LCD is in sleepin state and draw wrong content to LCD.
     * So we need to clear the buffer first to avoid this situation.
     */
    gdi_layer_clear(GDI_COLOR_BLACK);

    /* stop MMI sleep */
    TurnOnBacklight(0);

    /* force all playing keypad tone off */
    AudioStopReq(GetCurKeypadTone());

    /* disable key pad tone */
    mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_DISABLED);

    /* disalbe align timer  */
    UI_disable_alignment_timers();

    /* stop LED patten */
    GpioCtrlReq(MMIAPI_DEV_CTRL_GET);

    /* get sublcd base layer handle */
    gdi_lcd_set_active(GDI_LCD_SUB_LCD_HANDLE);
    gdi_layer_get_base_handle(&g_camera_cntx.sublcd_base_layer_handle);
    gdi_layer_clear(GDI_COLOR_BLACK);
    gdi_lcd_set_active(GDI_LCD_MAIN_LCD_HANDLE);

    gdi_lcd_freeze(TRUE);

#if defined(__MMI_CLAMSHELL__) && !defined(__MMI_SLIDE__) && defined(MMI_ON_HARDWARE_P)
    /* register event hdlr */
//    SetInterruptEventHandler(mmi_sublcd_camera_clam_close_event_hdlr, NULL, MSG_ID_MMI_EQ_GPIO_DETECT_IND);
#endif /* defined(__MMI_CLAMSHELL__) && !defined(__MMI_SLIDE__) && defined(MMI_ON_HARDWARE_P) */ 

   /************ init camera app environment ************/

    /* init some flags */
    g_camera_cntx.last_error = MDI_RES_CAMERA_SUCCEED;
    g_camera_cntx.lcm_rotate = CAMERA_LCM_MAINLCD_ROTATE;

    /* load Setting */
    mmi_camera_load_setting();

    /* allocate storage path buffer */
    g_camera_cntx.storage_filepath = gui_malloc(FMGR_PATH_BUFFER_SIZE);
    memset(g_camera_cntx.storage_filepath, 0, FMGR_PATH_BUFFER_SIZE);

    /* check if path is valid or not. if not will pop up a screen after the preview screen is show */
    // g_camera_cntx.imgview_old_storage = g_imgview_context.storage;

    if (mmi_camera_check_and_restore_valid_drv())
    {
        /* drv is valid, create directory */
        mmi_imgview_get_storage_file_path(g_camera_cntx.storage_filepath);
        create_result = mmi_imgview_create_file_dir(g_camera_cntx.storage_filepath);

        /* create directory failed */
        if (create_result == FS_WRITE_PROTECTION)
        {
            g_camera_cntx.last_error = CAMERA_ERR_WRITE_PROTECT;

            /* has error - restore to phone */
            g_imgview_context.storage =  MMI_PUBLIC_DRV;
            g_imgview_context.is_storage_path_changed = TRUE;
        }
        else if (create_result == FS_DISK_FULL)
        {
            if (cur_storage == MMI_IMGVIEW_STORAGE_PHONE)
            {
                g_camera_cntx.last_error = CAMERA_ERR_PHONE_DISK_FULL;
            }
            else
            {
                /* storage is card */
                g_camera_cntx.last_error = CAMERA_ERR_CARD_DISK_FULL;

                /* has error - restore to phone */
                g_imgview_context.storage =  MMI_PUBLIC_DRV;
                g_imgview_context.is_storage_path_changed = TRUE;
            }
        }
        else if (create_result == FS_ROOT_DIR_FULL)
        {
            if (cur_storage == MMI_IMGVIEW_STORAGE_PHONE)
            {
                g_camera_cntx.last_error = CAMERA_ERR_ROOT_DIR_FULL;
            }
            else
            {
                /* storage is card */
                g_camera_cntx.last_error = CAMERA_ERR_ROOT_DIR_FULL;

                /* has error - restore to phone */
                g_imgview_context.storage =  MMI_PUBLIC_DRV;
                g_imgview_context.is_storage_path_changed = TRUE;
            }
        }

    }
    else
    {
        /* drv no valid, means card is plugged out (or phone FAT corrupted) */

        /* if storage before restoration is already in phone, means FAT is corrupted */
        if (cur_storage == MMI_IMGVIEW_STORAGE_PHONE)
        {
            g_camera_cntx.last_error = CAMERA_ERR_CORRUPT_FAT;
        }
        else
        {
            g_camera_cntx.last_error = MDI_RES_CAMERA_ERR_NO_DISK;
        }
    }

    /* each time newly enter camera, zoom will be reset to default */
    if (guiBuffer == NULL)
    {
        g_camera_cntx.setting.zoom_idx = CAMERA_DEFAULT_SETTING_ZOOM_IDX;
    }

    /* power on and init hardware module */
    if (g_camera_cntx.last_error == MDI_RES_CAMERA_SUCCEED)
    {
        g_camera_cntx.last_error = mdi_camera_power_on();
    }


   /************ enter next state ************/
    /* entry preview */
    if (g_camera_cntx.last_error == MDI_RES_CAMERA_SUCCEED)  /* no error, if has error, will enter main then show error popup */
    {
        /* set key handler */

        /* preview start */
        mmi_sublcd_camera_preview_start();

        /* check if preview function has error */
        if (g_camera_cntx.last_error != MDI_RES_CAMERA_SUCCEED)
        {
            mmi_sublicd_camera_display_error_screen();
            return;
        }
    }
    else
    {
        mmi_sublicd_camera_display_error_screen();
        return;
    }
  
    SetKeyHandler(mmi_sublcd_camera_capture, KEY_CAMERA, KEY_EVENT_UP);
    SetKeyHandler(GoBackSubLCDHistory, KEY_CAMERA, KEY_EVENT_LONG_PRESS);
    SetSubLCDExitHandler(mmi_sublcd_camera_exit_preview_screen);
    ClearKeyEvents();
}


BOOL mmi_sublcd_camera_is_previewing(void)
{
    return g_camera_cntx.is_sublcd_previewing;
}
void mmi_sublcd_camera_exit_preview_screen(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    if (!IsSubLCDScreenPresent(SCR_ID_CAMERA_SUBLCD_APP))
    {
        SubLCDHistoryNode SubLCDHistory;

        SubLCDHistory.entryFuncPtr = mmi_sublcd_camera_entry_preview_screen_ex;
        AddSubLCDHistoryWithScrID(&SubLCDHistory, SCR_ID_CAMERA_SUBLCD_APP);
    }


    /* turn off led highlight */
    mmi_camera_turn_off_led_highlight();

    /* stop previewing */
    mmi_camera_sublcd_preview_stop();

    /* turn on/of 3D sound */
#ifdef __MMI_AUDIO_REVERB_EFFECT__
    if (g_camera_cntx.is_3d_sound_on == TRUE)
    {
        mdi_audio_reverb_turn_on();
    }
#endif /* __MMI_AUDIO_REVERB_EFFECT__ */ 

    /* shut down camera */
    mdi_camera_power_off();

    /* resume alignment timer */
    UI_enable_alignment_timers();

    /* resume LED patten */
    GpioCtrlReq(MMIAPI_DEV_CTRL_RELEASE);

    /* let MMI can sleep */
    TurnOffBacklight();


    /* re-enable keypad tone */
    mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_ENABLED);

    /* free buffer */
    gui_free(g_camera_cntx.storage_filepath);
    g_camera_cntx.storage_filepath = NULL;

    gdi_lcd_set_active(GDI_LCD_MAIN_LCD_HANDLE);

    gdi_lcd_freeze(FALSE);

#ifdef __MMI_SUBLCD__
    gdi_layer_push_and_set_active(g_camera_cntx.sublcd_base_layer_handle);
    gdi_layer_set_rotate(CAMERA_LCM_ROTATE_0);
    gdi_layer_pop_and_restore_active();
#endif /* __MMI_SUBLCD__ */ 

#if defined(__MMI_CLAMSHELL__) && !defined(__MMI_SLIDE__) && defined(MMI_ON_HARDWARE_P)
    /* un-hook clam close msg */
    ClearInterruptEventHandler(MSG_ID_MMI_EQ_GPIO_DETECT_IND);
#endif /* defined(__MMI_CLAMSHELL__) && !defined(__MMI_SLIDE__) && defined(MMI_ON_HARDWARE_P) */ 

    /* store camera setting back to NVRAM */
    mmi_camera_store_setting();

    g_camera_cntx.is_sublcd_previewing = FALSE;
}
/*****************************************************************************
 * FUNCTION
 *  mmi_camera_add_frame_highlight_hdlr
 * DESCRIPTION
 *  add frame highlight handler
 * PARAMETERS
 *  idx     [IN]        Highlight index
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_sublcd_camera_flash_highlight_hdlr(S32 idx)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    g_camera_cntx.cur_select_flash_idx= idx;
}

static void mmi_sublcd_camera_entry_flash_screen(void)
{
    DisplaySubLCDScreen(SCR_ID_CAMERA_SUBLCD_OPTION_FLASH, mmi_sublcd_camera_entry_flash_screen_ex, 1);
}
static void mmi_sublcd_camera_entry_flash_screen_ex(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 ItemList[16];
    U16 ItemIcons[16];
    U16 nItems;
    U8 *guiBuffer;
    U8 *PopUpList[32];
    S32 i;
    S32 hilight_item = 0;
    BOOL is_hide = TRUE;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ExecSubLCDCurrExitHandler();

    mmi_camera_load_setting();
    #if defined(__CAMERA_FEATURE_FLASH__) 
    if (g_camera_cntx.setting.flash == CAMERA_SETTING_FLASH_OFF)
        hilight_item = 1;
    else 
        hilight_item = 0;
    #elif defined(__CAMERA_FEATURE_LED_HIGHLIGHT__)
    if (g_camera_cntx.setting.led_highlight == CAMERA_SETTING_LED_HIGHLIGHT_OFF )
        hilight_item = 1;
    else 
        hilight_item = 0;
    #endif

    ClearInputEventHandler(MMI_DEVICE_KEY);
    
    guiBuffer = GetCurrGuiBuffer(SCR_ID_CAMERA_SUBLCD_OPTION_FLASH);
    nItems = GetNumOfChild_Ext(MENU_ID_CAMERA

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -