// ========================================================================= // 函数功能:画状态条(最右边) // 输入参数:dispara:代表的显示参数 // 输出参数: // 返回值 : // 说明 :一般而言dispara的所有菜单项因为屏幕的原因不可能同时显示出来,此状态条 // 代表当前操作的菜单项在同层所有菜单中的位置 // ========================================================================= void drawstatecontent_9cell_rightside(struct menu_displaypara *dispara) { u8 numOp=0; u8 numTotal=0; s32 lengthT=0; s32 LengthE=0; struct tagRectangle state_area={0,0,0,0}; numOp=CalMenuitemNumber(dispara->OperatingMenuitem); numTotal=CalMenuitemNum(dispara->FVisualMenuitem); //复原颜色 state_area.left=dispara->CurWin->right-dispara->CurWin->left-cn_column_space; state_area.right=dispara->CurWin->right-dispara->CurWin->left; state_area.top=0; state_area.bottom=dispara->CurWin->bottom-dispara->CurWin->top; GK_ApiFillRect(dispara->CurWin, &state_area, color_back, 0,CN_FILLRECT_MODE_N,0); //标志当前的可视区 lengthT=state_area.bottom-state_area.top; //提高精度; lengthT=lengthT*1000; LengthE=(lengthT+numTotal-1)/numTotal; state_area.top=(numOp-1)*LengthE; state_area.top=(state_area.top)/1000; state_area.bottom=(numOp)*LengthE; state_area.bottom=(state_area.bottom)/1000; GK_ApiFillRect(dispara->CurWin, &state_area, color_light, 0,CN_FILLRECT_MODE_N,0); GK_ApiSyncShow(CN_TIMEOUT_FOREVER); return; }
static void draw_cursor(struct tagGkWinRsc *desktop,int x,int y) { GK_ApiLineto(desktop,x,y,x,y-20+1,CN_COLOR_RED,CN_R2_COPYPEN,0); //上 GK_ApiLineto(desktop,x,y,x,y+20-1,CN_COLOR_RED,CN_R2_COPYPEN,0); //下 GK_ApiLineto(desktop,x,y,x+20-1,y,CN_COLOR_RED,CN_R2_COPYPEN,0);//右 GK_ApiLineto(desktop,x,y,x-20+1,y,CN_COLOR_RED,CN_R2_COPYPEN,0); //左 GK_ApiSyncShow(1000*mS); }
//----触摸屏校准--------------------------------------------------------------- //功能: 触摸屏的尺寸可能与液晶可显示区域不完全一致,安装也可能有偏差,需要计算 // 校准系数和偏移量。为获得更高精度,使用定点小数。 //参数: display_name,本触摸屏对应的显示器名(资源名) //返回: 无 //----------------------------------------------------------------------------- void touch_ratio_adjust(struct tagGkWinRsc *desktop) { struct tagSingleTouchMsg touch_xyz0,touch_xyz1; FILE *touch_init; s32 limit_left,limit_top,limit_right,limit_bottom,pen_down_time,step; if((touch_init = fopen("sys:\\touch_init.dat","r")) != NULL) { fread(&ts_cfg_data,sizeof(TS_CFG_DATA),1,touch_init); } else { limit_left = desktop->limit_left; limit_top = desktop->limit_top; limit_right = desktop->limit_right; limit_bottom = desktop->limit_bottom; // GK_ApiCreateGkwin(desktop,desktop,limit_left,limit_top,limit_right,limit_bottom, // CN_COLOR_WHITE,CN_WINBUF_BUF,"&tg_touch_adjust",CN_R3_SRCCOPY,0); // GK_ApiSetPrio(desktop,-1,CN_GK_SYNC); GK_ApiFillWin(desktop,CN_COLOR_WHITE,0); GK_ApiDrawText(desktop,NULL,NULL,limit_left+10,limit_top+50, "触摸屏矫正",21,CN_COLOR_WHITE,CN_R2_COPYPEN,0); GK_ApiDrawText(desktop,NULL,NULL,limit_left+10,limit_top+70, "请准确点击十字交叉点",21,CN_COLOR_WHITE,CN_R2_COPYPEN,0); step=0; while(step<4) { s32 adx,ady; if(step>0) { clr_cursor(desktop,ts_cal_ref_pos[step-1][0],ts_cal_ref_pos[step-1][1]); } draw_cursor(desktop,ts_cal_ref_pos[step][0],ts_cal_ref_pos[step][1]); while(ts_is_down()) { Djy_DelayUs(100*mS); } pen_down_time=0; while(1) { if(ts_is_down()) { ts_get_data_raw(&adx,&ady); if(pen_down_time++>5) { break; } } else { pen_down_time=0; } Djy_DelayUs(100*mS); } switch(step) { case 0: ts_cfg_data.LUAdx =adx; ts_cfg_data.LUAdy =ady; break; case 1: ts_cfg_data.RUAdx =adx; ts_cfg_data.RUAdy =ady; break; case 2: ts_cfg_data.RDAdx =adx; ts_cfg_data.RDAdy =ady; break; case 3: ts_cfg_data.LDAdx =adx; ts_cfg_data.LDAdy =ady; break; } printf("ts_cal[%d]: %04X,%04X\r\n",step,adx,ady); step++; } GK_ApiFillWin(desktop,CN_COLOR_WHITE,0); GK_ApiSyncShow(1000*mS); while(ts_is_down()) { Djy_DelayUs(100*mS); } Djy_DelayUs(500*mS); // GK_DestroyWin(desktop); touch_init = fopen("sys:\\touch_init.dat","w+"); fwrite(&ts_cfg_data,sizeof(TS_CFG_DATA),1,touch_init); } fclose(touch_init); }
void djy_main(void) { // djyfs_file *fp; static char *banner_text = "---- DJYOS ----"; u8 flip_inc1 = -2,flip_inc2 = 2,flip_inc4 = -2,flip_inc8 = 2; struct tagInputDeviceMsg *input_msg; struct tagRectBitmap bitmap; struct tagRectangle Grad; u32 r=0; s32 touch_x=0, touch_y=0; u8 alpha = 0x80; if( sqlite3_initialize()) printf("initial sqlite3 error"); test_sqlite1(0); desktop = GK_ApiGetDesktop("sim_display"); GK_ApiCreateGkwin(desktop, &wnd_banner, 0, 0, 240, 25, CN_COLOR_BLUE, CN_WINBUF_BUF, "banner", CN_SYS_PF_DISPLAY,0,0,0); GK_ApiDrawText(&wnd_banner,NULL,NULL, 60, 5, banner_text, strnlen(banner_text, 100),CN_COLOR_RED,CN_R2_COPYPEN,0); // body GK_ApiCreateGkwin(desktop, &wnd_body, 0, 25, 240, 290, CN_COLOR_RED, CN_WINBUF_BUF, "body",CN_SYS_PF_DISPLAY,0,0, 0); #if 0 GK_ApiCreateGkwin(&wnd_body, &wnd_body_selector, 0, 0, 240, 20, CN_COLOR_RED+CN_COLOR_GREEN, CN_WINBUF_BUF, "body selector", CN_SYS_PF_DISPLAY,0,0,0); GK_ApiLineto(&wnd_body_selector, 60, 0, 60, 20, CN_COLOR_BLACK, CN_R2_COPYPEN, 0); GK_ApiLineto(&wnd_body_selector, 120, 0, 120, 20, CN_COLOR_BLACK, CN_R2_COPYPEN, 0); GK_ApiLineto(&wnd_body_selector, 180, 0, 180, 20, CN_COLOR_BLACK, CN_R2_COPYPEN, 0); #endif bitmap.bm_bits = (u8*)gImage_rgb565_240x180; bitmap.width = 240; bitmap.height = 180; bitmap.linebytes = 480; bitmap.PixelFormat = CN_SYS_PF_RGB565; bitmap.ExColor = CN_COLOR_WHITE; GK_ApiDrawBitMap(&wnd_body, &bitmap, 0, 20, 0,0,CN_TIMEOUT_FOREVER); bitmap.bm_bits = (u8*)acindex_4; bitmap.width = 128; bitmap.height = 128; bitmap.linebytes = 64; bitmap.PixelFormat = CN_SYS_PF_PALETTE4; bitmap.ExColor = (ptu32_t)Colorsindex_4; GK_ApiDrawBitMap(&wnd_body, &bitmap, 0, 140,0,0, CN_TIMEOUT_FOREVER); bitmap.bm_bits = (u8*)acTulips_128_96; bitmap.width = 128; bitmap.height = 96; bitmap.linebytes = 128; bitmap.PixelFormat = CN_SYS_PF_PALETTE8; bitmap.ExColor = (ptu32_t)ColorsTulips; GK_ApiDrawBitMap(&wnd_body, &bitmap, 40, 20, 0,0,CN_TIMEOUT_FOREVER); bitmap.bm_bits = (u8*)acJellyfish_128_96; bitmap.width = 128; bitmap.height = 96; bitmap.linebytes = 128; bitmap.PixelFormat = CN_SYS_PF_PALETTE8; bitmap.ExColor = (ptu32_t)ColorsJellyfish; GK_ApiDrawBitMap(&wnd_body, &bitmap, 80, 116,0,0, CN_TIMEOUT_FOREVER); GK_ApiCreateGkwin(&wnd_body, &wnd_gray8, 0, 20, 64, 68, CN_COLOR_BLUE, CN_WINBUF_BUF, "gray8",CN_SYS_PF_DISPLAY,0,0, 0); GK_ApiCreateGkwin(&wnd_body, &wnd_gray4, 0,68,64,116, CN_COLOR_WHITE, CN_WINBUF_BUF, "gray4",CN_SYS_PF_DISPLAY,0,0, 0); GK_ApiCreateGkwin(&wnd_body, &wnd_gray2, 0,116,64,164, CN_COLOR_RED, CN_WINBUF_BUF, "gray2",CN_SYS_PF_DISPLAY,0,0, 0); GK_ApiCreateGkwin(&wnd_body, &wnd_gray1, 0,164,64,212, CN_COLOR_RED, CN_WINBUF_BUF, "gray1",CN_SYS_PF_DISPLAY,0,0, 0); bitmap.bm_bits = (u8*)gImage_gray8_64x48; bitmap.width = 64; bitmap.height = 48; bitmap.linebytes = 64; bitmap.PixelFormat = CN_SYS_PF_GRAY8; bitmap.ExColor = CN_COLOR_WHITE; GK_ApiDrawBitMap(&wnd_gray8, &bitmap, 0, 0, 0,0,CN_TIMEOUT_FOREVER); bitmap.bm_bits = (u8*)gImage_gray4_64x48; bitmap.width = 64; bitmap.height = 48; bitmap.linebytes = 32; bitmap.PixelFormat = CN_SYS_PF_GRAY4; bitmap.ExColor = CN_COLOR_WHITE; GK_ApiDrawBitMap(&wnd_gray4, &bitmap, 0, 0, 0,0,CN_TIMEOUT_FOREVER); bitmap.bm_bits = (u8*)gImage_gray2_64x48; bitmap.width = 64; bitmap.height = 48; bitmap.linebytes = 16; bitmap.PixelFormat = CN_SYS_PF_GRAY2; bitmap.ExColor = CN_COLOR_WHITE; GK_ApiDrawBitMap(&wnd_gray2, &bitmap, 0, 0,0,0, CN_TIMEOUT_FOREVER); bitmap.bm_bits = (u8*)gImage_gray1_64x48; bitmap.width = 64; bitmap.height = 48; bitmap.linebytes = 8; bitmap.PixelFormat = CN_SYS_PF_GRAY1; bitmap.ExColor = CN_COLOR_WHITE; GK_ApiDrawBitMap(&wnd_gray1, &bitmap, 0, 0, 0,0,CN_TIMEOUT_FOREVER); // bottom GK_ApiCreateGkwin(desktop, &wnd_bottom, 0, 295, 240, 320, CN_COLOR_BLUE, CN_WINBUF_BUF, "bottom",CN_SYS_PF_DISPLAY,0,0, 0); GK_ApiFillWin(desktop, CN_COLOR_BLACK, CN_TIMEOUT_FOREVER); // ±³¾°Í¿ºÚ GK_ApiSyncShow(CN_TIMEOUT_FOREVER); GDD_Demo(); //´Ëº¯Êý²»»á·µ»Ø Grad.left = 0; Grad.top = 0; Grad.right = 64; Grad.bottom = 48; while(1) { flip_inc1 -=2; flip_inc2 +=2; flip_inc4 -=2; flip_inc8 +=2; GK_ApiMoveWin(&wnd_gray1, flip_inc1, 164, 0); GK_ApiMoveWin(&wnd_gray2, flip_inc2, 116,0); GK_ApiMoveWin(&wnd_gray4, flip_inc4, 68,0); GK_ApiMoveWin(&wnd_gray8, flip_inc8, 20,CN_TIMEOUT_FOREVER); Grad.left = 0; Grad.top = 0; Grad.right = 64; Grad.bottom = 48; GK_ApiFillRect(&wnd_gray1,&Grad,CN_COLOR_BLUE,CN_COLOR_RED,CN_FILLRECT_MODE_H,0); GK_ApiFillRect(&wnd_gray2,&Grad,CN_COLOR_GREEN,CN_COLOR_BLUE,CN_FILLRECT_MODE_V,0); GK_ApiFillRect(&wnd_gray4,&Grad,CN_COLOR_RED+CN_COLOR_BLUE,CN_COLOR_RED+CN_COLOR_GREEN,CN_FILLRECT_MODE_SN,0); GK_ApiFillRect(&wnd_gray8,&Grad,CN_COLOR_WHITE,CN_COLOR_RED,CN_FILLRECT_MODE_SP,0); Grad.left = 70; Grad.top = 60; Grad.right = 200; Grad.bottom = 100; GK_ApiFillRect(&wnd_body,&Grad,CN_COLOR_WHITE,CN_COLOR_RED,CN_FILLRECT_MODE_SP,0); // GK_ApiSyncShow(CN_TIMEOUT_FOREVER); dis_wnd_bottom_text(&wnd_bottom); GK_ApiDrawText(&wnd_body,NULL,NULL, 0, 0,"flash", 5,CN_COLOR_WHITE,CN_R2_XORPEN,0); GK_ApiDrawText(&wnd_body,NULL,NULL, 80, 120,"flash", 5,CN_COLOR_WHITE,CN_R2_XORPEN,0); GK_ApiSyncShow(CN_TIMEOUT_FOREVER); Djy_WaitEvttPop(Djy_MyEvttId(),NULL,200*mS); } }