Okay. Understood. I was just reading some more about it, and library creation etc. the class definition doesnt look right in the Liquidcrystal one but here it is. I see what you are saying about the .Print comand
This is the utft class from the .cpp file. Sorry codes ran together. LCD is halfway down
class UTFT
{
public:
UTFT();
UTFT(byte model, int RS, int WR,int CS, int RST, int SER=0);
void InitLCD(byte orientation=LANDSCAPE);
void clrScr();
void drawPixel(int x, int y);
void drawLine(int x1, int y1, int x2, int y2);
void fillScr(byte r, byte g, byte b);
void fillScr(word color);
void drawRect(int x1, int y1, int x2, int y2);
void drawRoundRect(int x1, int y1, int x2, int y2);
void fillRect(int x1, int y1, int x2, int y2);
void fillRoundRect(int x1, int y1, int x2, int y2);
void drawCircle(int x, int y, int radius);
void fillCircle(int x, int y, int radius);
void setColor(byte r, byte g, byte b);
void setColor(word color);
word getColor();
void setBackColor(byte r, byte g, byte b);
void setBackColor(uint32_t color);
word getBackColor();
void print(char *st, int x, int y, int deg=0);
void print(String st, int x, int y, int deg=0);
void printNumI(long num, int x, int y, int length=0, char filler=' ');
void printNumF(double num, byte dec, int x, int y, char divider='.', int length=0, char filler=' ');
void setFont(uint8_t* font);
uint8_t* getFont();
uint8_t getFontXsize();
uint8_t getFontYsize();
void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int scale=1);
void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int deg, int rox, int roy);
void lcdOff();
void lcdOn();
void setContrast(char c);
int getDisplayXSize();
int getDisplayYSize();
byte fch, fcl, bch, bcl;
byte orient;
long disp_x_size, disp_y_size;
byte display_model, display_transfer_mode, display_serial_mode;
regtype *P_RS, *P_WR, *P_CS, *P_RST, *P_SDA, *P_SCL, *P_ALE;
regsize B_RS, B_WR, B_CS, B_RST, B_SDA, B_SCL, B_ALE;
_current_font cfont;
boolean _transparent;
void LCD_Writ_Bus(char VH,char VL, byte mode);
void LCD_Write_COM(char VL);
void LCD_Write_DATA(char VH,char VL);
void LCD_Write_DATA(char VL);
void LCD_Write_COM_DATA(char com1,int dat1);
void _hw_special_init();
void setPixel(word color);
void drawHLine(int x, int y, int l);
void drawVLine(int x, int y, int l);
void printChar(byte c, int x, int y);
void setXY(word x1, word y1, word x2, word y2);
void clrXY();
void rotateChar(byte c, int x, int y, int pos, int deg);
void _set_direction_registers(byte mode);
void _fast_fill_16(int ch, int cl, long pix);
void _fast_fill_8(int ch, long pix);
void _convert_float(char *buf, double num, int width, byte prec);
};
And the LCD class from the .cpp file
[code]
#include "LiquidCrystal_SPI_8Bit.h"
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "WProgram.h"
// LiquidCrystal_SPI_8Bit constructor is called).
LiquidCrystal_SPI_8Bit::LiquidCrystal_SPI_8Bit(uint8_t rs, uint8_t enable)
{
init(rs, 255, enable);
}
void LiquidCrystal_SPI_8Bit::init(uint8_t rs, uint8_t rw, uint8_t enable)
{
pinMode(13, OUTPUT);
pinMode(12, INPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
// set control register enable, master, MSBF, and mode00
SPCR = (1<<SPE)|(1<<MSTR);
//SPSR = (1<<SPI2X); // Uncomment this line for double clock speed
_rs_pin = rs;
_rw_pin = rw;
_enable_pin = enable;
pinMode(_rs_pin, OUTPUT);
// we can save 1 pin by not using RW. Indicate by passing 255 instead of pin#
if (_rw_pin != 255) {
pinMode(_rw_pin, OUTPUT);
}
pinMode(_enable_pin, OUTPUT);
digitalWrite(_enable_pin, LOW);
_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
begin(16, 1);
}
void LiquidCrystal_SPI_8Bit::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
if (lines > 1) {
_displayfunction |= LCD_2LINE;
}
_numlines = lines;
_currline = 0;
// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1)) {
_displayfunction |= LCD_5x10DOTS;
}
delayMicroseconds(50000);
digitalWrite(_rs_pin, LOW);
digitalWrite(_enable_pin, LOW);
if (_rw_pin != 255) {
digitalWrite(_rw_pin, LOW);
}
//put the LCD into 8 bit mode
/
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(4500); // wait more than 4.1ms
// second try
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(150);
// third go
command(LCD_FUNCTIONSET | _displayfunction);
// finally, set # lines, font size, etc.
command(LCD_FUNCTIONSET | _displayfunction);
// turn the display on with no cursor or blinking default
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
display();
// clear it off
clear();
// Initialize to default text direction (for romance languages)
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
// set the entry mode
command(LCD_ENTRYMODESET | _displaymode);
}
/********** high level commands, for the user! */
void LiquidCrystal_SPI_8Bit::clear()
{
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
}
void LiquidCrystal_SPI_8Bit::home()
{
command(LCD_RETURNHOME); // set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
}
void LiquidCrystal_SPI_8Bit::setCursor(uint8_t col, uint8_t row)
{
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if ( row > _numlines ) {
row = _numlines-1; // we count rows starting w/0
}
command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
}
// Turn the display on/off (quickly)
void LiquidCrystal_SPI_8Bit::noDisplay() {
_displaycontrol &= ~LCD_DISPLAYON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal_SPI_8Bit::display() {
_displaycontrol |= LCD_DISPLAYON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
// Turns the underline cursor on/off
void LiquidCrystal_SPI_8Bit::noCursor() {
_displaycontrol &= ~LCD_CURSORON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal_SPI_8Bit::cursor() {
_displaycontrol |= LCD_CURSORON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
// Turn on and off the blinking cursor
void LiquidCrystal_SPI_8Bit::noBlink() {
_displaycontrol &= ~LCD_BLINKON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal_SPI_8Bit::blink() {
_displaycontrol |= LCD_BLINKON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
// These commands scroll the display without changing the RAM
void LiquidCrystal_SPI_8Bit::scrollDisplayLeft(void) {
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
}
void LiquidCrystal_SPI_8Bit::scrollDisplayRight(void) {
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
}
// This is for text that flows Left to Right
void LiquidCrystal_SPI_8Bit::leftToRight(void) {
_displaymode |= LCD_ENTRYLEFT;
command(LCD_ENTRYMODESET | _displaymode);
}
// This is for text that flows Right to Left
void LiquidCrystal_SPI_8Bit::rightToLeft(void) {
_displaymode &= ~LCD_ENTRYLEFT;
command(LCD_ENTRYMODESET | _displaymode);
}
// This will 'right justify' text from the cursor
void LiquidCrystal_SPI_8Bit::autoscroll(void) {
_displaymode |= LCD_ENTRYSHIFTINCREMENT;
command(LCD_ENTRYMODESET | _displaymode);
}
// This will 'left justify' text from the cursor
void LiquidCrystal_SPI_8Bit::noAutoscroll(void) {
_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
command(LCD_ENTRYMODESET | _displaymode);
}
// Allows us to fill the first 8 CGRAM locations
// with custom characters
void LiquidCrystal_SPI_8Bit::createChar(uint8_t location, uint8_t charmap[]) {
location &= 0x7; // we only have 8 locations 0-7
command(LCD_SETCGRAMADDR | (location << 3));
for (int i=0; i<8; i++) {
write(charmap[i]);
}
}
/*********** mid level commands, for sending data/cmds */
inline void LiquidCrystal_SPI_8Bit::command(uint8_t value) {
send(value, LOW);
}
inline void LiquidCrystal_SPI_8Bit::write(uint8_t value) {
send(value, HIGH);
}
/************ low level data pushing commands **********/
// write either command or data, with automatic 4/8-bit selection
void LiquidCrystal_SPI_8Bit::send(uint8_t value, uint8_t mode) {
digitalWrite(_rs_pin, mode);
// if there is a RW pin indicated, set it low to Write
if (_rw_pin != 255) {
digitalWrite(_rw_pin, LOW);
}
SPDR = value;
while(!(SPSR & (1<<SPIF)));
pulseEnable();
}
void LiquidCrystal_SPI_8Bit::pulseEnable(void) {
digitalWrite(_enable_pin, LOW);
delayMicroseconds(1);
digitalWrite(_enable_pin, HIGH);
delayMicroseconds(1); // enable pulse must be >450ns
digitalWrite(_enable_pin, LOW);
delayMicroseconds(100); // commands need > 37us to settle
}
[/code]