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

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

 Open Projects
 oLogic - Oscilloscope Logic Viewer
 oLogic 1.4 - NEW Logic Viewer
 SSX32 - Serial Servo Driver



 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
/vhost/mculabs/snippet_db/lcd-gui/lcd-gui.c
    1 // note: this calls the functions in the EA-DOGM driver
    2 
    3 // sets up the programmable chr's for use as a bar graph
    4 //uses custom chrs 1 to 5
    5 void gBarGraphIni(void)
    6 {
    7    int i;
    8    for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00001000 + i,0b0010000); }
    9    for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00010000 + i,0b0011000); }
   10    for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00011000 + i,0b0011100); }
   11    for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00100000 + i,0b0011110); }
   12    for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00101000 + i,0b0011111); }
   13 }
   14 
   15 void gBarGraph(char row, unsigned int16 pos, unsigned int16 max)
   16 {
   17    int8 i,m,r;
   18    int32 n;
   19 
   20    eaDogM_SetPos(row,0);
   21    n = ( (pos * 80) / max );
   22    m = n / 5; // i love integer math, 6/5 = 1 not 1.2 :)
   23    r = n - (m * 5); // get the remainder
   24    for (i=0; i<m; i++) { eaDogM_WriteChr(5); } // block chr
   25    eaDogM_WriteChr(r);
   26    for (i=(m+1); i<16; i++) { eaDogM_WriteChr(0x20); } // end spaces
   27 }
   28 
   29 void gAdvBarGraph(char row, char col, char width, unsigned int16 pos, unsigned int16 max)
   30 {
   31    int8 i,m,r;
   32    int32 n;
   33 
   34    eaDogM_SetPos(row,col);
   35    n = ( (pos * (width*5)) / max );
   36    m = n / 5; // i love integer math, 6/5 = 1 not 1.2 :)
   37    r = n - (m * 5); // get the remainder
   38    for (i=0; i<m; i++) { eaDogM_WriteChr(5); } // block chr
   39    eaDogM_WriteChr(r);
   40    for (i=(m+1); i<width; i++) { eaDogM_WriteChr(0x20); } // end spaces
   41 }






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