LPC1768 Mini-DK board with 2.8" SPI TFT and SPI touch

Dependencies:   Mini-DK mbed SDFileSystem

WARNING: filetoflash (SD to CPU flash)

The SPI_TFT library called from Mini-DK.lib contains an option to copy an image from the SD card to the CPU flash memory. This allows you to use an image as background without speed loss when writing other text and graphics.

By default, this option is enabled.

It can be disabled by uncommenting the #define mentioned below in Mini_DK.h:

#define NO_FLASH_BUFFER

Since the flash memory has limited write endurance, DO NOT use this feature when you intend to read multiple images from the SD card (eg: when used as a photo frame).

Committer:
frankvnk
Date:
Thu Jan 03 10:54:09 2013 +0000
Revision:
2:d0acbd263ec7
Parent:
SPI_TFT/TextDisplay.cpp@0:ee7076d8260a
Child:
6:b547fb6c1095
ONLY FOR TEST

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frankvnk 0:ee7076d8260a 1 /* mbed TextDisplay Display Library Base Class
frankvnk 0:ee7076d8260a 2 * Copyright (c) 2007-2009 sford
frankvnk 0:ee7076d8260a 3 * Released under the MIT License: http://mbed.org/license/mit
frankvnk 0:ee7076d8260a 4 */
frankvnk 0:ee7076d8260a 5
frankvnk 0:ee7076d8260a 6 #include "TextDisplay.h"
frankvnk 0:ee7076d8260a 7
frankvnk 0:ee7076d8260a 8 TextDisplay::TextDisplay(const char *name) : Stream(name){
frankvnk 0:ee7076d8260a 9 _row = 0;
frankvnk 0:ee7076d8260a 10 _column = 0;
frankvnk 0:ee7076d8260a 11 if (name == NULL) {
frankvnk 0:ee7076d8260a 12 _path = NULL;
frankvnk 0:ee7076d8260a 13 } else {
frankvnk 0:ee7076d8260a 14 _path = new char[strlen(name) + 2];
frankvnk 0:ee7076d8260a 15 sprintf(_path, "/%s", name);
frankvnk 0:ee7076d8260a 16 }
frankvnk 0:ee7076d8260a 17 }
frankvnk 0:ee7076d8260a 18
frankvnk 0:ee7076d8260a 19 int TextDisplay::_putc(int value) {
frankvnk 0:ee7076d8260a 20 if(value == '\n') {
frankvnk 0:ee7076d8260a 21 _column = 0;
frankvnk 0:ee7076d8260a 22 _row++;
frankvnk 0:ee7076d8260a 23 if(_row >= rows()) {
frankvnk 0:ee7076d8260a 24 _row = 0;
frankvnk 0:ee7076d8260a 25 }
frankvnk 0:ee7076d8260a 26 } else {
frankvnk 0:ee7076d8260a 27 character(_column, _row, value);
frankvnk 0:ee7076d8260a 28 _column++;
frankvnk 0:ee7076d8260a 29 if(_column >= columns()) {
frankvnk 0:ee7076d8260a 30 _column = 0;
frankvnk 0:ee7076d8260a 31 _row++;
frankvnk 0:ee7076d8260a 32 if(_row >= rows()) {
frankvnk 0:ee7076d8260a 33 _row = 0;
frankvnk 0:ee7076d8260a 34 }
frankvnk 0:ee7076d8260a 35 }
frankvnk 0:ee7076d8260a 36 }
frankvnk 0:ee7076d8260a 37 return value;
frankvnk 0:ee7076d8260a 38 }
frankvnk 0:ee7076d8260a 39
frankvnk 0:ee7076d8260a 40 // crude cls implementation, should generally be overwritten in derived class
frankvnk 0:ee7076d8260a 41 void TextDisplay::cls() {
frankvnk 0:ee7076d8260a 42 locate(0, 0);
frankvnk 0:ee7076d8260a 43 for(int i=0; i<columns()*rows(); i++) {
frankvnk 0:ee7076d8260a 44 putc(' ');
frankvnk 0:ee7076d8260a 45 }
frankvnk 0:ee7076d8260a 46 }
frankvnk 0:ee7076d8260a 47
frankvnk 0:ee7076d8260a 48 void TextDisplay::locate(int column, int row) {
frankvnk 0:ee7076d8260a 49 _column = column;
frankvnk 0:ee7076d8260a 50 _row = row;
frankvnk 0:ee7076d8260a 51 }
frankvnk 0:ee7076d8260a 52
frankvnk 0:ee7076d8260a 53 int TextDisplay::_getc() {
frankvnk 0:ee7076d8260a 54 return -1;
frankvnk 0:ee7076d8260a 55 }
frankvnk 0:ee7076d8260a 56
frankvnk 0:ee7076d8260a 57 void TextDisplay::foreground(uint16_t colour) {
frankvnk 0:ee7076d8260a 58 _foreground = colour;
frankvnk 0:ee7076d8260a 59 }
frankvnk 0:ee7076d8260a 60
frankvnk 0:ee7076d8260a 61 void TextDisplay::background(uint16_t colour) {
frankvnk 0:ee7076d8260a 62 _background = colour;
frankvnk 0:ee7076d8260a 63 }
frankvnk 0:ee7076d8260a 64
frankvnk 0:ee7076d8260a 65 bool TextDisplay::claim (FILE *stream) {
frankvnk 0:ee7076d8260a 66 if ( _path == NULL) {
frankvnk 0:ee7076d8260a 67 fprintf(stderr, "claim requires a name to be given in the instantioator of the TextDisplay instance!\r\n");
frankvnk 0:ee7076d8260a 68 return false;
frankvnk 0:ee7076d8260a 69 }
frankvnk 0:ee7076d8260a 70 if (freopen(_path, "w", stream) == NULL) {
frankvnk 0:ee7076d8260a 71 // Failed, should not happen
frankvnk 0:ee7076d8260a 72 return false;
frankvnk 0:ee7076d8260a 73 }
frankvnk 0:ee7076d8260a 74 // make sure we use line buffering
frankvnk 0:ee7076d8260a 75 setvbuf(stdout, NULL, _IOLBF, columns());
frankvnk 0:ee7076d8260a 76 return true;
frankvnk 0:ee7076d8260a 77 }