Пример #1
0
void * SimpleSliderNew(SimpleSliderClass * cls, int * bmps)
{
    SimpleSliderDesc * create;
    __size_t sz;
    sz = sizeof(SimpleSliderDesc) + (cls->bmp_nr * sizeof(int));
    create = (SimpleSliderDesc *)esMEMS_Malloc(0, sz);
    if (create) {
        eLIBs_memcpy((void *)&create->cls, (void *)cls, sizeof(SimpleSliderClass));
        create->drew_position = -1;
        create->puzzleDataSize = BYTESPERPIXEL * cls->puzzle.width * cls->puzzle.height;
        create->puzzleData = esMEMS_Malloc(0, create->puzzleDataSize);
        if (NULL == create->puzzleData) {
            esMEMS_Mfree(0, create);
            return NULL;
        }
        eLIBs_memcpy((void *)&create->bmps[0], (void *)bmps, (cls->bmp_nr * sizeof(int)));
    } else {
        return NULL;
    }
    return (void *)create;
}
Пример #2
0
int SimpleSliderDraw(void * handler, H_LYR layer, RECT * rect, int current)
{
    SimpleSliderDesc * desc;
    int i;
    int blocks;
    OFFSET locat;
    HTHEME bmpTheme;
    void * bmpData;
#ifndef REGULAR_DRAW
    HBLOCK backbg;
    HBLOCK foreg;
    FB fb;
#endif

    if (NULL == handler) {
        return -1;
    }
    desc = (SimpleSliderDesc *)handler;

    // To get the current display position
    current = (current > desc->cls.limit) ? desc->cls.limit : current;
    blocks = (current * desc->cls.bmp_nr) / desc->cls.limit;
    blocks = (blocks > desc->cls.bmp_nr) ? desc->cls.bmp_nr : blocks;

#ifndef REGULAR_DRAW
    GUI_LyrWinGetFB(layer, &fb);
    backbg = GUI_BlockCreateFrom(NULL, fb.size.width, fb.size.height, fb.addr[0], 0);
#endif
    GUI_LyrWinSel(layer);
    if (desc->drew_position < 0) {
        for (i = 1; i <= blocks; i++) {
            if (0 == getStartPoint(&locat, &desc->cls.start_point, desc->cls.direc, i, desc->cls.bmp_nr, &desc->cls.puzzle)) {
                bmpTheme = dsk_theme_open(desc->bmps[i - 1]);
                bmpData = dsk_theme_hdl2buf(bmpTheme);
#ifdef REGULAR_DRAW
                GUI_BMP_Draw(bmpData, locat.x + rect->x, locat.y + rect->y);
#else
                eLIBs_memcpy(desc->puzzleData, (void *)((int)bmpData + BITMAPHEADERSIZE), desc->puzzleDataSize);
                foreg = GUI_BlockCreateFrom(NULL, desc->cls.puzzle.width, desc->cls.puzzle.height, desc->puzzleData, 0);
                GUI_BlockBitBlit(backbg, locat.x + rect->x, locat.y + rect->y,
                                    foreg, NULL, BLITFLAG_COLORALPHA, NULL);
                GUI_BlockDelete(foreg);
#endif
                dsk_theme_close(bmpTheme);
                // LogMI("Simple Slider Piece x = %d, y = %d, bmp = %d", locat.x, locat.y, i - 1);
            }
        }
        for (; i <= desc->cls.bmp_nr; i++) {
            if (0 == getStartPoint(&locat, &desc->cls.start_point, desc->cls.direc, i, desc->cls.bmp_nr, &desc->cls.puzzle)) {
                bmpTheme = dsk_theme_open(desc->cls.bgbmp_piece);
                bmpData = dsk_theme_hdl2buf(bmpTheme);
#ifdef REGULAR_DRAW
                GUI_BMP_Draw(bmpData, locat.x + rect->x, locat.y + rect->y);
#else
                eLIBs_memcpy(desc->puzzleData, (void *)((int)bmpData + BITMAPHEADERSIZE), desc->puzzleDataSize);
                foreg = GUI_BlockCreateFrom(NULL, desc->cls.puzzle.width, desc->cls.puzzle.height, desc->puzzleData, 0);
                GUI_BlockBitBlit(backbg, locat.x + rect->x, locat.y + rect->y,
                                    foreg, NULL, BLITFLAG_COLORALPHA, NULL);
                GUI_BlockDelete(foreg);
#endif
                dsk_theme_close(bmpTheme);
                // LogMI("Simple Slider Piece x = %d, y = %d", locat.x, locat.y);
            }
        }
    } else if (desc->drew_position < blocks) {
        for (i = 1 + desc->drew_position; i <= blocks; i++) {
            if (0 == getStartPoint(&locat, &desc->cls.start_point, desc->cls.direc, i, desc->cls.bmp_nr, &desc->cls.puzzle)) {
                bmpTheme = dsk_theme_open(desc->bmps[i - 1]);
                bmpData = dsk_theme_hdl2buf(bmpTheme);
#ifdef REGULAR_DRAW
                GUI_BMP_Draw(bmpData, locat.x + rect->x, locat.y + rect->y);
#else
                eLIBs_memcpy(desc->puzzleData, (void *)((int)bmpData + BITMAPHEADERSIZE), desc->puzzleDataSize);
                foreg = GUI_BlockCreateFrom(NULL, desc->cls.puzzle.width, desc->cls.puzzle.height, desc->puzzleData, 0);
                GUI_BlockBitBlit(backbg, locat.x + rect->x, locat.y + rect->y,
                                    foreg, NULL, BLITFLAG_COLORALPHA, NULL);
                GUI_BlockDelete(foreg);
#endif
                dsk_theme_close(bmpTheme);
                // LogMI("Simple Slider Piece x = %d, y = %d, bmp = %d", locat.x, locat.y, i - 1);
            }
        }
    } else if (desc->drew_position > blocks) {
        for (i = desc->drew_position; i > blocks; i--) {
            if (0 == getStartPoint(&locat, &desc->cls.start_point, desc->cls.direc, i, desc->cls.bmp_nr, &desc->cls.puzzle)) {
                bmpTheme = dsk_theme_open(desc->cls.bgbmp_piece);
                bmpData = dsk_theme_hdl2buf(bmpTheme);
#ifdef REGULAR_DRAW
                GUI_BMP_Draw(bmpData, locat.x + rect->x, locat.y + rect->y);
#else
                eLIBs_memcpy(desc->puzzleData, (void *)((int)bmpData + BITMAPHEADERSIZE), desc->puzzleDataSize);
                foreg = GUI_BlockCreateFrom(NULL, desc->cls.puzzle.width, desc->cls.puzzle.height, desc->puzzleData, 0);
                GUI_BlockBitBlit(backbg, locat.x + rect->x, locat.y + rect->y,
                                    foreg, NULL, BLITFLAG_COLORALPHA, NULL);
                GUI_BlockDelete(foreg);
#endif
                dsk_theme_close(bmpTheme);
                // LogMI("Simple Slider Piece x = %d, y = %d", locat.x, locat.y);
            }
        }
    }
    desc->drew_position = blocks;
#ifndef REGULAR_DRAW
    GUI_BlockDelete(backbg);
#endif
    return 0;
}
Пример #3
0
/*
****************************************************************************************************
*
*             DEV_KEY_Ioctrl
*
*  Description:
*       DRV_irkey_MIoctrl
*
*  Parameters:
*
*  Return value:
*       EPDK_OK
*       EPDK_FAIL
****************************************************************************************************
*/
__s32 DEV_PowerIoctrl(__hdle hPower, __u32 cmd, __s32 aux, void *pbuffer)
{
    __s32 ret = EPDK_OK;
    switch(cmd)
    {
        case DRV_POWER_CMD_READ_REG:
        {
            __inf("drvpower DRV_POWER_CMD_READ_REG start\n");
            ret = 0xff;
            break;
        }

        case DRV_POWER_CMD_WRITE_REG:
        {
            __inf("drvpower DRV_POWER_CMD_WRITE_REG start\n");

            break;
        }

        case DRV_POWER_CMD_POWER_ON:
        {
            break;
        }
        
        case DRV_POWER_CMD_POWER_OFF:
        {
            __s32           cpu_sr;
            volatile __u32 *tmpAddr;
            __u32           tmpData;
            
            __wrn("power off enter....\n");
			__close_lcd();	
            if (hPowerOn)
			{
				esPINS_WritePinData(hPowerOn, 0, NULL);
			}
			
            //正常状况下,系统已关机,下面的代码是不会执行到,
            //为了防止插USB或充电器时无法关机的问题,
            //直接将CPU挂死在死循环内.
            
            //关掉watch-dog,防止系统复位
            tmpAddr = TMRC_WACHDOG_CTL_ADDR;
            tmpData = *tmpAddr;
            tmpData &= ~(1 << TMRC_WATCH_DOG_EN_BIT);
            *tmpAddr = tmpData;
            
            //关掉中断
            //ENTER_CRITICAL(cpu_sr);//中断不关,否则定时器不起作用
            
            //防止编译器warning
            //cpu_sr = cpu_sr;
            
            //死循环,挂死CPU
            __wrn("power no use, cpu dumping\n");

            DEV_PowerOnProcess();
            
            while (1)
            {                
                ;
            }
            //unreached
            //break;
        }

        case DRV_POWER_CMD_INT_ENABLE:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_INT_DISABLE:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_INT_QUERY:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_INT_CLEAR:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_VOUT_GET:
        {
            __inf("drvpower DRV_POWER_CMD_VOUT_GET start\n");

            if(aux == POWER_VOL_LDO1)
            {
                if(ldo1set)
                {
                    ret = Vldo1_set;
                }
                else
                {
                    ret = Vldo1_set;
                }
            }
            else if((aux == POWER_VOL_DCDC1) || (aux == POWER_VOL_DCDC2))
            {
                if(aux == POWER_VOL_DCDC1)
                {
                    ret = Vdcdc1_set;
                }
                else
                {
                    if(dc2set)
                    {
                        __inf("drvpower DRV_POWER_CMD_VOUT_GET dc2set\n");
                        ret =  Vdcdc2_set;
                    }
                    else
                    {
                        ret = Vdcdc2_set;
                    }
                }
            }
            else if((aux == POWER_VOL_LDO2) || (aux == POWER_VOL_LDO3) || (aux == POWER_VOL_DCDC3))
            {
                if(aux == POWER_VOL_LDO2)
                {
                    ret = Vldo2_set;
                }
                else if(aux == POWER_VOL_DCDC3)
                {
                    ret = Vdcdc3_set;
                }
                else
                {
                    ret = Vldo3_set ;
                }
            }
            else if(aux == POWER_VOL_LDO4)
            {
                if(aux == POWER_VOL_LDO4)
                {
                    ret = Vldo4_set ;
                }
                else
                {
                    ret = Vldo5_set ;
                }
            }
            __inf("drvpower DRV_POWER_CMD_VOUT_GET dc2 return %d\n",ret);

            break;
        }

        case DRV_POWER_CMD_VOUT_SET:
        {
            __u32       tmp;

            tmp = (__u32)pbuffer;
            if((aux == POWER_VOL_DCDC1) || (aux == POWER_VOL_DCDC2))
            {
                if(aux == POWER_VOL_DCDC1)
                {
                    Vdcdc1_set = tmp;
                }
                else
                {
                    Vdcdc2_set = tmp;
                }
            }
            else if(aux == POWER_VOL_LDO1)
            {
                __wrn("LDO1 Voltage  cant be set!\n");
                Vldo1_set = tmp;
            }
            else if((aux == POWER_VOL_LDO2) || (aux == POWER_VOL_LDO3) || (aux ==POWER_VOL_DCDC3))
            {
                if(aux == POWER_VOL_DCDC3)
                {
                    Vdcdc3_set = tmp;
                }
                else if(aux == POWER_VOL_LDO2)
                {
                    Vldo2_set = tmp;
                }
                else
                {
                    Vldo3_set = tmp;
                }
            }
            else if(aux == POWER_VOL_LDO4)
            {
                if(aux == POWER_VOL_LDO4)
                {
                    Vldo4_set = tmp;
                }
                else
                {
                    Vldo5_set = tmp;
                }
            }
            ret = EPDK_OK;

            break;
        }
        case DRV_POWER_CMD_VSTS_GET:
        {
            break;
        }

        case DRV_POWER_CMD_VSTS_SET:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_PWREPT_GET:
        {
            break;
        }
        case DRV_POWER_CMD_PWREPT_SET:
        {
            break;
        }

        case DRV_POWER_CMD_BATADC_GET:
        {
            __drv_power_battery_status_t1   *bat_sts = (__drv_power_battery_status_t1 *)pbuffer;

            bat_sts->bat_vol = 2500;
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_BATADC_SET:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_GET_BAT_RDC:
        {
            ret = 500;
            break;
        }

        case DRV_POWER_CMD_BATSTATUS_TABLE_GET:
        {
            __drv_power_battery_status_t2  *bat_sts = (__drv_power_battery_status_t2 *)pbuffer;

            bat_sts->battery_exist = 0x0;
            bat_sts->dcin_valid = 0x01;
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_DCINADC_GET:
        {
            __drv_power_dcin_status_t   *dcin_sts = (__drv_power_dcin_status_t *)pbuffer;

            dcin_sts->dcin_exist = 0x01;
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_DCINADC_SET:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_CHARGE_GET:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_CHARGE_SET:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_BASIC_STATUS:
        {
            __drv_power_basic_status_t  *pbasic = (__drv_power_basic_status_t *)pbuffer;

            pbasic->bat_exist   = 0;
            pbasic->bat_charge_status =0;
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_IPS_GET:
        {
            ret = EPDK_OK;
            break;
        }

        case DRV_POWER_CMD_IPS_SET:
        {
            ret = EPDK_OK;
            break;
        }
        case DRV_POWER_CMD_GET_DCIN:
        {
            __drv_power_battery_status_t3 *pstatus = (__drv_power_battery_status_t3 *)pbuffer;
			if (hChargeStatus)
			{
			//__msg(".......111111..........pstatus->charge_status=%d......\n",pstatus->charge_status);
				pstatus->charge_status = esPINS_ReadPinData(hChargeStatus, NULL);
			//	__msg(".......222..........pstatus->charge_status=%d......\n",pstatus->charge_status);
			//	__inf("charge status is %d\n", pstatus->charge_status);
				return EPDK_OK;
			}
			else
			{
				//__msg("charge status pin is null failed\n");
	            pstatus->charge_status = 0x0;
				__msg(".......3333333..........pstatus->charge_status=%d......\n",pstatus->charge_status);
				return EPDK_FAIL;
			}
        }
        case DRV_POWER_CMD_GET_FUELGUAGE:
        {
            __drv_power_fuelguage_t *pbat = (__drv_power_fuelguage_t *)pbuffer;
            eLIBs_memcpy(pbat, &fuelguage, sizeof(__drv_power_fuelguage_t));
           // __wrn("pbat->rest_vol=%d\n", pbat->rest_vol);
            ret = EPDK_OK;
            break;
        }
        case DRV_POWER_CMD_SET_USB_CHARGE:
        {
            ret = EPDK_OK;
            break;
        }
        case DRV_POWER_CMD_SET_STANDBY_FLAG:
        {
            __inf("set sdandby to  1 \n");
            break;
        }
        default:
        {
            __wrn("Unkonwn Command...\n");
            ret = EPDK_FAIL;
            break;
        }
    }
    return ret;
}
Пример #4
0
/**
 * 通过回调函数的方式取触摸屏消息
 */
static __s32 tp_msg_cb(void *msg)
{	
	__msrv_msg_t	*pmsg;
	__u8 error;
	
	__u32 i;
	__input_event_packet_t *pPacket;
    __input_event_t        *pEventFrame;
	__input_event_t        pEvent_type;
	__input_event_t        pEvent_x;
	__input_event_t        pEvent_y;
	__input_event_t        pEvent_speed_dir;
	__input_event_t        pEvent_speed_val;
	
    if (msg == NULL)
    {
        __msg("invalid argument for call back\n");
        return EPDK_FAIL;
    }
    
    /* dump packet events */
    pPacket = (__input_event_packet_t *)msg;
    if (pPacket->event_cnt <= 0 || pPacket->event_cnt > INPUT_MAX_EVENT_NR)
    {
        __msg("invalid event count number\n");
        return EPDK_FAIL;
    }
	//__inf("\n------------------------------------------------\n");
	for (i = 0; i < pPacket->event_cnt; i++)
	{
		pEventFrame = &(pPacket->events[i]);
		/*__inf("Event %d: type = %d, code = %d, value = %d\n", i + 1,
                                                                 pEventFrame->type,
                                                                 pEventFrame->code,
                                                                 pEventFrame->value
                                                                 );*/
		if(pEventFrame->type == EV_ABS) 
		{
			if(pEventFrame->code == ABS_MISC)
			{			
				eLIBs_memcpy(&pEvent_type, pEventFrame, sizeof(__input_event_t));
			}
			else if(pEventFrame->code == ABS_X)
			{			
				eLIBs_memcpy(&pEvent_x, pEventFrame, sizeof(__input_event_t));					
			}
			else if(pEventFrame->code == ABS_Y)
			{			
				eLIBs_memcpy(&pEvent_y, pEventFrame, sizeof(__input_event_t));					
			}
			else if(pEventFrame->code == ABS_RUDDER)
			{			
				eLIBs_memcpy(&pEvent_speed_dir, pEventFrame, sizeof(__input_event_t));					
			}
			else if(pEventFrame->code == ABS_BRAKE)
			{			
				eLIBs_memcpy(&pEvent_speed_val, pEventFrame, sizeof(__input_event_t));					
			}	
		}
		else if(pEventFrame->type == EV_SYN)
		{
			break;
		}
	}				
	//__inf("\n------------------------------------------------\n");	
	
	esKRNL_SemPend(emit_ctr.p_array_sem, 0, &error);
	pmsg = get_msg_buf(&emit_ctr);	
	esKRNL_SemPost(emit_ctr.p_array_sem);
	
	pmsg->type 	= GUI_MSG_TOUCH;
	switch( pEvent_type.value)
	{
		case EV_TP_PRESS_START:
		{				
			pmsg->id 	= GUI_MSG_TOUCH_DOWN;					
			pmsg->data 	= (pEvent_y.value<<16) + pEvent_x.value;				
			pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value;
			last_touch_action = GUI_MSG_TOUCH_DOWN;
			break;
		}	
		case EV_TP_PRESS_MOVE:
			pmsg->id 	= GUI_MSG_TOUCH_MOVE;						
			pmsg->data 	= (pEvent_y.value<<16) + pEvent_x.value;				
			pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value;
			last_touch_action = GUI_MSG_TOUCH_MOVE;
			break;		
		case EV_TP_PINCH_IN:
			pmsg->id 	= GUI_MSG_TOUCH_ZOOMIN;						
			pmsg->data 	= (pEvent_y.value<<16) + pEvent_x.value;				
			pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value;
			last_touch_action = GUI_MSG_TOUCH_ZOOMIN;
			break;
		case EV_TP_PINCH_OUT:
			pmsg->id 	= GUI_MSG_TOUCH_ZOOMOUT;						
			pmsg->data 	= (pEvent_y.value<<16) + pEvent_x.value;				
			pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value;
			last_touch_action = GUI_MSG_TOUCH_ZOOMOUT;
			break;
		case EV_TP_PRESS_HOLD:
			pmsg->id 	= last_touch_action;		
			pmsg->data 	= (pEvent_y.value<<16) + pEvent_x.value;				
			pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value;
			break;
			
		case EV_TP_ACTION_NULL:			
  	 	case EV_TP_ACTION_CLICK:				
   		case EV_TP_ACTION_DOWN:				
   		case EV_TP_ACTION_UP:				 
    	case EV_TP_ACTION_LEFT:				
   		case EV_TP_ACTION_RIGHT:			
    	case EV_TP_ACTION_ANTICLOCKWISE:		
    	case EV_TP_ACTION_CLOCKWISE:			
    	case EV_TP_ACTION_LD2RU:				
    	case EV_TP_ACTION_RU2LD:      		   
    	case EV_TP_ACTION_LU2RD:	    		
    	case EV_TP_ACTION_RD2LU:
    		pmsg->id 	= GUI_MSG_TOUCH_UP;    
			pmsg->data 	= (pEvent_y.value<<16) + pEvent_x.value;				
			pmsg->reserved = (pEvent_speed_dir.value<<16) + pEvent_speed_val.value;
    		break; 	
    	default:
    		__msg("cannot identify message: %x\n", pEvent_type.value);
    		return EPDK_FALSE;		    
	}
	__msg("------------------------------------------------\n");	
	__msg("pmsg->type = %d, pmsg->id = %d\n", pmsg->type, pmsg->id);
	__msg("x = %d, y = %d\n", LOSWORD(pmsg->data), HISWORD(pmsg->data));
	__msg("------------------------------------------------\n");
	esKRNL_QPost(emit_ctr.psys_msg_queue, pmsg);
	
	return EPDK_TRUE;
}
Пример #5
0
void  mem_cpy(void* dst, void* src, u32 size)
{
	eLIBs_memcpy(dst, src, size);
}