Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Paul_B

Pages: 1 ... 13 14 [15] 16 17
211
Graphic LCDs / Re: NHD-C160100DiZ and Raspberry Pi
« on: March 17, 2015, 08:23:39 AM »
Hello,

Thanks for the update, I went ahead and looked over your initialization sequence and everything seems to be in order. It is possible that the RPi's 1.8k pull -up resistors could be causing a weak pull-up.

Looking forward to the results of your test  :)


212
OLEDs / Re: Library that works fine on the NHD-0420CW-A*3
« on: March 17, 2015, 07:45:13 AM »
Hello George,

Thanks for sharing and posting your solution!

Regarding custom characters please have a look at the displays controller spec, see page 28. User defined characters can be loaded via 512 bits (8 characters) Character Generator RAM (CGRAM).

Link: http://www.newhavendisplay.com/app_notes/US2066.pdf

You will need to call the Set CGRAM address command, also take a look at the command description listed on page 39.

Hope this helps and please keep me posted on your progress  :)

213
Graphic LCDs / Re: NHD-C160100DiZ and Raspberry Pi
« on: March 16, 2015, 09:37:34 AM »
Hello,

Sounds like your I2C connection is correct, this tells me there must be an issue in your initialization.  Can you please share your initialization code?

Thanks!

214
TFTs / Re: Linux | Device Tree | NHD ‐ 4.3 ‐ 480272EF
« on: February 26, 2015, 08:07:16 AM »
Hello,

Question 1: What is the correct pin out?

Answer: The pin description can be seen on page 4 in the displays datasheet.
http://www.newhavendisplay.com/specs/NHD-4.3-480272EF-ATXL.pdf

Pin 1: LED‐
Pin 2: LED+


Question 2: What must I connect to LED+ ?

Answer: You must supply 19.2V @ 40mA.


Question 3: If I connect the PIN 31 DISP to HIGH do i start the display ?

Answer: The DISP pin is used to turn on and off the TFT display. If DISP is pulled high the display will turn on.


Regarding your timing values everything looks correct  :)


Hope this helps!



215
OLEDs / Re: Column of characters not displaying.
« on: February 19, 2015, 08:12:22 AM »
Hello Carl,

I actually have some example code I can share with you.  It is written for the Arduino Mega.  See below:

Code: [Select]
#include <Wire.h>
//#include <SPI.h>

int RS = 30;
int  E = 31;
int RES = 32;
int CS = 33;

int ASDA = 20;
int ASCL = 21;

int SCLK = 52;
int SDIN = 51;
int SDOUT = 50;

// R/W signal tied LOW (always write)

