/******** basic.c contains basic code for sending data to the LCD and drawing single pixels Copyright 2006 Refik Hadzialic (http://www.e-dsp.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ********/ void sendCMD(byte cmd); void sendData(byte cmd); void shiftBits(byte b); void LCD_put_pixel(unsigned char color, unsigned char x, unsigned char y); /* crude routine that does blind "bit-banging" on SPI it would be ideal to fix this so that the SPI is used properly, but adding the delays works for now */ void shiftBits(byte b) { CLK0 if ((b&128)!=0) SDA1 else SDA0 CLK1 CLK0 if ((b&64)!=0) SDA1 else SDA0 CLK1 CLK0 if ((b&32)!=0) SDA1 else SDA0 CLK1 CLK0 if ((b&16)!=0) SDA1 else SDA0 CLK1 CLK0 if ((b&8)!=0) SDA1 else SDA0 CLK1 CLK0 if ((b&4)!=0) SDA1 else SDA0 CLK1 CLK0 if ((b&2)!=0) SDA1 else SDA0 CLK1 CLK0 if ((b&1)!=0) SDA1 else SDA0 CLK1 } // draw a single colored pixel void LCD_put_pixel(unsigned char color, unsigned char x, unsigned char y){ x += 2; // range goes from 2 to 130 sendCMD(PASET); // page start/end ram sendData(x); sendData(131); sendCMD(CASET); // column start/end ram sendData(y); // for some reason starts at 2 sendData(131); sendCMD(RAMWR); sendData(color); } //send data void sendData(byte data) { CLK0 SDA1 //1 for param CLK1 shiftBits(data); } //send cmd void sendCMD(byte data) { CLK0 SDA0 //1 for cmd CLK1 shiftBits(data); }