I'm attempting to utilize an open-source project called UTFT-Energia.
Unfortunately, when I attempt to test out the code, I receive the following errors:
/UTFT_Bitmap_Launchpad.cpp:34: undefined reference to `UTFT::InitLCD(unsigned char)'
/UTFT_Bitmap_Launchpad.cpp:36: undefined reference to `SmallFont'
/UTFT_Bitmap_Launchpad.cpp:36: undefined reference to `UTFT::setFont(unsigned char*)'
The UTFT class is defined in the header file.
Any help getting this annoying error message to disappear would be appreciated. Thanks in advance!
The header file is UTFT.h:
#ifndef UTFT_h
#define UTFT_h
#define UTFT_VERSION 241
#define LEFT 0
#define RIGHT 9999
#define CENTER 9998
#define PORTRAIT 0
#define LANDSCAPE 1
#define HX8347A 0
#define ILI9327 1
#define SSD1289 2
#define ILI9325C 3
#define ILI9325D_8 4
#define ILI9325D_16 5
#define HX8340B_8 6
#define HX8340B_S 7
#define HX8352A 8
#define ST7735 9
#define PCF8833 10
#define S1D19122 11
#define SSD1963_480 12
#define SSD1963_800 13
#define S6D1121_8 14
#define S6D1121_16 15
#define SSD1289LATCHED 16
#define ILI9320_8 17
#define ILI9320_16 18
#define SSD1289_8 19
#define SSD1963_800ALT 20
#define ILI9481 21
#define ITDB32 0 // HX8347-A (16bit)
#define ITDB32WC 1 // ILI9327 (16bit)
#define TFT01_32W 1 // ILI9327 (16bit)
#define ITDB32S 2 // SSD1289 (16bit)
#define TFT01_32 2 // SSD1289 (16bit)
#define CTE32 2 // SSD1289 (16bit)
#define GEEE32 2 // SSD1289 (16bit)
#define ITDB24 3 // ILI9325C (8bit)
#define ITDB24D 4 // ILI9325D (8bit)
#define ITDB24DWOT 4 // ILI9325D (8bit)
#define ITDB28 4 // ILI9325D (8bit)
#define TFT01_24_8 4 // ILI9325D (8bit)
#define TFT01_24_16 5 // ILI9325D (16bit)
#define ITDB22 6 // HX8340-B (8bit)
#define GEEE22 6 // HX8340-B (8bit)
#define ITDB22SP 7 // HX8340-B (Serial)
#define ITDB32WD 8 // HX8352-A (16bit)
#define TFT01_32WD 8 // HX8352-A (16bit)
#define ITDB18SP 9 // ST7735 (Serial)
#define LPH9135 10 // PCF8833 (Serial)
#define ITDB25H 11 // S1D19122 (16bit)
#define ITDB43 12 // SSD1963 (16bit) 480x272
#define ITDB50 13 // SSD1963 (16bit) 800x480
#define TFT01_50 13 // SSD1963 (16bit) 800x480
#define CTE50 13 // SSD1963 (16bit) 800x480
#define ITDB24E_8 14 // S6D1121 (8bit)
#define ITDB24E_16 15 // S6D1121 (16bit)
#define INFINIT32 16 // SSD1289 (Latched 16bit) -- Legacy, will be removed later
#define ELEE32_REVA 16 // SSD1289 (Latched 16bit)
#define GEEE24 17 // ILI9320 (8bit)
#define GEEE28 18 // ILI9320 (16bit)
#define ELEE32_REVB 19 // SSD1289 (8bit)
#define TFT01_70 20 // SSD1963 (16bit) 800x480 Alternative Init
#define CTE70 20 // SSD1963 (16bit) 800x480 Alternative Init
#define CTE32HR 21 // ILI9481 (16bit)
#define SERIAL_4PIN 4
#define SERIAL_5PIN 5
#define LATCHED_16 17
//*********************************
// COLORS
//*********************************
// VGA color palette
#define VGA_BLACK 0x0000
#define VGA_WHITE 0xFFFF
#define VGA_RED 0xF800
#define VGA_GREEN 0x0400
#define VGA_BLUE 0x001F
#define VGA_SILVER 0xC618
#define VGA_GRAY 0x8410
#define VGA_MAROON 0x8000
#define VGA_YELLOW 0xFFE0
#define VGA_OLIVE 0x8400
#define VGA_LIME 0x07E0
#define VGA_AQUA 0x07FF
#define VGA_TEAL 0x0410
#define VGA_NAVY 0x0010
#define VGA_FUCHSIA 0xF81F
#define VGA_PURPLE 0x8010
#define VGA_TRANSPARENT 0xFFFFFFFF
#if defined(ENERGIA)
#include "Energia.h"
#if defined(__LM4F120H5QR__)
#include "hardware/lm4f/HW_LM4F_defines.h"
#elif defined(__MSP430__)
#include "HW_MSP430_defines.h"
#else
#error "unknown Energia target"
#endif
#elif defined(ARDUINO)
#if defined(__AVR__)
#include "Arduino.h"
#include "hardware/avr/HW_AVR_defines.h"
#elif defined(__arm__)
#include "Arduino.h"
#include "hardware/arm/HW_ARM_defines.h"
#elif defined(__PIC32MX__)
#include "WProgram.h"
#include "hardware/pic32/HW_PIC32_defines.h"
#else
#error "unknown Arduino target"
#endif
#endif
struct _current_font
{
uint8_t* font;
uint8_t x_size;
uint8_t y_size;
uint8_t offset;
uint8_t numchars;
};
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();
/*
The functions and variables below should not normally be used.
They have been left publicly available for use in add-on libraries
that might need access to the lower level functions of UTFT.
Please note that these functions and variables are not documented
and I do not provide support on how to use them.
*/
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;
byte RS, WR, CS, RST, SER;
_current_font cfont;
boolean _transparent;
void initPins();
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);
};
#endif
The cpp file is:
#include "Energia.h"
void setup();
void loop();
// UTFT_Bitmap (C)2012 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a demo of the drawBitmap()-function.
//
// This demo was made to work on the 320x240 modules.
// Any other size displays may cause strange behaviour.
//
// This program requires the UTFT library.
//
#include <UTFT.h>
// Declare which fonts we will be using
extern uint8_t SmallFont[];
UTFT myGLCD(SSD1289_8, P1_4, P1_5, P1_6, P3_2); // Remember to change the model parameter to suit your display module!
extern unsigned short int info[0x400];
extern unsigned short int icon[0x400];
extern unsigned short int tux[0x400];
void setup()
{
Serial.begin(115200);
Serial.println("hello world");
myGLCD.InitLCD();
Serial.println("initialised lcd");
myGLCD.setFont(SmallFont);
Serial.println("set font");
}
void loop()
{
// myGLCD.fillScr(255, 255, 255);
myGLCD.fillScr(0, 0, 0);
Serial.println("filled screen");
myGLCD.setColor(255, 255, 255);
myGLCD.print(" *** A 10 by 7 grid of a 32x32 icon *** ", CENTER, 228);
for (int x=0; x<10; x++)
for (int y=0; y<7; y++)
myGLCD.drawBitmap (x*32, y*32, 32, 32, info);
Serial.println("drew bitmaps");
delay(5000);
myGLCD.fillScr(255, 255, 255);
myGLCD.setColor(255, 255, 255);
myGLCD.print(" Two different icons in scale 1 to 4 ", CENTER, 228);
int x=0;
for (int s=0; s<4; s++)
{
x+=(s*32);
myGLCD.drawBitmap (x, 0, 32, 32, tux, s+1);
}
x=0;
for (int s=4; s>0; s--)
{
myGLCD.drawBitmap (x, 224-(s*32), 32, 32, icon, s);
x+=(s*32);
}
delay(5000);
}