//****************剪切图片 //剪切第picnum幅的图片,放在x1,y1,x2,y2在屏幕显示的区域坐标,x,y为要剪切图片的左上角坐标 void CutPicture(unsigned char picnum,unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,unsigned short x,unsigned short y) { unsigned long cutaddress, picnumtemp; Write_Dir(0X06,0X00);//FLASH频率设定 if(picnum<61) { Write_Dir(0X05,0X06);//FLASH设置 ac cs1,2c cs0 Write_Dir(0Xc7,0X01); picnumtemp=picnum; } if(picnum>60&picnum<121) { Write_Dir(0X05,0X86); //ac Write_Dir(0Xc7,0X00); picnumtemp=picnum-60; } Write_Dir(0XBF,0X02);//FLASH设置 Active_Window(x1,x2,y1,y2); MemoryWrite_Position(x1,y1);//内存写入位置 cutaddress=(picnumtemp-1)*262144+y*960+x*2; DMA_Start_address_setting(cutaddress); DMA_block_mode_size_setting(x2-x1+1,y2-y1+1,480); Write_Dir(0XBF,0X03);//FLASH设置 Chk_DMA_Busy(); }
void updateCurrentLayer() { if(bDisplayInitialized == 0) return; xSemaphoreTake(xDispSemaphore, portMAX_DELAY); { if(currScreen->bAnimationEnabled) { switch(currScreen->drawScn) { case LoadingAnim: SetUpdateLayer(); Active_Window(0,479,0,271); Background_color(color_black); Text_color(color_white); //Show_String18(gArialBlack24, "Loading", 206 ,116); (currScreen->currFrame)++; if(currScreen->currFrame < currScreen->numberFrames) DisplayImageBlockMode(gProgressBar.start_addr +(currScreen->currFrame * 4872),153, 145, gProgressBar.image_width, 14); else currScreen->currFrame = 0x00; break; default: break; } } xSemaphoreGive(xDispSemaphore); } }
//****************显示flash图片(VS32240M35一个FLASH可以存储107幅图片,可以增加一个FLASH,即214幅图片) void displaypicture(unsigned char picnum) { unsigned int picnumtemp; Write_Dir(0X06,0X00);//FLASH频率设定 if(picnum<61) { Write_Dir(0X05,0X07);//FLASH设置 ac cs1,2c cs0 Write_Dir(0Xc7,0X01); picnumtemp=picnum; } if(picnum>60&picnum<121) { Write_Dir(0X05,0X87); //ac Write_Dir(0Xc7,0X00); picnumtemp=picnum-60; } Write_Dir(0XBF,0X02);//FLASH设置 Active_Window(0,479,0,271); //Write_Dir(0x41,(1-g_u8LcdLayer)); MemoryWrite_Position(0,0);//内存写入位置 DMA_Start_address_setting(262144*(picnumtemp-1)); DMA_block_mode_size_setting(480,272,480); Write_Dir(0XBF,0X03);//FLASH设置 Chk_DMA_Busy(); }
void Soft_Reset(void) { xSemaphoreTake(xDispSemaphore, portMAX_DELAY); { LCD_Reset(); Delay1ms(500); LCD_Initial(); Two_Layers(); Delay1ms(100); Active_Window(0,479,0,271); Background_color(color_black); Text_color(color_white); Text_Cursor_Disable(); Layer1_Visible(); Write_To_Bank1(); Clear_Active_Window(); Write_To_Bank2(); Clear_Full_Window(); Display_ON(); //backlight on for RAiO RA8875_demo_board_V2 PWM1_enable(); PWM1_duty_cycle(0xff); Text_color(color_white); Background_color(color_black); xSemaphoreGive(xDispSemaphore); } }
void RXLCD_clear (unsigned char Color) { Active_Window(0,479,0,271);//设置区域显示窗口 Text_Foreground_Color1(0xffff);//前景颜色设定 Text_Background_Color1(0xffff);//背景颜色设定 Write_Dir(0X8E,0X80);//开始清屏(显示窗口) Delay10ms(5); }
void DisplayImageDirectWrite(const uint8_t* array,uint length, uint startx , uint starty, uint width, uint height) { int i; Write_Dir(0x40,0x00); Active_Window(startx,startx + width-1,starty,starty+height-1);//Set the work window size MemoryWrite_Position(0,0);//Memory write position LCD_CmdWrite(0x02);//start data write //112X140 dot for(i=0;i<length;i++) { LCD_DataWrite(array[i]); Chk_Busy(); } }
/////////////LCM initial void LCD_Initial(void) { PLL_ini(); LCD_CmdWrite(0x10); // LCD_DataWrite(0x0C); // 65k 8bit mcu interface LCD_CmdWrite(0x04); //PCLK LCD_DataWrite(0x81); // Delay1ms(1); //Horizontal set LCD_CmdWrite(0x14); //HDWR//Horizontal Display Width Setting Bit[6:0] LCD_DataWrite(0x63);//Horizontal display width(pixels) = (HDWR + 1)*8 LCD_CmdWrite(0x15);//Horizontal Non-Display Period Fine Tuning Option Register (HNDFTR) LCD_DataWrite(0x00);//Horizontal Non-Display Period Fine Tuning(HNDFT) [3:0] LCD_CmdWrite(0x16); //HNDR//Horizontal Non-Display Period Bit[4:0] LCD_DataWrite(0x03);//Horizontal Non-Display Period (pixels) = (HNDR + 1)*8 LCD_CmdWrite(0x17); //HSTR//HSYNC Start Position[4:0] LCD_DataWrite(0x03);//HSYNC Start Position(PCLK) = (HSTR + 1)*8 LCD_CmdWrite(0x18); //HPWR//HSYNC Polarity ,The period width of HSYNC. LCD_DataWrite(0x0B);//HSYNC Width [4:0] HSYNC Pulse width(PCLK) = (HPWR + 1)*8 //Vertical set LCD_CmdWrite(0x19); //VDHR0 //Vertical Display Height Bit [7:0] LCD_DataWrite(0xdf);//Vertical pixels = VDHR + 1 LCD_CmdWrite(0x1a); //VDHR1 //Vertical Display Height Bit [8] LCD_DataWrite(0x01);//Vertical pixels = VDHR + 1 LCD_CmdWrite(0x1b); //VNDR0 //Vertical Non-Display Period Bit [7:0] LCD_DataWrite(0x20);//Vertical Non-Display area = (VNDR + 1) LCD_CmdWrite(0x1c); //VNDR1 //Vertical Non-Display Period Bit [8] LCD_DataWrite(0x00);//Vertical Non-Display area = (VNDR + 1) LCD_CmdWrite(0x1d); //VSTR0 //VSYNC Start Position[7:0] LCD_DataWrite(0x16);//VSYNC Start Position(PCLK) = (VSTR + 1) LCD_CmdWrite(0x1e); //VSTR1 //VSYNC Start Position[8] LCD_DataWrite(0x00);//VSYNC Start Position(PCLK) = (VSTR + 1) LCD_CmdWrite(0x1f); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0] LCD_DataWrite(0x01);//VSYNC Pulse Width(PCLK) = (VPWR + 1) Active_Window(0,799,0,479); LCD_CmdWrite(0x8a);//PWM setting LCD_DataWrite(0x80); LCD_CmdWrite(0x8a);//PWM setting LCD_DataWrite(0x81);//open PWM LCD_CmdWrite(0x8b);//Backlight brightness setting LCD_DataWrite(0xff);//Brightness parameter 0xff-0x00 }
void CutPictrue(uchar picnum,uint x1,uint y1,uint x2,uint y2,unsigned long x,unsigned long y) {unsigned long cutaddress;uchar picnumtemp; Write_Dir(0X06,0X00);//FLASH frequency setting Write_Dir(0X05,0Xac);//FLASH setting picnumtemp=picnum; Write_Dir(0XBF,0X02);//FLASH setting Active_Window(x1,x2,y1,y2); MemoryWrite_Position(x1,y1);//Memory write position cutaddress=(picnumtemp-1)*261120+y*960+x*2; DMA_Start_address_setting(cutaddress); DMA_block_mode_size_setting(x2-x1+1,y2-y1+1,480); Write_Dir(0XBF,0X03);//FLASH setting Chk_DMA_Busy(); }
/* Private functions ---------------------------------------------------------*/ void DisplayImageBlockMode(uint startAddress,uint startx , uint starty, uint width, uint height) { Active_Window(startx,startx+width-1,starty,starty+height-1); MemoryWrite_Position(startx,starty);//Memory write position SROM_CLK_DIV(0X00);//FLASH frequency setting Serial_ROM_select1(); Serial_ROM_Address_set_24bit(); Select_Serial_Waveform_mode0(); SERIAL_ROM_Read_Cycle_4bus(); SERIAL_ROM_DMA_mode(); SERIAL_ROM_Dual_mode1(); DMA_Start_address_setting(startAddress);//DMA Start address setting DMA_block_mode_size_setting(width,height,width); DMA_Block_mode();//FLASH setting DMA_Start_enable();//FLASH setting Chk_DMA_Busy(); }
void WriteString(unsigned char *Str,u16 x, u16 y, u16 Color, u8 Size, u8 transperent ) { RXLCD_EditCurrent(); Active_Window(0,479,0,271); Size = Size<<6; Write_Dir(0x21,0x20);//?????? Write_Dir(0x06,0x03);//??FLASH?? Write_Dir(0x2F,0x81);//????IC Write_Dir(0x05,0xA8);//????IC Write_Dir(0x22,0x80|(transperent<<6));//????IC Write_Dir(0x2E,Size);//??????16x16/??1 Text_Foreground_Color1(Color);//?????? FontWrite_Position(x,y);//?????? String(Str); Write_Dir(0x21,0x00);//????? Write_Dir(0x2F,0x00);//????? }
// initialization of RAIO8870 // ---------------------------------------------------------- void RAIO_init( void ) { static uint8_t PLL_Initial_Flag = 0; // *************** PLL settings (System Clock) if ( !PLL_Initial_Flag ) // wait until PLL is ready { PLL_Initial_Flag = 1; // set Flag to avoid repeated PLL init RAIO_SetRegister( PLLC1, 0x07 ); // set sys_clk bcm2835_delayMicroseconds( 200 ); RAIO_SetRegister( PLLC2, 0x03 ); // set sys_clk bcm2835_delayMicroseconds( 200 ); RAIO_SetRegister( PWRR, 0x01 ); // Raio software reset ( bit 0 ) set RAIO_SetRegister( PWRR, 0x00 ); // Raio software reset ( bit 0 ) set to 0 delay( 100 ); // *************** color modes (color depths) #ifdef CM_65K // System Configuration Register RAIO_SetRegister( SYSR, 0x0A ); // digital TFT // parallel data out // no external memory // 8bit memory data bus // 16bpp 65K color // 16bit MCU-interface (data) RAIO_SetRegister( DPCR, 0x00 ); // one layer #elif defined(CM_4K) // System Configuration Register RAIO_SetRegister( SYSR, 0x06 ); // digital TFT // parallel data out // no external memory // 8bit memory data bus // 12bpp 4K color // 16bit MCU-interface (data) RAIO_SetRegister( DPCR, 0x80 ); // two layers RAIO_SetRegister( MWCR1, BankNo_WR ); RAIO_SetRegister( LTPR0, BankNo_RD ); #else #error "color_mode not defined" #endif } // *************** horizontal settings // 0x27+1 * 8 = 320 pixel RAIO_SetRegister( HDWR , (DISPLAY_WIDTH / 8) - 1 ); RAIO_SetRegister( HNDFTR, 0x02 ); // Horizontal Non-Display Period Fine Tuning // HNDR , Horizontal Non-Display Period Bit[4:0] // Horizontal Non-Display Period (pixels) = (HNDR + 1)*8 RAIO_SetRegister( HNDR, 0x03 ); // 0x06 RAIO_SetRegister( HSTR, 0x04 ); //HSTR , HSYNC Start Position[4:0], HSYNC Start Position(PCLK) = (HSTR + 1)*8 0x02 // HPWR , HSYNC Polarity ,The period width of HSYNC. // 1xxxxxxx activ high 0xxxxxxx activ low // HSYNC Width [4:0] HSYNC Pulse width // (PCLK) = (HPWR + 1)*8 RAIO_SetRegister( HPWR, 0x03 ); // 0x00 // ********************* vertical settings // 0x0EF +1 = 240 pixel RAIO_SetRegister( VDHR0 , ( (DISPLAY_HEIGHT-1) & 0xFF ) ); RAIO_SetRegister( VDHR1 , ( (DISPLAY_HEIGHT-1) >> 8) ); // VNDR0 , Vertical Non-Display Period Bit [7:0] // Vertical Non-Display area = (VNDR + 1) // VNDR1 , Vertical Non-Display Period Bit [8] // Vertical Non-Display area = (VNDR + 1) RAIO_SetRegister( VNDR0, 0x10 ); RAIO_SetRegister( VNDR1, 0x00 ); // VPWR , VSYNC Polarity ,VSYNC Pulse Width[6:0] // VSYNC , Pulse Width(PCLK) = (VPWR + 1) RAIO_SetRegister( VPWR, 0x00 ); // *************** miscellaneous settings // active Window Active_Window( 0, DISPLAY_WIDTH-1, 0, DISPLAY_HEIGHT-1 ); // PCLK fetch data on rising edge RAIO_SetRegister( PCLK, 0x00 ); // Backlight dimming RAIO_SetBacklightPWMValue(50); Text_Background_Color( COLOR_WHITE ); // memory clear with background color RAIO_SetRegister( MCLR, 0x81 ); TFT_wait_for_raio(); RAIO_SetRegister( IODR, 0x07 ); RAIO_SetRegister( PWRR, 0x80 ); }
//-----模块初始化代码----------建议客户直接移植---------------------------// void RXLCD_init(void) { Reset(); Delay10ms(5); RA8870_PLL_ini(); Write_Command(0x10); //SYSR bit[4:3]=00 256 color bit[2:1]= 00 8bit MPU interface Write_Data(0x0f); // 1x 64k color 1x 16bit Write_Command(0x04); //PCLK Write_Data(0x03); // Delay10ms(1); //Horizontal set Write_Command(0x14); //HDWR//Horizontal Display Width Setting Bit[6:0] Write_Data(0x3b); //Horizontal display width(pixels) = (HDWR + 1)*8 0x27 Write_Command(0x15); //HNDFCR//Horizontal Non-Display Period fine tune Bit[3:0] Write_Data(0x02); //(HNDR + 1)*8 +HNDFCR Write_Command(0x16); //HNDR//Horizontal Non-Display Period Bit[4:0] Write_Data(0x03); //Horizontal Non-Display Period (pixels) = (HNDR + 1)*8 Write_Command(0x17); //HSTR//HSYNC Start Position[4:0] Write_Data(0x01); //HSYNC Start Position(PCLK) = (HSTR + 1)*8 Write_Command(0x18); //HPWR//HSYNC Polarity ,The period width of HSYNC. Write_Data(0x03); //HSYNC Width [4:0] HSYNC Pulse width(PCLK) = (HPWR + 1)*8 //Vertical set Write_Command(0x19); //VDHR0 //Vertical Display Height Bit [7:0] Write_Data(0x0f); //Vertical pixels = VDHR + 1 0xef Write_Command(0x1a); //VDHR1 //Vertical Display Height Bit [8] Write_Data(0x01); //Vertical pixels = VDHR + 1 0x00 Write_Command(0x1b); //VNDR0 //Vertical Non-Display Period Bit [7:0] Write_Data(0x0f); //Vertical Non-Display area = (VNDR + 1) Write_Command(0x1c); //VNDR1 //Vertical Non-Display Period Bit [8] Write_Data(0x00); //Vertical Non-Display area = (VNDR + 1) Write_Command(0x1d); //VSTR0 //VSYNC Start Position[7:0] Write_Data(0x0e); //VSYNC Start Position(PCLK) = (VSTR + 1) Write_Command(0x1e); //VSTR1 //VSYNC Start Position[8] Write_Data(0x06); //VSYNC Start Position(PCLK) = (VSTR + 1) Write_Command(0x1f); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0] Write_Data(0x01); //VSYNC Pulse Width(PCLK) = (VPWR + 1) Write_Command(0x20); Write_Data(0x80); Write_Dir(0x52,0xc1);//设置为缓冲卷动模式 Write_Dir(0x40,0x80);//设置为文字模式 Write_Dir(0x41,0x01); Layer1_Visible(); Write_Dir(0xf0,0x04);//开启中断 Write_Dir(0x71,0x04);//设置为4线触摸屏 Write_Dir(0x70,0xB2);//开启触摸功能,设置触摸参数 Write_Dir(0xf1,0x04);//clear INT state 確保上次觸碰後 TP_interrupt 清除 Write_Command(0x8c);//PWM控制设置 Write_Data(0x80);//开启PWM Write_Command(0x8c);//PWM控制设置 Write_Data(0x81);//开启PWM Write_Command(0x8d);//背光亮度 Write_Data(0x80);//亮度参数0xff-0x00 Active_Window(0,479,0,271);//设置区域显示窗口 Text_Foreground_Color1(0x0000);//前景颜色设定 Text_Background_Color1(0xffff);//背景颜色设定 Write_Dir(0X8E,0X80);//开始清屏(显示窗口) Delay10ms(1); Write_Dir(0X01,0X80);//开启显示 }
void DrawScreen(screen_enum_t scn) { int i,j; int sWidth = 0; if(bDisplayInitialized == 0) return; xSemaphoreTake(xDispSemaphore, portMAX_DELAY); { SetDrawingLayer(); switch(scn) { case EmpLoggedInScn: Background_color(color_black); Text_color(color_white); Clear_Active_Window(); Show_String18(gArial18, "Client Name:", 55,5); Show_String18(gArial24, "Vigelette, George", 55,28); // time while the font is still loaded Show_String18(gArial24, "11:32 AM", 385,28); // time while the font is still loaded DisplayImageBlockMode(g3gIcon20.start_addr ,400, 3, g3gIcon20.image_width, g3gIcon20.image_height); // // Layer1_Visible(); // Write_To_Bank1(); // Active_Window(0,479,0,271); // battery DisplayImageBlockMode(gBatteryIcons.start_addr,427, 3, gBatteryIcons.image_width, 20); // buttons // Row 1 DisplayImageBlockMode(gBtnEndShift.start_addr,20, 63, gBtnEndShift.image_width, gBtnEndShift.image_height); DisplayImageBlockMode(gBtnTimesheet.start_addr,250, 63, gBtnTimesheet.image_width, gBtnTimesheet.image_height); // Row 2 DisplayImageBlockMode(gBtnTaskList.start_addr,20, 123, gBtnTaskList.image_width, gBtnTaskList.image_height); DisplayImageBlockMode(gBtnSchedule.start_addr,250, 123, gBtnSchedule.image_width, gBtnSchedule.image_height); // Row 3 DisplayImageBlockMode(gBtnMessages.start_addr,20, 183, gBtnMessages.image_width, gBtnMessages.image_height); DisplayImageBlockMode(gBtnExit.start_addr,250, 183, gBtnExit.image_width, gBtnExit.image_height); sWidth = MeasureString(gArial24, "Jan 21, 2013"); Show_String18(gArial24, "Jan 21, 2013", (480 - sWidth)/2 ,250); break; case EmpLoggedOutScn: break; case ClientScn: break; case ActivationScn: break; case TestScn: // bte fill Background_color(color_black); Text_color(color_white); Graphic_Mode(); BTE_Size_setting(15,68); BTE_ROP_Code(0xcc); //set BTE solid fill for(i=0;i<32;i++) { Text_Foreground_Color(i,0,0); BTE_Source_Destination(0,i*15,0,0); BTE_enable(); Chk_Busy_BTE(); Text_Foreground_Color(0,i*2,0); BTE_Source_Destination(0,i*15,0,68); BTE_enable(); Chk_Busy_BTE(); Text_Foreground_Color(0,0,i); BTE_Source_Destination(0,i*15,0,136); BTE_enable(); Chk_Busy_BTE(); Text_Foreground_Color(i,i*2,i); BTE_Source_Destination(0,i*15,0,204); BTE_enable(); Chk_Busy_BTE(); } break; case ConfigurationScn: Internal_CGROM(); Font_size_16x16_8x16(); Background_color(color_blue); Text_color(color_white); Clear_Active_Window(); Font_Coordinate(5,5); Show_String("Safe-Link Device Configuration ",0); break; case AuthenticatingScn: break; case MessageListScn: break; case NewMessageScn: break; case ReadMessageScn: break; case TaskListScn: break; case TaskViewScn: break; case ScheduleScn: break; case TimeApproveScn: break; case LockedScn: Active_Window(0,479,0,271); DisplayImageBlockMode(gDeviceLockedScreen.start_addr, 0,0,gDeviceLockedScreen.image_width, gDeviceLockedScreen.image_height); break; case SplashScn: Active_Window(0,479,0,271); DisplayImageBlockMode(gsplashScreen.start_addr, 0,0,gsplashScreen.image_width, gsplashScreen.image_height); Text_color(color_white); Geometric_Coordinate(212,268,108,164); Draw_square(); Text_color(color_black); Geometric_Coordinate(213,267,109,163); Draw_square_fill(); Active_Window(0,479,0,271); DisplayImageBlockMode(gCycle.start_addr, 216,112,gCycle.image_width, gCycle.image_height); break; case LoadingAnim: Active_Window(0,479,0,271); Background_color(color_black); Text_color(color_white); Graphic_Mode(); Clear_Active_Window(); Show_String18(gArialBlack24, "Loading", 206 ,116); DisplayImageBlockMode(gProgressBar.start_addr,153, 145, gProgressBar.image_width, 14); break; default: DisplayImageBlockMode(gsplashScreen.start_addr, 0,0,gsplashScreen.image_width, gsplashScreen.image_height); break; } ShowNextScene(); xSemaphoreGive(xDispSemaphore); } }