===== Description =====
This demo shows how to write some bar graphs to a LCD2S serial LCD display using the lcd2c.h and nz_lcd2s.c driver. It writes "Example Bargraph" to first line of LCD display. Columns 1 to 8 of second line is initialized with bar graphs 1 to 8 pixels high. Column 9 contains a varying height bar graph, that changes height every 100ms. It also flashes the system LED. To add LCD2S support to a project, the following must be done:
- Add nz_lcd2s.c to the project, this is the main LCD2S driver file.
- The following additional files are required by lcd2s.c, and must be added to the project: nz_circularBufferPwr2.c, nz_helpers.c, nz_netcruzer.c and nz_serI2C.c
- Add "NZ_I2C1_ENABLE" to projdefs.h file.
- In code, initialize LCD2S. Ensure to delay 300ms from power up. For example: delay_ms(300); lcdInit();
- In projdefs.h, do any LCD2S, I2C or other configuration required. This is done by copying the configuration section from the *.h files to projdefs.h. Nothing required, defaults will work!
- All done! Can now use lcd2c.h driver functions! For example, to write to LCD2S: lcdDisplayString(0, "\fHello\nWorld, Again!");
===== Required Hardware =====
This project can be run on any of our SBC66 Netcruzer boards. For prototyping, we recommend combining this board with a Prototyping Board, like the PT66ECI for example. This low cost prototyping board makes all the I/O ports of the SBC66 board available via marked labels on the PCB. It also provides a reset and firmware button that simplifies prototyping.
===== Building Project =====
This project is located in the "src/demos/lcd/lcd2s_bargraph" folder of the Netcruzer Download. To compile for Netcruzer Board, open this project in MPLAB X, and select the "Project Configuration" for desired board. For example "SBC66ECL_R2" for the SBC66ECL Revision 2 board. For details click here
===== Programming Board =====
After compiling (build), the board can be programmed via the USB Bootloader or a PIC Programmer. USB Programming is simplified when using the SBC board together with a Prototype Board.
===== File History =====
2012-08-08, David H. (DH):
#define THIS_IS_MAIN_FILE //Uniquely identifies this as the file with the main application entry function main()
#include "HardwareProfile.h"
void drawWave(BYTE count);
int main(void)
{
BYTE count = 0;
BYTE bgHeight;
WORD tmrFlashLed = 0;
DIR_SYSLED = 0;
delay_ms(300);
lcdInit();
lcdDisplayString(0, "\fBargraph Example");
lcdLoadCustomCharSet(0, 0);
lcdDrawVertBargraph(0, 2, 1, 1);
lcdDrawVertBargraph(0, 2, 2, 2);
lcdDrawVertBargraph(0, 2, 3, 3);
lcdDrawVertBargraph(0, 2, 4, 4);
lcdDrawVertBargraph(0, 2, 5, 5);
lcdDrawVertBargraph(0, 2, 6, 6);
lcdDrawVertBargraph(0, 2, 7, 7);
lcdDrawVertBargraph(0, 2, 8, 8);
while(1)
{
count++;
if ((count%5) == 0) {
LAT_SYSLED = !LAT_SYSLED;
}
bgHeight = count & 0b00001111;
if (bgHeight > 8)
bgHeight = 16 - bgHeight;
drawWave(count);
}
}
return 0;
}
void drawWave(BYTE count) {
BYTE i;
BYTE bgHeight;
for (i=0; i<8; i++) {
bgHeight = (count+i) & 0b00001111;
if (bgHeight > 8)
bgHeight = 16 - bgHeight;
lcdDrawVertBargraph(0, 2, 10+i, bgHeight);
}
}