Example #1
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;
}
Example #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);

  // 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;
}
Example #3
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 = 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
}
Example #4
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
}
Example #5
0
/////////////////////////////////////////////////////////////////////////////
// Display-port specific setting of RS
/////////////////////////////////////////////////////////////////////////////
static void RS_Set(u8 level)
{
   if (current_lcd_device == 0)
      MIOS32_BOARD_J15_RS_Set(level);
   else
   {
      if (level)
         lastdata |= 0b00000010;
      else
         lastdata &= 0b11111101;

      MIOS32_BOARD_J15_DataSet(lastdata);
   }
}
Example #6
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
#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
}
Example #7
0
/////////////////////////////////////////////////////////////////////////////
// Initializes application specific VFD driver
// IN: <mode>: optional configuration
// OUT: returns < 0 if initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 APP_LCD_Init(u32 mode)
{
   MIOS32_BOARD_J15_PortInit(APP_LCD_OUTPUT_MODE);

   MIOS32_BOARD_J15_RS_Set(0);
   MIOS32_BOARD_J15_RW_Set(0);
   APP_LCD_Cmd(0b00110011);
   APP_LCD_Cmd(0b00110010);

   APP_LCD_Cmd(0b00101000); // 4bit, 2 lines
   APP_LCD_Cmd(0b00001100); // display on, cursor off, char blinking off
   APP_LCD_Cmd(0b00000110); // entry mode
   APP_LCD_Cmd(0b00000001); // clear

   return 0;
}
Example #8
0
/////////////////////////////////////////////////////////////////////////////
// Hack: reinitializes the screens after some time, to clean up 
//       potentially garbled screens
//
/////////////////////////////////////////////////////////////////////////////
void reinit()
{
   mios32_sys_time_t t = MIOS32_SYS_TimeGet();
   charcount++;
   if (t.seconds > last_reinit_seconds || charcount > 500)
   {
      charcount = 0;
      last_reinit_seconds = t.seconds;
      
      MIOS32_BOARD_J15_RS_Set(0);
      MIOS32_BOARD_J15_RW_Set(0);
      APP_LCD_Cmd(0b00110011);
      APP_LCD_Cmd(0b00110010);

      APP_LCD_Cmd(0b00101000); // 4bit, 2 lines
      APP_LCD_Cmd(0b00001100); // display on, cursor off, char blinking off
      APP_LCD_Cmd(0b00000110); // entry mode
   }
}
Example #9
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
}