SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By dext3r
#11698
Can someone explain to how you would convert images to use this color palette? (like in photoshop or something)

I'm not really sure I understand how the color palette is set up.
By amcfall
#11708
dext3r wrote:Can someone explain to how you would convert images to use this color palette? (like in photoshop or something)

I'm not really sure I understand how the color palette is set up.
I've been using GCLCD to convert the bitmap to a nice array, you can get it here:

http://translate.google.com/translate?h ... s%26sa%3DG
original:
http://www.hobbypic.com/index.php?optio ... &Itemid=36

I've been taking 16 bit color bitmaps and bringing them down to 12 bit. The 16 bit data is RGB 565, and the 12 bit is 4 bits for each color.

The code above has an error or two, if you need OK reference code I have a post in the code library at the CCS user forum (ccsinfo.com).

Has anyone found a really good contrast or other init setting? What voltage are you running it at? Image quality on mine is good but not great.

Avery
By dext3r
#11715
hmm thanks for the link, good info there too.

What I'm not getting is...to place a pixel, you specify X, Y, and 0-4096? for a color? (according to the sparkfun source), but in GCLCD app you never see a value higher than 255...??
By amcfall
#11726
Theh LCD has two modes, 8 bit and 12 bit.

If you load a 16 bit color bitmap in GCLCD and select 16 bit output it will give you higer color values. It defaults to 8 bit output.

Avery
By rcooke
#12874
Hi Folks,

I'm new to the AVR parts and the LCD module and am wondering how do you get the AVR's SPI port to work with the 9 bit serial mode the Epson controller chip is expecting?

Thanks,

RIchard
By JamesC
#12875
The short answer is, all of the AVR's I've looked at only support 8-bit (hardware) SPI

The longer answer is, theres other ways to do it.

I've gotten a test pattern working on using an Atmega32 by bit-banging the ports.

Another thing you can do is use 8-bit SPI for 8 of the bits and bit bang the 9th bit. That works too. Below is a snippet from my test program that demonstrates the technique. It's currently non-interrupt driven, so using the hardware SPI isnt much faster than bit-banging all 9-bits. But with a little clever coding, you could probably set it up to be interrupt driven. When the interrupt is triggered for the end of one byte, you would bit bang the first bit, then put the last 8 bytes in the buffer to be written out and return. It would be a little tricky to code, but I think it could be made to work.

Bear with me on the wacky macros... I try to avoid manual bit-twiddling, and gcc optimizes this rather well.
Code: Select all


#define LCD_PORT PORTB
#define LCD_RST 0
#define LCD_CS  1
#define LCD_SDATA 5
#define LCD_SCLK 7


#define sbi(port,bit)  (port |= (1<<bit))   //set bit in port
#define cbi(port,bit)  (port &= ~(1<<bit))  //clear bit in port

#define SET_LCD_CS(value) ( (!(value)) ? cbi(LCD_PORT, LCD_CS) : sbi(LCD_PORT, LCD_CS) )
#define SET_LCD_RST(value) ( (!(value)) ? cbi(LCD_PORT, LCD_RST) : sbi(LCD_PORT, LCD_RST) )
#define SET_LCD_SCLK(value) ( (!(value)) ? cbi(LCD_PORT, LCD_SCLK) : sbi(LCD_PORT, LCD_SCLK) )
#define SET_LCD_SDATA(value) ( (!(value)) ? cbi(LCD_PORT, LCD_SDATA) : sbi(LCD_PORT, LCD_SDATA) )


void lcdSendCommand(uint8_t v)
{

    // bit bang the first bit...
    SET_LCD_SDATA(0);
    SET_LCD_SCLK(1);
    SET_LCD_SCLK(0);
    
   
    // turn on hardware SPI
    SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR0);
    
    // send the 8 bits using hardware spi
    SPDR = v;
    while (!  ((SPSR) & (1<<SPIF)))
        ;
        
    // turn off hardware SPI    
    SPCR = 0;

}


void lcdSendData(uint8_t v)
{
    // bit bang the first bit...
    SET_LCD_SDATA(1);
    SET_LCD_SCLK(1);
    SET_LCD_SCLK(0);


    // turn on hardware SPI
    SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR0);

    // send the 8 bits using hardware spi
    SPDR = v;
    while (!  ((SPSR) & (1<<SPIF)))
        ;

    // turn off hardware SPI    
    SPCR = 0;
}
By seulater
#12881
her is how you can send the 9 bits to the LCD using an AVR


#define LCDCommand 0
#define LCDData 1
#define LCD_CS(x) PORTC.0=x;
#define LCD_CLK(x) PORTB.7=x;
#define LCD_DATA(x) PORTB.5=x;
#define LCD_RESET(x) PORTC.3=x;





//*********************************************************
// Name: SendLcd(u_char type, u_char dat)
// Copyright: Free to use at will & at own risk.
// Author: JCP
// Date: 03.30.06 17:10
// Description: Sends 9 bit SPI data to LCD
// Useage: SendLcd(param 1,param 2)
// param 1: Type of data, I.E. Data or Command
// param 2: The data to be sent
//
// Example: SendLcd(LCDCommand,RGBSET8);
// or
// SendLcd(LCDData,0x00);
//********************************************************
void SendLcd(u_char type, u_char dat)
{

LCD_DATA(type); // set up first bit as command or data
LCD_CS(0); // Enable device CS

LCD_CLK(0); // Pull Clock LOW
LCD_CLK(1); // Pul Clock HIGH

SPCR |=0x50; // Enable Hardware SPI

SPDR = dat; // send data

while(!(SPSR & 0x80)); // wait until send complete

LCD_CS(1); // disable device CS

SPCR &=~0x50; // Disable Hardware SPI, this releases the SPI pins
// for general IO use. which is used to send the 1'st
// bit out
}
By rcooke
#12897
Thanks guys. These ideas will make my life a whole lot easier. Now I just have to come up with a compact way to actually get text to appear on the LCD.
By seulater
#12921
I will be E-mailing Spark Fun with my full source code for the Atmega32
for this display. I have included allot of features like Line, Box, Circle, 3 different Font types, and so on. I dont know if they will post it or not but check around for it.