예제 #1
0
파일: app_lcd.c 프로젝트: gillspice/mios32
/////////////////////////////////////////////////////////////////////////////
// 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;
}
예제 #2
0
/////////////////////////////////////////////////////////////////////////////
// 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;
}
예제 #3
0
파일: app_lcd.c 프로젝트: gillspice/mios32
/////////////////////////////////////////////////////////////////////////////
// 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
}
예제 #4
0
/////////////////////////////////////////////////////////////////////////////
// Sends command byte to VFD
// IN: command byte in <cmd>
// OUT: returns < 0 if display not available or timed out
/////////////////////////////////////////////////////////////////////////////
s32 APP_LCD_Cmd(u8 cmd)
{
   current_lcd_device = mios32_lcd_device;
   
   RS_Set(0);
   RW_Set(0);
   E_Set(1);
   lastdata = (lastdata & 0x0F) + (cmd & 0xF0);
   MIOS32_BOARD_J15_DataSet(lastdata);
   E_Set(0);

   RS_Set(0);
   RW_Set(0);
   E_Set(1);
   lastdata = (lastdata & 0x0F) + (cmd << 4);
   MIOS32_BOARD_J15_DataSet(lastdata);
   E_Set(0);
   
   return 0; // no error
}
예제 #5
0
/////////////////////////////////////////////////////////////////////////////
// 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
}
예제 #6
0
/////////////////////////////////////////////////////////////////////////////
// Sends data byte to VFD
// IN: data byte in <data>
// OUT: returns < 0 if display not available or timed out
/////////////////////////////////////////////////////////////////////////////
s32 APP_LCD_Data(u8 data)
{
   current_lcd_device = mios32_lcd_device;
   
   RS_Set(1);
   RW_Set(0);
   E_Set(1);
   lastdata = (lastdata & 0x0F) + (data & 0xF0);
   MIOS32_BOARD_J15_DataSet(lastdata);
   E_Set(0);

   RS_Set(1);
   RW_Set(0);
   E_Set(1);
   lastdata = (lastdata & 0x0F) + (data << 4);
   MIOS32_BOARD_J15_DataSet(lastdata);
   E_Set(0);

   reinit();

   return 0; // no error
}
예제 #7
0
/////////////////////////////////////////////////////////////////////////////
// Display-port specific setting of RW
/////////////////////////////////////////////////////////////////////////////
static void RW_Set(u8 level)
{
   if (current_lcd_device == 0)
      MIOS32_BOARD_J15_RW_Set(level);
   else
   { 
      if (level)
         lastdata |= 0b00000100;
      else
         lastdata &= 0b11111011;

      MIOS32_BOARD_J15_DataSet(lastdata);
   }
}
예제 #8
0
/////////////////////////////////////////////////////////////////////////////
//! This function services the row selection lines at J15 and the 
//! LED output lines at J5A/B
//! It should be called from the APP_SRIO_ServicePrepare()
//! \return < 0 on errors
/////////////////////////////////////////////////////////////////////////////
s32 BLM_CHEAPO_PrepareCol(void)
{
  if( ++selected_row >= 8 )
    selected_row = 0;

  // selection lines at J15
  u8 selection_mask = (1 << selected_row);
  MIOS32_BOARD_J15_DataSet(selection_mask);

  // LED columns at J5A/B
  MIOS32_BOARD_J5_Set(led_row[selected_row]);

  return 0; // no error
}
예제 #9
0
파일: app_lcd.c 프로젝트: gillspice/mios32
/////////////////////////////////////////////////////////////////////////////
// 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
}
예제 #10
0
/////////////////////////////////////////////////////////////////////////////
// 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
}