unsigned char tx_packet[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const char slave2w = 0x3C;  //3C or 78

unsigned char mode = 0; // 0 = 8-bit parallel 6800 mode; 1 = i2c mode; 2 = SPI mode;

unsigned char text1[] = {"Newhaven Display----"};
unsigned char text2[] = {"Test----------------"};
unsigned char text3[] = {"16/20 Characters----"};
unsigned char text4[] = {"!@#$%^&*()_+{}[]<>?~"};

void command(unsigned char c)
{
  unsigned char i, temp;
  switch(mode)
  {
    case 0:   digitalWrite(CS, LOW);
              PORTA = c;
              digitalWrite(RS, LOW);
              digitalWrite(E, HIGH);
              delay(1);
              digitalWrite(E, LOW);
              digitalWrite(CS, HIGH);
              break;
   case 1:    tx_packet[0] = 0x00;
              tx_packet[1] = c;
              send_packet(2);
              break;
   case 2:   
              temp = 0xF8;
              for(i=0;i<8;i++)
              {
                digitalWrite(SCLK, LOW);
                if((temp&0x80)>>7==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                temp = temp << 1;
                digitalWrite(SCLK, HIGH);
              }
 
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((c&0x01)==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                c = c >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((c&0x1)==0x1) // <------- Change
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                c = c >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              break;
  }
 
}
void data(unsigned char d)
{
  unsigned char i, temp;
  switch(mode)
  {
    case 0:   digitalWrite(CS, LOW);
              PORTA = d;
              digitalWrite(RS, HIGH);
              digitalWrite(E, HIGH);
              delay(1);
              digitalWrite(E, LOW);
              digitalWrite(CS, HIGH);
              break;
   case 1:    tx_packet[0] = 0x40;
              tx_packet[1] = d;
              send_packet(2);
              break;
   case 2:   
              temp = 0xFA;
              for(i=0;i<8;i++)
              {
                digitalWrite(SCLK, LOW);
                if((temp&0x80)>>7==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                temp = temp << 1;
                digitalWrite(SCLK, HIGH);
              }
 
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((d&0x01)==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                d = d >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((d&0x1)==0x1) // <------- Change
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                d = d >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              break;
  }
 
}

void send_packet(unsigned char x)
{
  unsigned char ix;
 
  Wire.beginTransmission(slave2w);
  for(ix=0;ix<x;ix++)
  {
    Wire.write(tx_packet[ix]);
  }
  Wire.endTransmission();
}


void output()
{
int i;

        command(0x01);
        delay(2);
        for(i=0;i<20;i++){
          data(text1[i]);
        }
       
        command(0xA0);
        for(i=0;i<20;i++){
          data(text2[i]);
        }
       
        command(0xC0);
        for(i=0;i<20;i++){
          data(text3[i]);
        }
        command(0xE0);
        for(i=0;i<20;i++){
          data(text4[i]);
        }
        delay(2000);

command(0x01);
        delay(2);
for (i=0;i<20;i++){
data(text3[i]);
}

command(0xA0);
for (i=0;i<20;i++){
data(text4[i]);
}

command(0xC0);
for (i=0;i<20;i++){
data(text1[i]);
}

command(0xE0);
for (i=0;i<20;i++){
data(text2[i]);
}
}

void outputTest()
{
int i;

        command(0x01);
        delay(2);
        data('N');
        while(1);
       
        for(i=0;i<20;i++){
          data(text1[i]);
        }
       
        command(0xA0);
        for(i=0;i<20;i++){
          data(text2[i]);
        }
       
        command(0xC0);
        for(i=0;i<20;i++){
          data(text3[i]);
        }
        command(0xE0);
        for(i=0;i<20;i++){
          data(text4[i]);
        }
        delay(2000);

command(0x01);
        delay(2);
for (i=0;i<20;i++){
data(text3[i]);
}

command(0xA0);
for (i=0;i<20;i++){
data(text4[i]);
}

command(0xC0);
for (i=0;i<20;i++){
data(text1[i]);
}

command(0xE0);
for (i=0;i<20;i++){
data(text2[i]);
}
}

void blocks()
{
int i;

        command(0x01);
        delay(2);

        for(i=0;i<20;i++){
          data(0x1F);
        }

        command(0xA0);
        for(i=0;i<20;i++){
          data(0x1F);
        }
}

void setup()
{
  pinMode(ASCL, OUTPUT);      //set Arduino I2C lines as outputs
  pinMode(ASDA, OUTPUT);      //
  digitalWrite(ASCL, LOW);    //
  digitalWrite(ASDA, LOW);    //
  pinMode(SCLK, OUTPUT);
  pinMode(SDIN, OUTPUT);
  pinMode(SDOUT, INPUT);
  digitalWrite(SCLK, HIGH);
  digitalWrite(SDIN, HIGH);
  DDRA = 0xFF;
  PORTA = 0x00;
  DDRC = 0xFF;
  PORTC = 0x00;
  digitalWrite(RES, HIGH);
  delay(10);
  Wire.begin();
  delay(10);
  //SPI.begin();
command(0x2A);  //function set (extended command set)
command(0x71);  //function selection A, disable internal Vdd regualtor
data(0x00);
command(0x28);  //function set (fundamental command set)
command(0x08);  //display off, cursor off, blink off
command(0x2A);  //function set (extended command set)
command(0x79);  //OLED command set enabled
command(0xD5);  //set display clock divide ratio/oscillator frequency
command(0x70);  //set display clock divide ratio/oscillator frequency
command(0x78);  //OLED command set disabled
command(0x09);  //extended function set (4-lines)
    command(0x06);  //COM SEG direction
command(0x72);  //function selection B, disable internal Vdd regualtor
data(0x00);     //ROM CGRAM selection
command(0x2A);  //function set (extended command set)
command(0x79);  //OLED command set enabled
command(0xDA);  //set SEG pins hardware configuration
command(0x10);  //set SEG pins hardware configuration   // <--------- Change
command(0xDC);  //function selection C
command(0x00);  //function selection C
command(0x81);  //set contrast control
command(0x7F);  //set contrast control
command(0xD9);  //set phase length
command(0xF1);  //set phase length
command(0xDB);  //set VCOMH deselect level
command(0x40);  //set VCOMH deselect level
command(0x78);  //OLED command set disabled
command(0x28);  //function set (fundamental command set)
command(0x01);  //clear display
command(0x80);  //set DDRAM address to 0x00
command(0x0C);  //display ON
  delay(100);
  //Wire.begin();
  //delay(10);
}

void loop()

  while(1)
  {
    output();
    //blocks();
    while(1);
    //outputTest();
    delay(2000);
  }
}

Please verify your timing and initialization with what is listed in the example code, also can you tell me what interface you are using?

216
TFTs / Re: Linux | Device Tree | NHD ‐ 4.3 ‐ 480272EF
« on: February 18, 2015, 10:43:27 AM »
Hello,

Your timing characteristics look correct, one thing I did notice from the elinux wiki is that your panel-info {},needs to change from bpp <16> to bpp <24>.

Please keep me posted on your progress, looks like a great project  8)

217
Character LCDs / Re: Need some help with NHD-0216WZ-RN-YBW-2
« on: February 17, 2015, 05:15:23 PM »
Hello,

The controller / driver is AT89C2051

Hope this helps!

218
Character LCDs / Re: NHD-0212WH-ATMI-JT# on 3.3V
« on: February 17, 2015, 05:05:34 PM »
Hello,

To answer your question no, the optimal contrast needs to be around 0.8V. Please see page 5 in the displays data sheet for the electrical characteristics.   

http://www.newhavendisplay.com/specs/NHD-0212WH-ATMI-JT.pdf

219
OLEDs / Re: Need help/wisdom using the new NHD-0420CW-xxx
« on: February 17, 2015, 04:51:23 PM »
Success, enjoy the display George!

220
Character LCDs / Re: Need some help with NHD-0216WZ-RN-YBW-2
« on: February 17, 2015, 10:37:10 AM »
Hello,

This is an older model display made several years ago and we no longer support it. I'm sorry, unfortunately we do not have a datasheet available.


221
OLEDs / Re: Need help/wisdom using the new NHD-0420CW-xxx
« on: February 17, 2015, 07:51:19 AM »
Hey George,

Do you have pull-up resistors on SDA and SCL (10k) when using I2C?

Also please try the code below in SPI, I have made some modifications (see comments):

Code: [Select]
#include <Wire.h>
//#include <SPI.h>

int RS = 30;
int  E = 31;
int RES = 32;
int CS = 33;

int ASDA = 20;
int ASCL = 21;

int SCLK = 52;
int SDIN = 51;
int SDOUT = 50;

// R/W signal tied LOW (always write)

unsigned char tx_packet[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const char slave2w = 0x3C;  //3C or 78

unsigned char mode = 0; // 0 = 8-bit parallel 6800 mode; 1 = i2c mode; 2 = SPI mode;

unsigned char text1[] = {"Newhaven Display----"};
unsigned char text2[] = {"Test----------------"};
unsigned char text3[] = {"16/20 Characters----"};
unsigned char text4[] = {"!@#$%^&*()_+{}[]<>?~"};

void command(unsigned char c)
{
  unsigned char i, temp;
  switch(mode)
  {
    case 0:   digitalWrite(CS, LOW);
              PORTA = c;
              digitalWrite(RS, LOW);
              digitalWrite(E, HIGH);
              delay(1);
              digitalWrite(E, LOW);
              digitalWrite(CS, HIGH);
              break;
   case 1:    tx_packet[0] = 0x00;
              tx_packet[1] = c;
              send_packet(2);
              break;
   case 2:   
              temp = 0xF8;
              for(i=0;i<8;i++)
              {
                digitalWrite(SCLK, LOW);
                if((temp&0x80)>>7==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                temp = temp << 1;
                digitalWrite(SCLK, HIGH);
              }
 
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((c&0x01)==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                c = c >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((c&0x1)==0x1) // <------- Change
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                c = c >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              break;
  }
 
}
void data(unsigned char d)
{
  unsigned char i, temp;
  switch(mode)
  {
    case 0:   digitalWrite(CS, LOW);
              PORTA = d;
              digitalWrite(RS, HIGH);
              digitalWrite(E, HIGH);
              delay(1);
              digitalWrite(E, LOW);
              digitalWrite(CS, HIGH);
              break;
   case 1:    tx_packet[0] = 0x40;
              tx_packet[1] = d;
              send_packet(2);
              break;
   case 2:   
              temp = 0xFA;
              for(i=0;i<8;i++)
              {
                digitalWrite(SCLK, LOW);
                if((temp&0x80)>>7==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                temp = temp << 1;
                digitalWrite(SCLK, HIGH);
              }
 
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((d&0x01)==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                d = d >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((d&0x1)==0x1) // <------- Change
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                d = d >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              break;
  }
 
}

void send_packet(unsigned char x)
{
  unsigned char ix;
 
  Wire.beginTransmission(slave2w);
  for(ix=0;ix<x;ix++)
  {
    Wire.write(tx_packet[ix]);
  }
  Wire.endTransmission();
}


void output()
{
int i;

        command(0x01);
        delay(2);
        for(i=0;i<20;i++){
          data(text1[i]);
        }
       
        command(0xA0);
        for(i=0;i<20;i++){
          data(text2[i]);
        }
       
        command(0xC0);
        for(i=0;i<20;i++){
          data(text3[i]);
        }
        command(0xE0);
        for(i=0;i<20;i++){
          data(text4[i]);
        }
        delay(2000);

command(0x01);
        delay(2);
for (i=0;i<20;i++){
data(text3[i]);
}

command(0xA0);
for (i=0;i<20;i++){
data(text4[i]);
}

command(0xC0);
for (i=0;i<20;i++){
data(text1[i]);
}

command(0xE0);
for (i=0;i<20;i++){
data(text2[i]);
}
}

void outputTest()
{
int i;

        command(0x01);
        delay(2);
        data('N');
        while(1);
       
        for(i=0;i<20;i++){
          data(text1[i]);
        }
       
        command(0xA0);
        for(i=0;i<20;i++){
          data(text2[i]);
        }
       
        command(0xC0);
        for(i=0;i<20;i++){
          data(text3[i]);
        }
        command(0xE0);
        for(i=0;i<20;i++){
          data(text4[i]);
        }
        delay(2000);

command(0x01);
        delay(2);
for (i=0;i<20;i++){
data(text3[i]);
}

command(0xA0);
for (i=0;i<20;i++){
data(text4[i]);
}

command(0xC0);
for (i=0;i<20;i++){
data(text1[i]);
}

command(0xE0);
for (i=0;i<20;i++){
data(text2[i]);
}
}

void blocks()
{
int i;

        command(0x01);
        delay(2);

        for(i=0;i<20;i++){
          data(0x1F);
        }

        command(0xA0);
        for(i=0;i<20;i++){
          data(0x1F);
        }
}

void setup()
{
  pinMode(ASCL, OUTPUT);      //set Arduino I2C lines as outputs
  pinMode(ASDA, OUTPUT);      //
  digitalWrite(ASCL, LOW);    //
  digitalWrite(ASDA, LOW);    //
  pinMode(SCLK, OUTPUT);
  pinMode(SDIN, OUTPUT);
  pinMode(SDOUT, INPUT);
  digitalWrite(SCLK, HIGH);
  digitalWrite(SDIN, HIGH);
  DDRA = 0xFF;
  PORTA = 0x00;
  DDRC = 0xFF;
  PORTC = 0x00;
  digitalWrite(RES, HIGH);
  delay(10);
  Wire.begin();
  delay(10);
  //SPI.begin();
command(0x2A);  //function set (extended command set)
command(0x71);  //function selection A, disable internal Vdd regualtor
data(0x00);
command(0x28);  //function set (fundamental command set)
command(0x08);  //display off, cursor off, blink off
command(0x2A);  //function set (extended command set)
command(0x79);  //OLED command set enabled
command(0xD5);  //set display clock divide ratio/oscillator frequency
command(0x70);  //set display clock divide ratio/oscillator frequency
command(0x78);  //OLED command set disabled
command(0x09);  //extended function set (4-lines)
    command(0x06);  //COM SEG direction
command(0x72);  //function selection B, disable internal Vdd regualtor
data(0x00);     //ROM CGRAM selection
command(0x2A);  //function set (extended command set)
command(0x79);  //OLED command set enabled
command(0xDA);  //set SEG pins hardware configuration
command(0x10);  //set SEG pins hardware configuration   // <--------- Change
command(0xDC);  //function selection C
command(0x00);  //function selection C
command(0x81);  //set contrast control
command(0x7F);  //set contrast control
command(0xD9);  //set phase length
command(0xF1);  //set phase length
command(0xDB);  //set VCOMH deselect level
command(0x40);  //set VCOMH deselect level
command(0x78);  //OLED command set disabled
command(0x28);  //function set (fundamental command set)
command(0x01);  //clear display
command(0x80);  //set DDRAM address to 0x00
command(0x0C);  //display ON
  delay(100);
  //Wire.begin();
  //delay(10);
}

void loop()

  while(1)
  {
    output();
    //blocks();
    while(1);
    //outputTest();
    delay(2000);
  }
}

Thanks!

222
OLEDs / Re: Need help/wisdom using the new NHD-0420CW-xxx
« on: February 16, 2015, 12:36:16 PM »
Correct, give the new code a try and keep me posted  :D

223
OLEDs / Re: Need help/wisdom using the new NHD-0420CW-xxx
« on: February 16, 2015, 09:08:47 AM »
Hello,

void output()  //This function is used to display an Array of text on the screen.
{
   int i;

        command(0x01); //This is clearing the display
        delay(2);
        for(i=0;i<20;i++){ // loops through Array text1
          data(text1);
        }
       
        command(0xa0); // Send cursor to line 2
        for(i=0;i<20;i++){
          data(text2);
        }
......

void outputTest() // You can ignore this function, it isn't actually called.   This function was written to test the output.
{
   int i;

        command(0x01);
        delay(2);
        data('N');
        while(1);
       
        for(i=0;i<20;i++){
          data(text1);
        }
       
        command(0xA0);
        for(i=0;i<20;i++){
          data(text2);
        }
        delay(2000);

   command(0x01);
        delay(2);
   for (i=0;i<20;i++){
      data(text3);
   }
   
   command(0xA0);
   for (i=0;i<20;i++){
      data(text4);
   }
}


Please try the code below (I have modified it for the 4x20 instead of 2x16):

Code: [Select]
#include <Wire.h>
//#include <SPI.h>

int RS = 30;
int  E = 31;
int RES = 32;
int CS = 33;

int ASDA = 20;
int ASCL = 21;

int SCLK = 52;
int SDIN = 51;
int SDOUT = 50;

// R/W signal tied LOW (always write)

unsigned char tx_packet[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const char slave2w = 0x3C;  //3C or 78

unsigned char mode = 0; // 0 = 8-bit parallel 6800 mode; 1 = i2c mode; 2 = SPI mode;

unsigned char text1[] = {"Newhaven Display----"};
unsigned char text2[] = {"Test----------------"};
unsigned char text3[] = {"16/20 Characters----"};
unsigned char text4[] = {"!@#$%^&*()_+{}[]<>?~"};

void command(unsigned char c)
{
  unsigned char i, temp;
  switch(mode)
  {
    case 0:   digitalWrite(CS, LOW);
              PORTA = c;
              digitalWrite(RS, LOW);
              digitalWrite(E, HIGH);
              delay(1);
              digitalWrite(E, LOW);
              digitalWrite(CS, HIGH);
              break;
   case 1:    tx_packet[0] = 0x00;
              tx_packet[1] = c;
              send_packet(2);
              break;
   case 2:   
              temp = 0xF8;
              for(i=0;i<8;i++)
              {
                digitalWrite(SCLK, LOW);
                if((temp&0x80)>>7==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                temp = temp << 1;
                digitalWrite(SCLK, HIGH);
              }
 
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((c&0x01)==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                c = c >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((c&0x10)==0x10)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                c = c >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              break;
  }
 
}
void data(unsigned char d)
{
  unsigned char i, temp;
  switch(mode)
  {
    case 0:   digitalWrite(CS, LOW);
              PORTA = d;
              digitalWrite(RS, HIGH);
              digitalWrite(E, HIGH);
              delay(1);
              digitalWrite(E, LOW);
              digitalWrite(CS, HIGH);
              break;
   case 1:    tx_packet[0] = 0x40;
              tx_packet[1] = d;
              send_packet(2);
              break;
   case 2:   
              temp = 0xFA;
              for(i=0;i<8;i++)
              {
                digitalWrite(SCLK, LOW);
                if((temp&0x80)>>7==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                temp = temp << 1;
                digitalWrite(SCLK, HIGH);
              }
 
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((d&0x01)==1)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                d = d >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                if((d&0x10)==0x10)
                {
                  digitalWrite(SDIN, HIGH);
                }
                else
                {
                  digitalWrite(SDIN, LOW);
                }
                d = d >> 1;
                digitalWrite(SCLK, HIGH);
              }
              for(i=0;i<4;i++)
              {
                digitalWrite(SCLK, LOW);
                digitalWrite(SDIN, LOW);
                digitalWrite(SCLK, HIGH);
              }
              break;
  }
 
}

void send_packet(unsigned char x)
{
  unsigned char ix;
 
  Wire.beginTransmission(slave2w);
  for(ix=0;ix<x;ix++)
  {
    Wire.write(tx_packet[ix]);
  }
  Wire.endTransmission();
}


void output()
{
int i;

        command(0x01);
        delay(2);
        for(i=0;i<20;i++){
          data(text1[i]);
        }
       
        command(0xA0);
        for(i=0;i<20;i++){
          data(text2[i]);
        }
       
        command(0xC0);
        for(i=0;i<20;i++){
          data(text3[i]);
        }
        command(0xE0);
        for(i=0;i<20;i++){
          data(text4[i]);
        }
        delay(2000);

command(0x01);
        delay(2);
for (i=0;i<20;i++){
data(text3[i]);
}

command(0xA0);
for (i=0;i<20;i++){
data(text4[i]);
}

command(0xC0);
for (i=0;i<20;i++){
data(text1[i]);
}

command(0xE0);
for (i=0;i<20;i++){
data(text2[i]);
}
}

void outputTest()
{
int i;

        command(0x01);
        delay(2);
        data('N');
        while(1);
       
        for(i=0;i<20;i++){
          data(text1[i]);
        }
       
        command(0xA0);
        for(i=0;i<20;i++){
          data(text2[i]);
        }
       
        command(0xC0);
        for(i=0;i<20;i++){
          data(text3[i]);
        }
        command(0xE0);
        for(i=0;i<20;i++){
          data(text4[i]);
        }
        delay(2000);

command(0x01);
        delay(2);
for (i=0;i<20;i++){
data(text3[i]);
}

command(0xA0);
for (i=0;i<20;i++){
data(text4[i]);
}

command(0xC0);
for (i=0;i<20;i++){
data(text1[i]);
}

command(0xE0);
for (i=0;i<20;i++){
data(text2[i]);
}
}

void blocks()
{
int i;

        command(0x01);
        delay(2);

        for(i=0;i<20;i++){
          data(0x1F);
        }

        command(0xA0);
        for(i=0;i<20;i++){
          data(0x1F);
        }
}

void setup()
{
  pinMode(ASCL, OUTPUT);      //set Arduino I2C lines as outputs
  pinMode(ASDA, OUTPUT);      //
  digitalWrite(ASCL, LOW);    //
  digitalWrite(ASDA, LOW);    //
  pinMode(SCLK, OUTPUT);
  pinMode(SDIN, OUTPUT);
  pinMode(SDOUT, INPUT);
  digitalWrite(SCLK, HIGH);
  digitalWrite(SDIN, HIGH);
  DDRA = 0xFF;
  PORTA = 0x00;
  DDRC = 0xFF;
  PORTC = 0x00;
  digitalWrite(RES, HIGH);
  delay(10);
  Wire.begin();
  delay(10);
  //SPI.begin();
  command(0x2A);  //function set (extended command set)
    command(0x71);  //function selection A, disable internal Vdd regualtor
    data(0x00);
command(0x28);  //function set (fundamental command set)
command(0x08);  //display off, cursor off, blink off
command(0x2A);  //function set (extended command set)
command(0x79);  //OLED command set enabled
command(0xD5);  //set display clock divide ratio/oscillator frequency
command(0x70);  //set display clock divide ratio/oscillator frequency
command(0x78);  //OLED command set disabled
command(0x09);  //extended function set (4-lines)
        command(0x06);  //COM SEG direction
command(0x72);  //function selection B, disable internal Vdd regualtor
data(0x00);     //ROM CGRAM selection
command(0x2A);  //function set (extended command set)
command(0x79);  //OLED command set enabled
command(0xDA);  //set SEG pins hardware configuration
command(0x00);  //set SEG pins hardware configuration   ////////////////////////////////////0x10 on other slim char OLEDs
command(0xDC);  //function selection C
command(0x00);  //function selection C
command(0x81);  //set contrast control
command(0x7F);  //set contrast control
command(0xD9);  //set phase length
command(0xF1);  //set phase length
command(0xDB);  //set VCOMH deselect level
command(0x40);  //set VCOMH deselect level
command(0x78);  //OLED command set disabled
command(0x28);  //function set (fundamental command set)
command(0x01);  //clear display
command(0x80);  //set DDRAM address to 0x00
command(0x0C);  //display ON
  delay(100);
  //Wire.begin();
  //delay(10);
}

void loop()

  while(1)
  {
    output();
    //blocks();
    while(1);
    //outputTest();
    delay(2000);
  }
}

224
OLEDs / Re: Driving Slim OLED from 3.3V system
« on: February 16, 2015, 08:13:26 AM »
Hello,

Page 4 in the displays datasheet will list the pin description, it will be sorted by interface e.g SPI, I2c ..etc In your case please follow the SPI pin description as-well as the Serial MPU Interface Pin Selections (when using SPI BS0 - BS1- BS2 must be tied to ground).

http://www.newhavendisplay.com/specs/NHD-0420CW-AY3.pdf


We also have some example Arduino code available, please see the link below:

https://github.com/NewhavenDisplay/NHD_US2066-Arduino-Mega

Hope this helps!

225
OLEDs / Re: interface voltage levels for NHD-0420CW
« on: February 12, 2015, 01:56:20 PM »
No problem, have a good one!  :)

Pages: 1 ... 13 14 [15] 16 17