:: Home :: Code Snippets :: Drivers :: Projects :: About ::
 Main Menu
  Home
  Code Snippets
  About

 Open Drivers
 _build - Embedded build information
 qTask - Queued Task Manager
 PIC32 mcompat - PIC32 mcompat
 EA-DOGM - LCD Display Driver

 Open Projects
 fplCore - Self contained controller
 oLogic 1.4 - NEW Logic Viewer
 oLogic - Oscilloscope Logic Viewer
 SSX32 - Serial Servo Driver
 uProfiler - uController uProfiller



 Sources
Prototyping
  PicStuff
  Sparkfun

Equipment
  Saelig
  Tequipment

Supply House
  Jameco
  Mouser
  Digikey
  Allied Electronics
  Clearwater Technologies

Miscellaneous
  BCM
  N34D Blog

LCD Bar Graph - Bar Graph routines for the EA-DOGM text LCD display.

This will allow you to display a custom bar graph on the EA-DOGM text LCD displays.

 Code Snippet
// note: this calls the functions in the EA-DOGM driver

// sets up the programmable chr's for use as a bar graph
//uses custom chrs 1 to 5
void gBarGraphIni(void)
{
   int i;
   for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00001000 + i,0b0010000); }
   for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00010000 + i,0b0011000); }
   for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00011000 + i,0b0011100); }
   for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00100000 + i,0b0011110); }
   for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00101000 + i,0b0011111); }
}

void gBarGraph(char row, unsigned int16 pos, unsigned int16 max)
{
   int8 i,m,r;
   int32 n;

   eaDogM_SetPos(row,0);
   n = ( (pos * 80) / max );
   m = n / 5; // i love integer math, 6/5 = 1 not 1.2 :)
   r = n - (m * 5); // get the remainder
   for (i=0; i<m; i++) { eaDogM_WriteChr(5); } // block chr
   eaDogM_WriteChr(r);
   for (i=(m+1); i<16; i++) { eaDogM_WriteChr(0x20); } // end spaces
}

void gAdvBarGraph(char row, char col, char width, unsigned int16 pos, unsigned int16 max)
{
   int8 i,m,r;
   int32 n;

   eaDogM_SetPos(row,col);
   n = ( (pos * (width*5)) / max );
   m = n / 5; // i love integer math, 6/5 = 1 not 1.2 :)
   r = n - (m * 5); // get the remainder
   for (i=0; i<m; i++) { eaDogM_WriteChr(5); } // block chr
   eaDogM_WriteChr(r);
   for (i=(m+1); i<width; i++) { eaDogM_WriteChr(0x20); } // end spaces
}






:: Home :: Resources :: PIC Microcontrollers ::
:: 10F :: 12F :: 16F :: 18F :: 24F :: 24H :: 30F :: 33F ::
(C) Copyright 2009 mculabs.com - contact: info@mculabs.com
0.0026979446411133