CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Driver for GU112x16_7806 Noritake Itron VFD display

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
Fram_fr



Joined: 29 Oct 2008
Posts: 13

View user's profile Send private message

Driver for GU112x16_7806 Noritake Itron VFD display
PostPosted: Thu Nov 06, 2008 5:22 am     Reply with quote

Hi all,

here is a driver which contains a set of useful routines for use with a Noritake-Itron GU112X16-7806 graphical Vacuum Fluorescent Display (VFD)in parallel interface.

Code:

//------------------------------------------------------------------------
//
// File:        VFD_GU112x16_7806.c
//
// Purpose:     Graphical VFD routines.
//
// Description: This file contains a set of useful routines for use with
//      a Noritake-Itron GU112X16-7806 graphical Vacuum Fluorescent
//      Display (VFD)in parallel interface.
//------------------------------------------------------------------------*/

#define set_tris_lcd(x) set_tris_d(x) //port D used for DATA D0 to D7

//************************************************************************//
// BRIGHTNESS LEVEL - According to datasheet to configure VFD brightness
//************************************************************************//
#DEFINE brightness_25  0x03
#DEFINE brightness_50  0x02
#DEFINE brightness_75  0x01
#DEFINE brightness_100 0x00

//************************************************************************//
// write a byte to the VFD cmd register
//************************************************************************//
void vfd_write_cmd(unsigned char c)
{
   unsigned char busy;
   set_tris_lcd(0xff); // set data port to input
   output_high(VFD_RW);      // read
   output_low(VFD_RS);
   
   do {
      output_high(VFD_EN);
      busy = (input_d() & 0x80);
      output_low(VFD_EN);
      } while (busy);
   
   set_tris_lcd(0x00); // set data port to output
   output_low(VFD_RW);       // write
   output_low(VFD_RS);
   output_d(c);
   output_high(VFD_EN);
   output_low(VFD_EN);
}

//************************************************************************//
// write a byte to the VFD data register
//************************************************************************//
void vfd_write_data(unsigned char c)
{
   unsigned char busy;
   set_tris_lcd(0xff); // set data port to input
   output_high(VFD_RW);      // read
   output_low(VFD_RS);
   
   do {
      output_high(VFD_EN);
      busy = (input_d() & 0x80);
      output_low(VFD_EN);
      } while (busy);
     
   set_tris_lcd(0x00); // set data port to output
   output_low(VFD_RW);      // write
   output_high(VFD_RS);
   output_d(c);
   output_high(VFD_EN);
   output_low(VFD_EN);
}

//************************************************************************//
//    Clear and home the LCD     
//************************************************************************//
void vfd_clear()
{
   vfd_write_cmd(0x01);
   delay_ms (10);
}

//************************************************************************//
//    Cursor return home     
//************************************************************************//
void vfd_cursor_home()
{
   vfd_write_cmd(0x02);
   delay_ms (10);
}

//************************************************************************// 
// initialise the VFD - put into 8 bit mode
//************************************************************************//
void vfd_init(unsigned char brightness)
{
   output_low(VFD_EN);
   vfd_write_cmd (0x30);
   delay_ms (10);
   vfd_write_cmd (0x30);
   delay_ms (10);
   vfd_write_cmd (0x30);
   delay_ms (10);
   vfd_write_cmd (0x30);   // Eight bit mode
   delay_ms (10);   
   vfd_write_data(brightness);   // Set luminance
   vfd_write_cmd(0x06);
   vfd_write_cmd(0x0c);
   vfd_clear();      // Clear screen
}

//************************************************************************//
// Set luminance of the VFD
//************************************************************************//
void vfd_set_brightness(unsigned char brightness)
{
   output_low(VFD_EN);
   vfd_write_cmd (0x30);   // Eight bit mode
   vfd_write_data(brightness);   // Set luminance=75%
}

