Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Re: MF522-AN RFID Reader on: August 17, 2013, 08:18:05 pm
SPI on the Pro Mini hooks up just like with any other 168/328 based Arduino:

Pin 13 >> SCK
Pin 12 >> MISO
Pin 11 >> MOSI
Pin 10 >> SS (Labeled SDA on my reader)
Reset >> RST

IRQ is not necessary.
2  Using Arduino / Displays / Re: U8glib: Graphics Lib for LCDs and OLEDs on: January 12, 2013, 11:52:28 am
Oops. Sorry about that. Here it is:

Code:
#include "U8glib.h"

U8GLIB_NHD_C12864 u8g(13, 11, 10, 9);

int val; // Y value (Read from the Analog input)
int xPos = 0; // X position
int prevXPos = 0; // Previous x position
int scanVal[128]; // Array to hold the graphs values as it scans.
int xDraw; // Used to

//--------------------------------------------

void drawText(void) {
  val = analogRead(A0);// Poll ADC
  val = map(val,0,1023,63,0);// Scale things down to fit the vertical pixel count of the LCD.

  scanVal[xPos] = val;// Write the Y value to the appropriate element (X value).

  u8g.setPrintPos(50, 63);// Set Cursor.
  u8g.print("Y");
  u8g.print(val);// Print out the Y value.

  u8g.setPrintPos(20, 63);// Set Cursor.
  u8g.print("X");
  u8g.print(xPos);// Print out the X value.
}

//--------------------------------------------

void drawScan(void) {// This function cycles 128 times per update to draw the full scan of the line.
  val = scanVal[xDraw];// Pull the Y value from the appropriate element.
  u8g.drawPixel(xDraw,val);// Set a pixel.
  xDraw++;// Increment the column position (X value).
}// End of scan

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void setup(void) {
  u8g.setRot180();// Flip screen
  u8g.setFont(u8g_font_6x10r);// Set Font
  pinMode(7,OUTPUT);
}

void loop(void) {

  u8g.firstPage(); 
  do {
    drawText();
    xDraw = 0;
    do
    {
      drawScan();
    }
    while(xDraw <= 127); // Loop to draw every column of the array.
  }
  while( u8g.nextPage() );


  if(xPos == 127) xPos = 0; // Reset X to 0 when it reaches the last column on the screen.
  else xPos++; // Increment X position

}// End Void Loop()


I couldn't get it to draw lines instead of points. It would visibly buffer the pages.

I'm actually running my display in parallel mode with a different library to see if I can get it to work right. It works well, but I have to figure out how to set the contrast since it is not set up to be externally controlled like KS0108 driven displays. I think I've found out how to adjust it in the datasheet, though.

 - Muhammad.
3  Using Arduino / Displays / Re: U8glib: Graphics Lib for LCDs and OLEDs on: January 11, 2013, 07:43:00 pm
After some late-night tinkering, I managed to get it to scan. I guess it just took me some time to get acquainted with the Do While structure of execution. It renders a tad slow, but it's still pretty good. I might have an idea on how to speed things up...

I'm using an LCD I bought off of Ebay, similarly found here: http://tinyurl.com/cxujsag which works perfectly under NHD_C12864.

I can definitely understand the memory oriented design of this library. A lot of display libraries don't fare well on the ATMega168. I know Adafruit's library for the Nokia 5110 display will only work on a 328 and up.

I've attached a photo of it plotting a .4Hz signal from a function generator. I've also attached the program for whoever may be interested in it. Ideas on optimization would be much appreciated smiley

I really appreciate the work you've put into this library!


 - Muhammad.
4  Using Arduino / Displays / Re: U8glib: Graphics Lib for LCDs and OLEDs on: January 10, 2013, 06:46:31 pm
I downloaded this library a couple days ago and am having a blast with it! It is the most comprehensive and flexible display library I've seen.

However, I'm having a bit of trouble doing some simple stuff.

I'm basically trying to get my screen to plot the input of the ADC; a line over time, sort of like the way an oscilloscope scans when the time/div is big enough. Or how an EKG display refreshes (which is what my application is.) I was previously doing this with a generic parallel GLCD using the GLCD library. Here's how I was doing it:

Code:
#include <glcd.h>

int xPos = 0; // X position value.
int pot; // Potentiometer value.

void setup()
{
  GLCD.Init();
  GLCD.ClearScreen();
}

void  loop()

  for(xPos = 0; xPos < 127; xPos += 1)
  {                               
    pot = analogRead(A0); // Sample ADC
    pot = map(pot, 0, 1023, 0, 63); // Scale down readings to LCD's vertical pixel count.
    GLCD.DrawVLine(xPos, 0, 63, WHITE); // Erase column of pixels previously set.
    GLCD.SetDot(xPos, pot, BLACK); // Set new pixel.
    delay(10);
  } // End FOR statement.

  if(xPos == 127)
  {
    xPos = 0; // Return to the first column when the last column is reached.
  } // End IF statement.

} // End void loop()

I changed this to fit the profile of this library by doing away with the For loop and fitting it in a Do While, changing the functions, so on. (I'd post it, but it appears that I didn't save it smiley-confuse ) It of course doesn't work since this library (to my understanding) rewrites the entire screen each time it cycles rather than just the pixels specified in the functions. Instead, it just scans a single pixel.

I guess what I'm asking is for some insight on how I might be able to get this library to continuously draw without necessarily rewriting the entire display, if that's possible in the first place.

If I must rewrite the full display, I guess I could store all 128 columns in an array and write them all over every time I refresh. I'm not sure how efficient that is, though.


Cheers,

 - Muhammad.
Pages: [1]