RSS Feed on Nokia LCD 6610

This project displays an RSS feed from the CNN website on a Nokia LCD.

The connections for the LCD are shown in the picture below.

/media/uploads/shrutibhagat/mobilelcdschematic1.png

Link to the LCD specifications on the sparkfun website http://www.sparkfun.com/products/8600

/media/uploads/shrutibhagat/_scaled_photo.jpg

/media/uploads/shrutibhagat/_scaled_photo-2-.jpg

A webpage containing the RSS news feeds was downloaded and entire page was scanned for <title> and displayed the string that followed until </title>. The functions from the "EthernetNetIf.h" "HTTPClient.h", more details on the code. The code extracted 512 bytes from the webpage and extracted the text from the webpage. Our code displays the first three titles from the RSS Feed.

We used the NokiaLCD library to interface with the LCD. The following fixes need to be made to the library before it is used:

1.The two leftmost columns of pixels appeared whitish and were not affected by the lcd.background() command. The code needs to be modified in NokiaLCD.cpp at line 118 from x1=x+2 to x1=x+0 and the whitish pixels go away.

2. The member function pixel needs to modified to:

void NokiaLCD::pixel(int x, int y, int colour) {
    _cs = 0;
    _window(x, y, 1, 1);
     switch (_type) {
        case LCD6100:
        case PCF8833:
           
                _putp(colour);
            
            break;
        case LCD6610:
           
                int r4 = (colour >> (16 + 4)) & 0xF;
                int g4 = (colour >> (8 + 4)) & 0xF;
                int b4 = (colour >> (0 + 4)) & 0xF;
                int d1 = (r4 << 4) | g4;
                int d2 = (b4 << 4) | r4;
                int d3 = (g4 << 4) | b4;
                data(d1); 
                data(d2);   
                data(d3);
            
            break;
            }
    _cs = 1;
}

Our entire main program is given below:

#include "mbed.h"
#include "EthernetNetIf.h"
#include "HTTPClient.h"
#include "NokiaLCD.h"

NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type

EthernetNetIf eth; 
HTTPClient http;
LocalFileSystem local("local"); 
HTTPResult result;
bool completed = false;

void request_callback(HTTPResult r)
{
  result = r;
  completed = true;
}

int main() {

   lcd.background(0x0000FF);
    lcd.cls();

  printf("Start\n");

  printf("Setting up...\n");
  EthernetErr ethErr = eth.setup();
  if(ethErr)
  {
    printf("Error %d in setup.\n", ethErr);
    return -1;
  }
  printf("Setup OK\n");
  
  HTTPStream stream;
  
  int flag = 0;
  int count = 0;
  int pixel = 1;
  char c;
  char buffer[100];
  char BigBuf[512 + 1] = {0};
  stream.readNext((byte*)BigBuf, 512); //Point to buffer for the first read
  
  HTTPResult r = http.get("http://rss.cnn.com/rss/cnn_topstories.rss", &stream, request_callback); //Load a very large page, such as the hackaday RSS feed
  FILE *fp = fopen("/local/out.txt", "w");  // Open "out.txt" on the local file system for writing
  while(!completed)
  {
    Net::poll(); //Polls the Networking stack
    if(stream.readable())
    {
      BigBuf[stream.readLen()] = 0; //Transform this buffer in a zero-terminated char* string
      fprintf(fp,BigBuf);
      //Note: some servers do not like if you throttle them too much, so printf'ing during a request is generally bad practice
      stream.readNext((byte*)BigBuf, 512); //Buffer has been read, now we can put more data in it
    }
  }
  fclose(fp); 
  fp = fopen( "/local/out.txt", "r");
  if (fp==NULL) printf ("Error opening file");
  else
  {
    do
    {
      c = fgetc (fp);
      if (c == '<')
      {
        c = fgetc(fp);
        if(c == 't')
        {
          c = fgetc(fp);
          if(c == 'i')
          {
            c = fgetc(fp);
            if(c == 't')
            {
              c = fgetc(fp);
              if( c == 'l')
              {
                c = fgetc(fp);
                if( c == 'e')
                {
                  c = fgetc(fp);
                  if(c == '>')
                  {
                    count++;
                    if((count >=3) && (count <=5))
                    {
                    if(count == 6) break;
                    int i = 0;
                    c = fgetc(fp);
                    while(c != '<')
                    {
                        buffer[i] = c;
                        i++;
                        c = fgetc(fp);
                    }
                    buffer[i] = '\0';
                    lcd.locate(0,pixel);
                    lcd.printf("%s",buffer);
                    pixel += 5;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }while (count <= 5);
    fclose (fp);
  } 

  if(result == HTTP_OK)
  {
    printf("Read completely\n"); 
  }
  else
  {
    printf("Error %d\n", result);
  }

  return 0;
  
}


1 comment on RSS Feed on Nokia LCD 6610:

14 May 2012

Shruti, Going to the Sparkfun website, a replacement is shown for the 6610, which is retired. And from there, click on MBED example. There are many posts about the new device. And at end of threads, a ZIP file is shown for an updated .cpp file. donde

Please log in to post comments.