0
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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]); 
}
\$\endgroup\$
  • \$\begingroup\$ Thanks. I was looking at specifics to Nokia 5110, like details on draw pixel function. The given answer is pretty generic. Thanks. \$\endgroup\$ – Chetan Bhargava Nov 12 '12 at 21:08
1
\$\begingroup\$

I worked with the Nokia 5110 display a while ago but using a MSP430.

The display can be seen as an array of 84 columns x 6 blocks of 8 pixels each; writing a value from 0x00 to 0xFF to a block will change its contents (0x00 = nothing on that block, 0xFF = this block is fully on). Block 0 represents rows 0 to 7, block 1 represents rows 8 to 15 etc...

Thus you'll need a buffer of 84 x 6 = 504 values to hold those, since the display is write-only. To draw a pixel at (x,y) you need to find which block you want to write to, then change the adequate values on the buffer, set the display X/Y position to it and write it there.

Those codes for the Arduino might help: https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library and https://github.com/adafruit/Adafruit-GFX-Library

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.