///////////////////////////////////////////////////////////////////////////// // Clear Screen // IN: - // OUT: returns < 0 on errors ///////////////////////////////////////////////////////////////////////////// s32 APP_LCD_Clear(void) { s32 error = 0; u8 x, y; // use default font MIOS32_LCD_FontInit((u8 *)GLCD_FONT_NORMAL); // select all LCDs error |= MIOS32_LCD_CursorSet(0, 0); // send data for(y=0; y<APP_LCD_HEIGHT; y=y+4) { error |= APP_LCD_GCursorSet(0, y); MIOS32_BOARD_J15_DataSet(0x00); MIOS32_BOARD_J15_RS_Set(1); // RS pin used to control DC for(x=0; x<APP_LCD_WIDTH; ++x){ MIOS32_BOARD_J15_SerDataShift(0x00); } } // set X=0, Y=0 error |= MIOS32_LCD_CursorSet(0, 0); return error; }
///////////////////////////////////////////////////////////////////////////// // Clear Screen // IN: - // OUT: returns < 0 on errors ///////////////////////////////////////////////////////////////////////////// s32 APP_LCD_Clear(void) { s32 error = 0; u8 x, y; // use default font MIOS32_LCD_FontInit((u8 *)GLCD_FONT_NORMAL); // send data for(y=0; y<8; ++y) { error |= MIOS32_LCD_CursorSet(0, y); // select all LCDs #if APP_LCD_USE_J10_FOR_CS MIOS32_BOARD_J10_Set(0x00); #else MIOS32_BOARD_J15_DataSet(0x00); #endif MIOS32_BOARD_J15_RS_Set(1); // RS pin used to control DC for(x=0; x<128; ++x) MIOS32_BOARD_J15_SerDataShift(0x00); } // set X=0, Y=0 error |= MIOS32_LCD_CursorSet(0, 0); return error; }
///////////////////////////////////////////////////////////////////////////// // Sends data byte to LCD // IN: data byte in <data> // OUT: returns < 0 on errors ///////////////////////////////////////////////////////////////////////////// s32 APP_LCD_Data(u8 data) { // select LCD depending on current cursor position // THIS PART COULD BE CHANGED TO ARRANGE THE 8 DISPLAYS ON ANOTHER WAY u8 line = mios32_lcd_y / APP_LCD_HEIGHT; u8 row = (mios32_lcd_x % (2*APP_LCD_WIDTH)) / APP_LCD_WIDTH; u8 cs = 2*line + row; if( cs >= 8 ) return -1; // invalid CS line // chip select and DC #if APP_LCD_USE_J10_FOR_CS MIOS32_BOARD_J10_Set(~(1 << cs)); #else MIOS32_BOARD_J15_DataSet(~(1 << cs)); #endif MIOS32_BOARD_J15_RS_Set(1); // RS pin used to control DC // send data MIOS32_BOARD_J15_SerDataShift(data); // increment graphical cursor ++mios32_lcd_x; // if end of display segment reached: set X position of all segments to 0 if( (mios32_lcd_x % APP_LCD_WIDTH) == 0 ) { APP_LCD_Cmd(0x00); // set X=0 APP_LCD_Cmd(0x10); } return 0; // no error }
///////////////////////////////////////////////////////////////////////////// // Sends command byte to LCD // IN: command byte in <cmd> // OUT: returns < 0 on errors ///////////////////////////////////////////////////////////////////////////// s32 APP_LCD_Cmd(u8 cmd) { // select all LCDs MIOS32_BOARD_J15_DataSet(0x00); MIOS32_BOARD_J15_RS_Set(0); // RS pin used to control DC // send command MIOS32_BOARD_J15_SerDataShift(cmd); return 0; // no error }
///////////////////////////////////////////////////////////////////////////// // Sends command byte to LCD // IN: command byte in <cmd> // OUT: returns < 0 on errors ///////////////////////////////////////////////////////////////////////////// s32 APP_LCD_Cmd(u8 cmd) { // select all LCDs #if APP_LCD_USE_J10_FOR_CS MIOS32_BOARD_J10_Set(0x00); #else MIOS32_BOARD_J15_DataSet(0x00); #endif MIOS32_BOARD_J15_RS_Set(0); // RS pin used to control DC MIOS32_BOARD_J15_SerDataShift(cmd); return 0; // no error }
///////////////////////////////////////////////////////////////////////////// // Sends data byte to LCD // IN: data byte in <data> // OUT: returns < 0 on errors ///////////////////////////////////////////////////////////////////////////// s32 APP_LCD_Data(u8 data) { // select LCD depending on current cursor position // THIS PART COULD BE CHANGED TO ARRANGE THE 8 DISPLAYS ON ANOTHER WAY u8 line = 0; if( mios32_lcd_y >= 3*APP_LCD_HEIGHT ) line = 3; else if( mios32_lcd_y >= 2*APP_LCD_HEIGHT ) line = 2; else if( mios32_lcd_y >= 1*APP_LCD_HEIGHT ) line = 1; u8 row = 0; if( mios32_lcd_x >= 1*APP_LCD_WIDTH ) row = 1; u8 cs = 2*line + row; if( cs >= 8 ) return -1; // invalid CS line // chip select and DC MIOS32_BOARD_J15_DataSet(~(1 << cs)); MIOS32_BOARD_J15_RS_Set(1); // RS pin used to control DC // send data MIOS32_BOARD_J15_SerDataShift(data); //MIOS32_DELAY_Wait_uS(40); // exact 10 uS delay // increment graphical cursor ++mios32_lcd_x; // if end of display segment reached: set X position of all segments to 0 if( (mios32_lcd_x % APP_LCD_WIDTH) == 0 ) { APP_LCD_Cmd(0x00); // Set lower nibble to 0 return APP_LCD_Cmd(0x10); // Set upper nibble to 0 } return 0; // no error }