How to plot a graph on Nokia 5110 LCD

graphlcdpic

I have interfaced a Nokia 5110 LCD to a PIC. It displays characters using a font table.

Is there a way to plot ADC data on the LCD with ADC data on Y axis and time on X axis?
I do not want to use a library as my code space is limited. I'm using Microchip XC8 compiler.

Best Answer

Save your samples into an array, then plot each ADC value as the y value, and increment the x value.

Something like the code below (int8_t = unsigned char typedef):

int8_t buffer[256];
int8_t i;

for(i = 0, i < 256, i++)
{
    // draw_pixel is your routine for plotting an individual pixel 
    draw_pixel(i, buffer[i]);
}

You can interpolate between the pixels if desired (you need a draw_line function - google for code), then do something like:

// note end value decremented by one to account for i+i
for(i = 0, i < 255, i++) 
{
    draw_line(i, buffer[i]), i+1, buffer[i+1]); 
}