//************************************************************************//
// Set the VFD font
//
//   'A' 4x6 mini font
//   'B' 5x7 Katakana font
//   'C' 10x14 Katakana font
//   'b' 5x7 European font
//   'c' 10x14 European font
//   '1' 1 pixel inter-character spacing
//   '2' 2 pixel inter-character spacing
//************************************************************************//
void vfd_font(unsigned char font)
{
   vfd_write_cmd(0xf2);
   vfd_write_data(font);   
}   

void vfd_font_small()
{
    vfd_font('1');
    vfd_font('A');
}

void vfd_font_medium()
{
    vfd_font('1');
    vfd_font('b');
}

void vfd_font_large()
{
    vfd_font('2');
    vfd_font('c');
}

//************************************************************************//
// write a string of chars to the VFD
//************************************************************************//
void vfd_puts(unsigned char text)
{
      vfd_write_data(text);
}

//************************************************************************//
// Go to the specified position
//
//   xpos = 0-111, ypos = 0-15
//************************************************************************//
void vfd_goto(unsigned char xpos, unsigned char ypos)
{
   vfd_write_cmd(0xf0);
   vfd_write_data(xpos);   
   vfd_write_data(ypos);
   delay_us(1);
}

//************************************************************************//
// Set the VFD area
//
//   x1, y1 = left top of area
//   x2, y2 = right bottom of area
//
//   Commands:
//      'I' Invert area
//      'F' Fill area
//      'C' Clear area
//      'O' Set outline
//      'o' Clear outline
//      'H' Write horizontal graphical data with horizontal cursor movement
//      'V' Write vertical graphical data with vertical cursor movement
//      'h' Write horizontal graphical data with vertical cursor movement
//      'v' Write vertical graphical data with horizontal cursor movement
//************************************************************************//
void vfd_area(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char cmd)
{
   vfd_write_cmd(0xf1);
   vfd_write_data(x1);   
   vfd_write_data(y1);   
   vfd_write_data(x2);   
   vfd_write_data(y2);   
   vfd_write_data(cmd);   
}   

//************************************************************************//
// display shift of "count" positions to the right
//************************************************************************//
void vfd_shift_right(unsigned char count) // low speed shift
{
   int i;
   for (i=0; i<=count; i++)
      {
      vfd_write_cmd(0x1C);
      delay_ms(30);
      }
}

void vfd_shift_right2(unsigned char count) // normal speed shift
{
   int i;
   for (i=0; i<=count; i++)
      {
      vfd_write_cmd(0x1C);
      delay_ms(20);
      }
}

void vfd_shift_right3(unsigned char count) // high speed shift
{
   int i;
   for (i=0; i<=count; i++)
      {
      vfd_write_cmd(0x1C);
      delay_ms(10);
      }
}

//************************************************************************//
// display shift of "count" positions to the left
//************************************************************************//
void vfd_shift_left(unsigned char count) // low speed shift
{
   int i;
   for (i=0; i<=count; i++)
      {
      vfd_write_cmd(0x18);
      delay_ms(30);
      }
}

void vfd_shift_left2(unsigned char count) // normal speed shift
{
   int i;
   for (i=0; i<=count; i++)
      {
      vfd_write_cmd(0x18);
      delay_ms(20);
      }
}

void vfd_shift_left3(unsigned char count) // high speed shift
{
   int i;
   for (i=0; i<=count; i++)
      {
      vfd_write_cmd(0x18);
      delay_ms(10);
      }
}

//************************************************************************//
// enable or disable the display
//  *   0 = disable, 1 = enable
//************************************************************************//
void vfd_display_control(unsigned char on_off)
{
   vfd_write_cmd(0x0F);
   vfd_write_data(on_off);
}
   
//************************************************************************//
// enable or disable the flashing bloc cursor
//  *   0 = disable, 1 = enable
//************************************************************************//
void vfd_display_cursor(unsigned char cursor)
{
   vfd_write_cmd(0x08);
   vfd_write_data(cursor);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group