Fork of the Adafruit ST7735R library targeted to the 1.44" TFT with custom high speed monochrome and color drawing routines. Note that this library includes modifications to use a shared SPI module to simplify projects that use the SPI for several peripherals. Read the WIKI to see how to get this library working in your own project.

Fork of Adafruit_ST7735 by Andrew Lindsay

This library is a modification of Andrew Lindsay's ST7735 Adafruit library. It includes custom bitmap drawing routines that work around 15 times faster when using custom byte arrays generated by my png to char array converter.

For more info look to the detailed post explaining the changes and where you can download the converter binaries as well: http://alfredoer.com/microcontrollers-2/adafruit-image-bitmap-generator/

IMPORTANT: One of the main modifications is that this library does not instantiate an SPI object directly, rather it is meant to use a shared SPI object exported in a "board.h" file elsewhere in your project.

The contents of such a file can be something like:

ifndef BOARD_H_

  1. define BOARD_H_
  1. include <mbed.h>
  2. include <rtos.h> extern Mutex spi_mutex; extern SPI spi_port;
  1. endif

And of course, the objects should be instantiated somewhere (like in board.c) like this (for a KL25z, modify as needed):

mosi, miso, sck Mutex spi_mutex; SPI spi_port( PTD2, PTD3, PTD1);

The rationale is that several modules can use the hardware SPI port on several threads and coexist happily with each other.

Revision:
4:2eb7d188ba43
Parent:
3:38c4a70421f0
Child:
5:57e689b2af4f
--- a/Adafruit_ST7735.h	Thu Jan 15 21:00:58 2015 +0000
+++ b/Adafruit_ST7735.h	Sat Jan 24 21:32:09 2015 +0000
@@ -16,11 +16,11 @@
   MIT license, all text above must be included in any redistribution
  ****************************************************/
 
-#ifndef _ADAFRUIT_ST7735H_
-#define _ADAFRUIT_ST7735H_
+#pragma once
 
 #include "mbed.h"
 #include "Adafruit_GFX.h"
+#include "N3310LCDDefs.h"
 #include "board.h"
 #define boolean bool
 
@@ -106,14 +106,19 @@
 #define WHITE   0xFFFF
 
 
+
+
 class Adafruit_ST7735 : public Adafruit_GFX {
 
  public:
 
-  Adafruit_ST7735( PinName CS, PinName RS, PinName RST, PinName LITE);
+  Adafruit_ST7735( PinName CS, PinName RS, PinName RST, PinName BL);
 
   void     initB(void);                             // for ST7735B displays
   void     initR(uint8_t options = INITR_GREENTAB); // for ST7735R
+  void     backlight( uint8_t setting );
+  void     writeString( int x, int row, char * str, int flag );
+  void     writeString( int x, int row, char * str, int flag, char size );
   void     setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
   void     pushColor(uint16_t color);
 
@@ -124,10 +129,14 @@
   void     fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
   void     invertDisplay(boolean i);
 
-  void     bitmap(int16_t x, int16_t y, int16_t w, int16_t h, const unsigned char *bitmap );
-  void     setRotation(uint8_t r);
-  uint16_t Color565(uint8_t r, uint8_t g, uint8_t b);
+  
+  void     bitmap( int16_t x, int16_t y, int16_t w, int16_t h, const unsigned char *map );
+  void     bitmapBW(int16_t x, int16_t y, const unsigned char *map, int16_t w, int16_t h, int16_t foreground, int16_t background );
+                                
+  void     setRotation( uint8_t r);
+  uint16_t Color565( uint8_t r, uint8_t g, uint8_t b );
 
+  
  private:
 
   void     spiwrite(uint8_t),
@@ -142,6 +151,5 @@
     DigitalOut _cs;         // does SPI CE
     DigitalOut _rs;         // register/date select
     DigitalOut _rst;        // does 3310 LCD_RST
+    DigitalOut _bl;        // backlight
 };
-
-#endif