MSPM0_ValvanoWare  1.0
ECE445L starter code
Files | Macros | Enumerations | Functions
Display

OLED and LCD displays. More...

Files

file  Arabic.h
 Arabic output to LCD.
 
file  I2C.h
 Software driver functions for I2C and MKII boosterpack.
 
file  LCD.h
 LCD on MKII boosterpack.
 
file  SSD1306.h
 Provide simple I/O functions for the SSD 1306 OLED.
 
file  ST7735.h
 160 by 128 pixel LCD
 
file  ST7735_SDC.h
 160 by 128 pixel LCD with SDC
 

Macros

#define LCD_BLACK   0x0000
 The following constants are possible colors for the LCD in RGB format.
 
#define LCD_BLUE   0x001F
 
#define LCD_DARKBLUE   0x34BF
 
#define LCD_RED   0xF800
 
#define LCD_GREEN   0x07E0
 
#define LCD_LIGHTGREEN   0x07EF
 
#define LCD_ORANGE   0xFD60
 
#define LCD_CYAN   0x07FF
 
#define LCD_MAGENTA   0xF81F
 
#define LCD_YELLOW   0xFFE0
 
#define LCD_WHITE   0xFFFF
 
#define LCD_GREY   0x8410
 
#define STANDARD_GALACTIC_ALPHABET   0
 Set STANDARD_GALACTIC_ALPHABET to 1 for Commander Keen alphabet.
 
#define SSD1306_BLACK   0
 Black is 0 or off.
 
#define SSD1306_WHITE   1
 White is 1 or on.
 
#define SSD1306_INVERSE   2
 Inverse will flip bits.
 
#define SSD1306_EXTERNALVCC   0x01
 SSD1306_EXTERNALVCC specifies External display voltage source.
 
#define SSD1306_SWITCHCAPVCC   0x02
 SSD1306_SWITCHCAPVCC specifies display voltage from 3.3V.
 
#define true   1
 true means success
 
#define false   0
 false means failure
 
#define ST7735_TFTWIDTH   128
 128 pixels wide
 
#define ST7735_TFTHEIGHT   160
 160 pixels tall
 
#define ST7735_BLACK   0x0000
 The following constants are possible colors for the LCD in RGB format.
 
#define ST7735_BLUE   0xF800
 
#define ST7735_RED   0x001F
 
#define ST7735_GREEN   0x07E0
 
#define ST7735_CYAN   0xFFE0
 
#define ST7735_MAGENTA   0xF81F
 
#define ST7735_YELLOW   0x07FF
 
#define ST7735_WHITE   0xFFFF
 
#define ST7735_LIGHTGREY   ST7735_Color565(228,228,228)
 
#define ST7735_DARKGREY   ST7735_Color565(32,32,32)
 
#define ST7735_ORANGE   ST7735_Color565(255,102,0)
 
#define ST7735_PURPLE   ST7735_Color565(106,13,173)
 
#define ST7735_TFTWIDTH   128
 128 pixels wide
 
#define ST7735_TFTHEIGHT   160
 160 pixels tall
 
#define ST7735_COLOR565(r, g, b)   ((uint16_t)((b << 8) | (g << 3) | (r >> 3)))
 Converts r,b,g into 16 bit colors for the LCD in RGB format.
 
#define ST7735_BLACK   (uint16_t)0x0000
 The following constants are possible colors for the LCD in RGB format.
 
#define ST7735_BLUE   (uint16_t)0xF800
 
#define ST7735_RED   (uint16_t)0x001F
 
#define ST7735_GREEN   (uint16_t)0x07E0
 
#define ST7735_CYAN   (uint16_t)0xFFE0
 
#define ST7735_MAGENTA   (uint16_t)0xF81F
 
#define ST7735_YELLOW   (uint16_t)0x07FF
 
#define ST7735_WHITE   (uint16_t)0xFFFF
 
#define ST7735_LIGHTGREY   ST7735_COLOR565(228,228,228)
 
#define ST7735_GREY   ST7735_COLOR565(128,128,128)
 
#define ST7735_DARKGREY   ST7735_COLOR565(32,32,32)
 
#define ST7735_ORANGE   ST7735_COLOR565(255,102,0)
 
#define ST7735_PURPLE   ST7735_COLOR565(106,13,173)
 

Enumerations

enum  Arabic_t {
  null , alif , ayh , baa ,
  daad , daal , dhaa , dhaal ,
  faa , ghayh , haa , ha ,
  jeem , kaaf , khaa , laam ,
  meem , noon , qaaf , raa ,
  saad , seen , sheen , ta ,
  thaa , twe , waaw , yaa ,
  zaa , space , dot
}
 Arabic character set.
 
enum  initRFlags {
  none , INITR_GREENTAB , INITR_REDTAB , INITR_BLACKTAB ,
  none , INITR_GREENTAB , INITR_REDTAB , INITR_BLACKTAB
}
 some flags for ST7735_InitR()
 
enum  initRFlags {
  none , INITR_GREENTAB , INITR_REDTAB , INITR_BLACKTAB ,
  none , INITR_GREENTAB , INITR_REDTAB , INITR_BLACKTAB
}
 some flags for ST7735_InitR()
 

Functions

void Arabic_SetCursor (uint32_t newX, uint32_t newY)
 Move Arabic cursor. More...
 
void Arabic_OutChar (Arabic_t ch)
 Output an Arabic character. More...
 
void Arabic_OutString (Arabic_t *ptr)
 Output an Arabic string. More...
 
void I2C_Init (void)
 Initialize I2C. More...
 
uint8_t I2C_Recv1 (int8_t slave)
 Receive one byte. More...
 
uint16_t I2C_Recv2 (int8_t slave)
 Receive two bytes. More...
 
int I2C_Send (uint8_t slave, uint8_t *pData, uint32_t count)
 write 1 to 8 bytes to I2C. More...
 
int I2C_SendData (uint8_t slave, uint8_t *pData, uint32_t count)
 send large buffer to I2C. More...
 
int I2C_Send1 (int8_t slave, uint8_t data)
 Send one byte. More...
 
int I2C_Send2 (int8_t slave, uint8_t data1, uint8_t data2)
 Send two bytes. More...
 
int I2C_Send3 (int8_t slave, uint8_t data1, uint8_t data2, uint8_t data3)
 Send three bytes. More...
 
void I2C_LightSensor_Init (void)
 Initialize OPT3001. More...
 
uint32_t I2C_LightSensor_Input (void)
 Input from OPT3001. More...
 
void I2C_LightSensor_Start (void)
 Start OPT3001. More...
 
int I2C_LightSensor_End (uint32_t *light)
 Finish OPT3001. More...
 
void I2C_TempSensor_Init (void)
 Initialize TMP006. More...
 
void I2C_TempSensor_Input (int32_t *sensorV, int32_t *localT)
 Input from TMP006. More...
 
void I2C_TempSensor_Start (void)
 Start TMP006. More...
 
int I2C_TempSensor_End (int32_t *sensorV, int32_t *localT)
 Finish TMP006. More...
 
void LCD_Init (void)
 Initialize MKII LCD. More...
 
void LCD_DrawPixel (int16_t x, int16_t y, uint16_t color)
 Color one pixel. More...
 
void LCD_DrawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 Draw a vertical line. More...
 
void LCD_DrawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 Draw a horizontal line. More...
 
void LCD_FillScreen (uint16_t color)
 Fill the screen. More...
 
void LCD_FillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 Draw a filled rectangle. More...
 
uint16_t LCD_Color565 (uint8_t r, uint8_t g, uint8_t b)
 RGB to color creation. More...
 
uint16_t LCD_SwapColor (uint16_t x)
 Swaps red and blue. More...
 
void LCD_DrawBitmap (int16_t x, int16_t y, const uint16_t *image, int16_t w, int16_t h)
 Displays a BMP image. More...
 
void LCD_DrawCharS (int16_t x, int16_t y, char c, int16_t textColor, int16_t bgColor, uint8_t size)
 Draw a character. More...
 
void LCD_DrawChar (int16_t x, int16_t y, char c, int16_t textColor, int16_t bgColor, uint8_t size)
 Draw a character. More...
 
uint32_t LCD_DrawString (uint16_t x, uint16_t y, char *pt, int16_t textColor)
 Draw a string. More...
 
void LCD_SetCursor (uint32_t newX, uint32_t newY)
 Move the cursor. More...
 
void LCD_OutUDec (uint32_t n, int16_t textColor)
 Output an unsigned decimal. More...
 
void LCD_OutUDec4 (uint32_t n, int16_t textColor)
 Output a 4-digit unsigned decimal. More...
 
void LCD_OutUDec5 (uint32_t n, int16_t textColor)
 Output a 5-digit unsigned decimal. More...
 
void LCD_OutUFix2_1 (uint32_t n, int16_t textColor)
 Output a 2-digit fixed-point decimal. More...
 
void LCD_OutUHex2 (uint32_t n, int16_t textColor)
 Output a 2-digit hexadecimal number. More...
 
void LCD_OutChar (char ch)
 Output a character. More...
 
void LCD_OutString (char *ptr)
 Output a string. More...
 
void LCD_SetTextColor (uint16_t color)
 sets the text color More...
 
void LCD_Drawaxes (uint16_t axisColor, uint16_t bgColor, char *xLabel, char *yLabel1, uint16_t label1Color, char *yLabel2, uint16_t label2Color, int32_t ymax, int32_t ymin)
 Initializes a plot. More...
 
void LCD_PlotPoint (int32_t data1, uint16_t color1)
 Plot one point. More...
 
void LCD_PlotIncrement (void)
 Moves the plot cursor in time. More...
 
int SSD1306_Init (int vccst)
 II2 driver for SSD1306 OLED display. More...
 
void SSD1306_OutBuffer (void)
 
void SSD1306_InvertDisplay (int i)
 Enable or disable display invert mode (white-on-black vs black-on-white). More...
 
void SSD1306_Dim (int dim)
 Dim the display. More...
 
void SSD1306_DrawPixel (int16_t x, int16_t y, uint16_t color)
 Set/clear/invert a single pixel. This is also invoked by the Adafruit_GFX library in generating many higher-level graphics primitives. More...
 
void SSD1306_DrawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 Draw a horizontal line. This is also invoked by the Adafruit_GFX library in generating many higher-level graphics primitives. More...
 
void SSD1306_DrawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 Draw a vertical line. This is also invoked by the Adafruit_GFX library in generating many higher-level graphics primitives. More...
 
void SSD1306_startscrollright (uint8_t start, uint8_t stop)
 Activate a right-handed scroll for all or part of the display. More...
 
void SSD1306_startscrollleft (uint8_t start, uint8_t stop)
 Activate a left-handed scroll for all or part of the display. More...
 
void SSD1306_startscrolldiagright (uint8_t start, uint8_t stop)
 Activate a diagonal scroll for all or part of the display. More...
 
void SSD1306_startscrolldiagleft (uint8_t start, uint8_t stop)
 Activate alternate diagonal scroll for all or part of the display. More...
 
void SSD1306_stopscroll (void)
 Cease a previously-begun scrolling action. More...
 
int SSD1306_GetPixel (int16_t x, int16_t y)
 Return color of a single pixel in display buffer. More...
 
uint8_t * SSD1306_getBuffer (void)
 Get base address of display buffer for direct reading or writing. More...
 
void SSD1306_DrawChar (int16_t x, int16_t y, char letter, uint16_t color)
 Draw a character. More...
 
void SSD1306_DrawString (int16_t x, int16_t y, char *pt, uint16_t color)
 Draw a string. More...
 
void SSD1306_DrawUDec (int16_t x, int16_t y, uint16_t n, uint16_t color)
 Draw a 3 digit integer. More...
 
void SSD1306_ClearBuffer (void)
 Clear contents of display buffer (set all pixels to off). More...
 
void SSD1306_OutClear (void)
 Clear the LCD by writing zeros to the entire screen and reset the cursor to (0,0) (top left corner of screen). More...
 
void SSD1306_DrawFullImage (const uint8_t *ptr)
 Fill the whole screen by drawing a 128x64 bitmap image. More...
 
void SSD1306_DrawBMP (uint8_t xpos, uint8_t ypos, const uint8_t *ptr, uint8_t threshold, uint16_t color)
 Draw a raw bitmap to the RAM buffer. More...
 
void SSD1306_SetCursor (uint16_t newX, uint16_t newY)
 
void SSD1306_OutChar (char data)
 Print a character to the OLED. More...
 
void SSD1306_OutString (char *ptr)
 Print a string of characters to the OLED. More...
 
void SSD1306_OutUDec (uint16_t n)
 Print a 16-bit unsigned number to the OLED. More...
 
void SSD1306_OutSDec (int16_t n)
 Print a 16-bit signed number to the OLED. More...
 
void SSD1306_OutUFix1 (uint16_t n)
 Print a 16-bit unsigned fixed-point number to the OLED. More...
 
void SSD1306_OutU3Fix1 (uint16_t n)
 Print a 16-bit unsigned fixed-point number to the OLED. More...
 
void SSD1306_OutSFix1 (int32_t n)
 Print a 32-bit signed fixed-point number to the OLED. More...
 
void SSD1306_OutHex7 (uint8_t n)
 Print one hex digit. More...
 
void SSD1306_OutUHex7 (uint8_t n)
 Print two hex digits. More...
 
void SSD1306_OutUHex32 (uint32_t n)
 Print 16 hex digits. More...
 
void SSD1306_OutUDec16 (uint32_t n)
 Print three decimal digits. More...
 
void SSD1306_OutUDec2 (uint32_t n)
 Print two decimal digits. More...
 
void SSD1306_SetPlot (int32_t minX, int32_t maxX, int32_t minY, int32_t maxY, uint16_t color)
 Initialize parameters for plotting. More...
 
void SSD1306_DrawPoint (int32_t x, int32_t y)
 Set/clear/invert a single pixel. SSD1306_SetPlot initializes scaling. More...
 
void SSD1306_InitPrintf (void)
 Initialize the SSD1306 for printf. More...
 
void ST7735_InitB (void)
 Initialize ST7735B LCD. More...
 
void ST7735_InitR (enum initRFlags option)
 Initialize ST7735R LCD. More...
 
void ST7735_DrawPixel (int16_t x, int16_t y, uint16_t color)
 Color one pixel. More...
 
void ST7735_DrawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 Draw a vertical line. More...
 
void ST7735_DrawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 Draw a horizontal line. More...
 
void ST7735_FillScreen (uint16_t color)
 Fill the screen. More...
 
void ST7735_FillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 Draw a filled rectangle. More...
 
void ST7735_DrawSmallCircle (int16_t x, int16_t y, uint16_t color)
 Draw a small circle. More...
 
void ST7735_DrawCircle (int16_t x, int16_t y, uint16_t color)
 Draw a circle. More...
 
uint16_t ST7735_Color565 (uint8_t r, uint8_t g, uint8_t b)
 RGB to color creation. More...
 
uint16_t ST7735_SwapColor (uint16_t x)
 Swaps red and blue. More...
 
void ST7735_DrawBitmap (int16_t x, int16_t y, const uint16_t *image, int16_t w, int16_t h)
 Displays a BMP image. More...
 
void ST7735_DrawCharS (int16_t x, int16_t y, char c, int16_t textColor, int16_t bgColor, uint8_t size)
 Draw a character. More...
 
void ST7735_DrawChar (int16_t x, int16_t y, char c, int16_t textColor, int16_t bgColor, uint8_t size)
 Draw a character. More...
 
uint32_t ST7735_DrawString (uint16_t x, uint16_t y, char *pt, int16_t textColor)
 Draw a string. More...
 
void ST7735_SetCursor (uint32_t newX, uint32_t newY)
 Move the cursor. More...
 
void ST7735_OutUDec (uint32_t n)
 Output an unsigned decimal. More...
 
void ST7735_OutUDec4 (uint32_t n)
 Output a 4-digit unsigned decimal. More...
 
void ST7735_OutUDec5 (uint32_t n)
 Output a 5-digit unsigned decimal. More...
 
void ST7735_OutUFix2_1 (uint32_t n, int16_t textColor)
 Output a 2-digit fixed-point decimal. More...
 
void ST7735_OutUHex2 (uint32_t n, int16_t textColor)
 Output a 2-digit hexadecimal number. More...
 
void ST7735_SetRotation (uint8_t m)
 Change rotation. More...
 
void ST7735_InvertDisplay (int i)
 invert display More...
 
void ST7735_Drawaxes (uint16_t axisColor, uint16_t bgColor, char *xLabel, char *yLabel1, uint16_t label1Color, char *yLabel2, uint16_t label2Color, int32_t ymax, int32_t ymin)
 Initializes a plot. More...
 
void ST7735_PlotClear (int32_t ymin, int32_t ymax)
 Clear plot. More...
 
void ST7735_PlotPoint (int32_t y)
 Plot one point. More...
 
void ST7735_PlotPoint2 (int32_t data1, uint16_t color1)
 Plot one point with color. More...
 
void ST7735PlotIncrement (void)
 Moves the plot cursor in time. More...
 
void ST7735_PlotLine (int32_t y)
 Plot one line. More...
 
void ST7735_PlotPoints (int32_t y1, int32_t y2)
 Plot two points. More...
 
void ST7735_PlotBar (int32_t y)
 Plot one bar. More...
 
void ST7735_PlotdBfs (int32_t y)
 Plot one bar. More...
 
void ST7735_PlotNext (void)
 Move x-axis parameter. More...
 
void ST7735_PlotNextErase (void)
 Move X coordinate
More...
 
void ST7735_OutChar (char ch)
 Output a character. More...
 
void ST7735_OutCharTransparent (char ch)
 Output a character transparently. More...
 
void ST7735_OutString (char *ptr)
 Output a string. More...
 
void ST7735_OutStringTransparent (char *ptr)
 Output a string transparently. More...
 
void ST7735_SetTextColor (uint16_t color)
 sets the text color More...
 
void ST7735_InitPrintf (enum initRFlags option)
 use ST7735 LCD to output from printf More...
 
void ST7735_sDecOut2 (int32_t n)
 fixed point output resolution 0.01 More...
 
void ST7735_uBinOut6 (uint32_t n)
 fixed point output resolution 1/64 More...
 
void ST7735_XYplotInit (char *title, int32_t minX, int32_t maxX, int32_t minY, int32_t maxY)
 initialize XY plot More...
 
void ST7735_XYplot (uint32_t num, int32_t bufX[], int32_t bufY[])
 XY plot. More...
 
void ST7735_Line (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
 Draws line. More...
 
void ST7735_SetX (int32_t newX)
 set X-position More...
 
void ST7735_DrawLine (int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color)
 draw line More...
 
void ST7735_OutSDec2 (int32_t n, uint32_t l)
 Output a signed decimal. More...
 
void ST7735_InitPrintf (void)
 Use ST7735 LCD to output from printf. More...
 

Detailed Description

OLED and LCD displays.

Adafruit ST7735R pins
Pin Connection Description
10+3.3Backlight
9 nc SPI1 MISO (used for SDC)
8 PB9 SPI1 SCLK clock out
7 PB8 SPI1 PICO data out
6 PB6 SPI1 CS0=TFT_CS
5 nc CARD_CS (used for SDC)
4 PA13Data/Command(GPIO), high for data, low for command
3 PB15RESET, low to reset, (GPIO)
2 +3.3VCC
1 Gnd ground
wide.hk ST7735R with ADXL345 accelerometer pins
PinConnection
VCC +3.3 V
GND Ground
!SCL SPI1 SCLK: PB9 clock
!SDA SPI1 PICO: PB8 MOSI SPI data from microcontroller to TFT or SDC
DC GPIO PA13 TFT data/command
RES GPIO PB15 TFT reset
CS SPI1 CS0: PB6 TFT_CS, active low to enable TFT
*CS (NC) SDC_CS, active low to enable SDC
MISO (NC) MISO SPI data from SDC to microcontroller
SDA (NC) I2C data for ADXL345 accelerometer
SCL (NC) I2C clock for ADXL345 accelerometer
SDO (NC) I2C alternate address for ADXL345 accelerometer
Backlight + - Light, backlight connected to +3.3 V
wide.hk ST7735R with ADXL335 accelerometer pins
PinConnection
VCC +3.3 V
GND Ground /
!SCLSPI1 SCLK: PB9
!SDA SPI1 PICO: PB8 MOSI SPI data from microcontroller to TFT or SDC
DC GPIO PA13 TFT data/command
RES GPIO PB15 TFT reset
CS SPI1 CS0: PB6 TFT_CS, active low to enable TFT
*CS (NC) SDC_CS, active low to enable SDC
MISO (NC) MISO SPI data from SDC to microcontroller
X(NC) analog input X-axis from ADXL335 accelerometer
Y(NC) analog input Y-axis from ADXL335 accelerometer
Z(NC) analog input Z-axis from ADXL335 accelerometer
Backlight + Light, backlight connected to +3.3 V
HiLetgo ST7735 TFT and SDC pins
signalPinConnection
LED- 16TFT, to ground
LED+ 15TFT, to +3.3 V
SD_CS 14SDC, to chip select
MOSI 13SDC, to MOSI
MISO 12SDC, to MISO
SCK 11SDC, to serial clock
CS 10TFT, to PB6 SPI1 CS0
SCL 9TFT, to PB9 SPI1 SCLK
SDA 8TFT, to PB8 MOSI SPI1 PICO
A0 7TFT, to PA13 Data/Command, high for data, low for command
RESET 6TFT, to PB15 reset (GPIO), low to reset
NC 3,4,5not connected
VCC 2to +3.3 V
GND 1to ground
Tyenaza Tyenazaqhf72mi9s3 pins
signalPinConnection
LED 8to +3.3 V
SCK 7SCLK to PB9 SPI1 SCLK
SDA 6MOSI, to PB8 SPI1 PICO
A0 5Data/Command to PA13 (GPIO), high for data, low for command
RESET 4to PB15 (GPIO), low to reset
CS 3to PB6 SPI1 CS0:
Gnd 2to ground
VCC 1to +3.3 V
MKII sensor pins
Pin FunctionDescription
PA27GPIO J1.8 ambient light (OPT3001) interrupt (digital)
PB2 I2C1-SCLJ1.9 ambient light (OPT3001) and temperature sensor (TMP006)
PB3 I2C1-SDAJ1.10 ambient light (OPT3001) and temperature sensor (TMP006)
PB16GPIO J2.11 temperature sensor (TMP006) interrupt (digital)
MKII LCD pins
Pin Function Description
PB9 SPI1 SCLK J1.7 LCD SPI clock (SPI)
PB6 SPI1 CS0 J2.13 LCD SPI CS (SPI)
PB8 SPI1 PICO J2.15 LCD SPI data (SPI)
PB15GPIO J2.17 LCD !RST (digital)
PA13GPIO J4.31 LCD RS (digital)
Adafruit ST7735R pins
Pin Connection Description
10+3.3Backlight
9 nc SPI1 MISO (used for SDC)
8 PB9 SPI1 SCLK clock out
7 PB8 SPI1 PICO data out
6 PB6 SPI1 CS0=TFT_CS
5 nc CARD_CS (used for SDC)
4 PA13Data/Command(GPIO), high for data, low for command
3 PB15RESET, low to reset, (GPIO)
2 +3.3VCC
1 Gnd ground
wide.hk ST7735R with ADXL345 accelerometer pins
PinConnection
VCC +3.3 V
GND Ground
!SCL SPI1 SCLK: PB9 clock
!SDA SPI1 PICO: PB8 MOSI SPI data from microcontroller to TFT or SDC
DC GPIO PA13 TFT data/command
RES GPIO PB15 TFT reset
CS SPI1 CS0: PB6 TFT_CS, active low to enable TFT
*CS (NC) SDC_CS, active low to enable SDC
MISO (NC) MISO SPI data from SDC to microcontroller
SDA (NC) I2C data for ADXL345 accelerometer
SCL (NC) I2C clock for ADXL345 accelerometer
SDO (NC) I2C alternate address for ADXL345 accelerometer
Backlight + - Light, backlight connected to +3.3 V
wide.hk ST7735R with ADXL335 accelerometer pins
PinConnection
VCC +3.3 V
GND Ground /
!SCLSPI1 SCLK: PB9
!SDA SPI1 PICO: PB8 MOSI SPI data from microcontroller to TFT or SDC
DC GPIO PA13 TFT data/command
RES GPIO PB15 TFT reset
CS SPI1 CS0: PB6 TFT_CS, active low to enable TFT
*CS (NC) SDC_CS, active low to enable SDC
MISO (NC) MISO SPI data from SDC to microcontroller
X(NC) analog input X-axis from ADXL335 accelerometer
Y(NC) analog input Y-axis from ADXL335 accelerometer
Z(NC) analog input Z-axis from ADXL335 accelerometer
Backlight + Light, backlight connected to +3.3 V
HiLetgo ST7735 TFT and SDC pins
signalPinConnection
LED- 16TFT, to ground
LED+ 15TFT, to +3.3 V
SD_CS 14SDC, to chip select
MOSI 13SDC, to MOSI
MISO 12SDC, to MISO
SCK 11SDC, to serial clock
CS 10TFT, to PB6 SPI1 CS0
SCL 9TFT, to PB9 SPI1 SCLK
SDA 8TFT, to PB8 MOSI SPI1 PICO
A0 7TFT, to PA13 Data/Command, high for data, low for command
RESET 6TFT, to PB15 reset (GPIO), low to reset
NC 3,4,5not connected
VCC 2to +3.3 V
GND 1to ground
Tyenaza Tyenazaqhf72mi9s3 pins
signalPinConnection
LED 8to +3.3 V
SCK 7SCLK to PB9 SPI1 SCLK
SDA 6MOSI, to PB8 SPI1 PICO
A0 5Data/Command to PA13 (GPIO), high for data, low for command
RESET 4to PB15 (GPIO), low to reset
CS 3to PB6 SPI1 CS0:
Gnd 2to ground
VCC 1to +3.3 V
Adafruit ST7735R pins
Pin Connection Description
10+3.3Backlight
9 PB7 SPI1 MISO (used for SDC)
8 PB9 SPI1 SCLK clock out
7 PB8 SPI1 PICO data out
6 PB6 GPIO CS0=TFT_CS
5 PB0 CARD_CS (used for SDC)
4 PB16Data/Command(GPIO), high for data, low for command
3 PB15RESET, low to reset, (GPIO)
2 +3.3VCC
1 Gnd ground
HiLetgo ST7735 TFT and SDC pins
signalPinConnection
LED- 16TFT, to ground
LED+ 15TFT, to +3.3 V
SD_CS 14SDC, to PB0 chip select
MOSI 13SDC, to PB8 MOSI
MISO 12SDC, to PB7 MISO
SCK 11SDC, to PB9 serial clock
CS 10TFT, to PB6 SPI1 CS0
SCL 9TFT, to PB9 SPI1 SCLK
SDA 8TFT, to PB8 MOSI SPI1 PICO
A0 7TFT, to PB16 Data/Command, high for data, low for command
RESET 6TFT, to PB15 reset (GPIO), low to reset
NC 3,4,5not connected
VCC 2to +3.3 V
GND 1to ground

Function Documentation

◆ Arabic_OutChar()

void Arabic_OutChar ( Arabic_t  ch)

Output an Arabic character.

Output one Arabic character to the LCD Position determined by Arabic_SetCursor command Color set by ST7735_SetTextColor

Parameters
ch8-bit Arabic character
Returns
none

◆ Arabic_OutString()

void Arabic_OutString ( Arabic_t ptr)

Output an Arabic string.

Output an Arabic string to the LCD Position determined by Arabic_SetCursor command Color set by ST7735_SetTextColor. The string will automatically wrap.

Parameters
ptrpointer to null-terminated Arabic string
Returns
none

◆ Arabic_SetCursor()

void Arabic_SetCursor ( uint32_t  newX,
uint32_t  newY 
)

Move Arabic cursor.

Move the cursor to the desired X- and Y-position. The next character will be printed here. X=0 is the leftmost column. Y=0 is the top row. *

Parameters
none
newXnew X-position of the cursor (0<=newX<=7)
newYnew Y-position of the cursor (0<=newY<=9)
Returns
none

◆ I2C_Init()

void I2C_Init ( void  )

Initialize I2C.

Initialize PB2 and PB3 for I2C for 400kHz clock. Uses busy-wait synchronization

Parameters
none
Returns
none
Note
Assumes 80MHz bus clock
Assumes GPIOB have been reset and powered previously

◆ I2C_LightSensor_End()

int I2C_LightSensor_End ( uint32_t *  light)

Finish OPT3001.

Finish a measurement using the OPT3001. Query the OPT3001 light sensor for a measurement. If no measurement is currently in progress, start one and return zero immediately. If the measurement is not yet complete, return zero immediately. If the measurement is complete, store the result in the pointer provided and return one.

Parameters
lightpointer to a place to return data
Returns
1 if measurement is ready and pointer is valid, 0 if measurement is not ready and pointer unchanged
See also
I2C_LightSensor_Init I2C_LightSensor_End
Note
Assumes: I2C_LightSensor_Start() has been called

◆ I2C_LightSensor_Init()

void I2C_LightSensor_Init ( void  )

Initialize OPT3001.

Initialize OPT3001 on MKII boosterpack. PA27 is GPIO pin for input, which corresponds with BoosterPack pins J1.8 (Light Sensor interrupt). Initialize PB2 and PB3 for I2C pins, which correspond with BoosterPack pins J1.9 (SCL) and J1.10 (SDA)

Parameters
none
Returns
none
Note
Assumes 80MHz bus clock
Assumes GPIOB have been reset and powered previously

◆ I2C_LightSensor_Input()

uint32_t I2C_LightSensor_Input ( void  )

Input from OPT3001.

Query the OPT3001 light sensor for a measurement. Wait until the measurement is ready, which may take 800 ms

Parameters
none
Returns
light intensity (units 100*lux)
See also
I2C_LightSensor_Start I2C_LightSensor_End
Note
Assumes: I2C_LightSensor_Init() has been called

◆ I2C_LightSensor_Start()

void I2C_LightSensor_Start ( void  )

Start OPT3001.

Start a measurement using the OPT3001. If a measurement is currently in progress, return without starting another measurement

Parameters
none
Returns
none
See also
I2C_LightSensor_Init I2C_LightSensor_End
Note
Assumes: I2C_LightSensor_Init() has been called

◆ I2C_Recv1()

uint8_t I2C_Recv1 ( int8_t  slave)

Receive one byte.

Receive one byte from specified slave. Uses busy-wait synchronization
[send address][read data]

Parameters
slaveis slave address
Returns
8-bit data received
Note
Does not check for errors

◆ I2C_Recv2()

uint16_t I2C_Recv2 ( int8_t  slave)

Receive two bytes.

Receive two bytes from specified slave. Uses busy-wait synchronization
[send address][read data][read data]

Parameters
slaveis slave address
Returns
16-bit data received
Note
Does not check for errors

◆ I2C_Send()

int I2C_Send ( uint8_t  slave,
uint8_t *  pData,
uint32_t  count 
)

write 1 to 8 bytes to I2C.

I2C_Send

Parameters
slaveaddress of slave device.
pDatadata address of data to be writen.

@param count number of bytes to be written, must be less than 8.

◆ I2C_Send1()

int I2C_Send1 ( int8_t  slave,
uint8_t  data 
)

Send one byte.

Send one byte to specified slave. Uses busy-wait synchronization
[send address][send data]

Parameters
slaveslave address
databyte to be sent
Returns
0 if successful, nonzero if error
Note
Does check for errors

◆ I2C_Send2()

int I2C_Send2 ( int8_t  slave,
uint8_t  data1,
uint8_t  data2 
)

Send two bytes.

Send two bytes to specified slave. Uses busy-wait synchronization
[send address][send data1][send data2]

Parameters
slaveis slave address
data1is first byte to be sent
data2is second byte to be sent
Returns
0 if successful, nonzero if error
Note
Does check for errors

◆ I2C_Send3()

int I2C_Send3 ( int8_t  slave,
uint8_t  data1,
uint8_t  data2,
uint8_t  data3 
)

Send three bytes.

Send three bytes to specified slave. Uses busy-wait synchronization
[send address][send data1][send data2][send data3]

Parameters
slaveis slave address
data1is first byte to be sent
data2is second byte to be sent
data3is third byte to be sent
Returns
0 if successful, nonzero if error
Note
Does check for errors

◆ I2C_SendData()

int I2C_SendData ( uint8_t  slave,
uint8_t *  pData,
uint32_t  count 
)

send large buffer to I2C.

I2C_SendData

Parameters
slaveaddress of slave device.
pDatadata address of data to be writen.

@param count number of bytes to be written, must be from 2 to 4095.

◆ I2C_TempSensor_End()

int I2C_TempSensor_End ( int32_t *  sensorV,
int32_t *  localT 
)

Finish TMP006.

Finish a measurement using the OPT3001. Query the TMP006 temperature sensor for a measurement. If no measurement is currently in progress, start one and return zero immediately. If the measurement is not yet complete, return zero immediately. If the measurement is complete, store the result in the pointers provided and return one.

Parameters
sensorVis signed pointer to store sensor voltage (units 100*nV)
localTis signed pointer to store local temperature (units 100,000*C)
Returns
1 if measurement is ready and pointer is valid, 0 if measurement is not ready and pointer unchanged
See also
I2C_TempSensor_Start
Note
Assumes: I2C_TempSensor_Start has been called

◆ I2C_TempSensor_Init()

void I2C_TempSensor_Init ( void  )

Initialize TMP006.

Initialize TMP006 on MKII boosterpack. PB16 is GPIO pin for input, which corresponds with BoosterPack pins J1.8 (Light Sensor interrupt). Initialize PB2 and PB3 for I2C pins, which correspond with BoosterPack pins J1.9 (SCL) and J1.10 (SDA)

Parameters
none
Returns
none
Note
Assumes 80MHz bus clock
Assumes GPIOB have been reset and powered previously

◆ I2C_TempSensor_Input()

void I2C_TempSensor_Input ( int32_t *  sensorV,
int32_t *  localT 
)

Input from TMP006.

Query the TMP006 temperature sensor for a measurement. Wait until the measurement is ready, which may take 4 seconds

Parameters
sensorVis signed pointer to store sensor voltage (units 100*nV)
localTis signed pointer to store local temperature (units 100,000*C)
Returns
none
Note
TMP006 was discontinued and not populated on most MKII

◆ I2C_TempSensor_Start()

void I2C_TempSensor_Start ( void  )

Start TMP006.

Start a measurement using the TMP006. If a measurement is currently in progress, return without starting another measurement

Parameters
none
Returns
none
See also
I2C_LightSensor_Init I2C_LightSensor_End
Note
Assumes: I2C_LightSensor_Init() has been called

◆ LCD_Color565()

uint16_t LCD_Color565 ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

RGB to color creation.

Pass 8-bit (each) R,G,B and get back 16-bit packed color.

Parameters
rred value
ggreen value
bblue value
Returns
16-bit color

◆ LCD_Drawaxes()

void LCD_Drawaxes ( uint16_t  axisColor,
uint16_t  bgColor,
char *  xLabel,
char *  yLabel1,
uint16_t  label1Color,
char *  yLabel2,
uint16_t  label2Color,
int32_t  ymax,
int32_t  ymin 
)

Initializes a plot.

Set up the axes, labels, and other variables to allow data to be plotted in a chart using the functions LCD_PlotPoint() and LCD_PlotIncrement(). If yLabel2 is empty string, no yLabel2 is printed, and yLabel1 is centered

Parameters
axisColor16-bit color for axes, which can be produced by LCD_Color565()
bgColor16-bit color for plot background, which can be produced by LCD_Color565()
xLabelpointer to a null terminated string for x-axis (~4 character space)
yLabel1pointer to a null terminated string for top of y-axis (~3-5 character space)
label1Color16-bit color for y-axis label1, which can be produced by LCD_Color565()
yLabel2pointer to a null terminated string for bottom of y-axis (~3 character space)
label2Color16-bit color for y-axis label2, which can be produced by LCD_Color565()
ymaxmaximum value to be printed
yminminimum value to be printed
Returns
none
Note
Assumes: LCD_Init() has been called

◆ LCD_DrawBitmap()

void LCD_DrawBitmap ( int16_t  x,
int16_t  y,
const uint16_t *  image,
int16_t  w,
int16_t  h 
)

Displays a BMP image.

Displays a 16-bit color BMP image. A bitmap file that is created by a PC image processing program has a header and may be padded with dummy columns so the data have four byte alignment. This function assumes that all of that has been stripped out, and the array image[] has one 16-bit halfword for each pixel to be displayed on the screen (encoded in reverse order, which is standard for bitmap files). An array can be created in this format from a 24-bit-per-pixel .bmp file using the associated BmpConvert16.exe converter program. (x,y) is the screen location of the lower left corner of BMP image
Requires (11 + 2*w*h) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the bottom left corner of the image, columns from the left edge
yvertical position of the bottom left corner of the image, rows from the top edge
imagepointer to a 16-bit color BMP image
wnumber of pixels wide
hnumber of pixels tall
Note
Must be less than or equal to 128 pixels wide by 128 pixels high
Returns
none

◆ LCD_DrawChar()

void LCD_DrawChar ( int16_t  x,
int16_t  y,
char  c,
int16_t  textColor,
int16_t  bgColor,
uint8_t  size 
)

Draw a character.

Advanced character draw function. This is similar to the function from Adafruit_GFX.c but adapted for this processor. However, this function only uses one call to setAddrWindow(), which allows it to run at least twice as fast.
Requires (11 + size*size*6*8) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the top left corner of the character, columns from the left edge
yvertical position of the top left corner of the character, rows from the top edge
ccharacter to be printed
textColor16-bit color of the character
bgColor16-bit color of the background
sizenumber of pixels per character pixel (e.g. size==2 prints each pixel of font as 2x2 square)
Returns
none

◆ LCD_DrawCharS()

void LCD_DrawCharS ( int16_t  x,
int16_t  y,
char  c,
int16_t  textColor,
int16_t  bgColor,
uint8_t  size 
)

Draw a character.

Simple character draw function. This is the same function from Adafruit_GFX.c but adapted for this processor. However, each call to LCD_DrawPixel() calls setAddrWindow(), which needs to send many extra data and commands. If the background color is the same as the text color, no background will be printed, and text can be drawn right over existing images without covering them with a box.
Requires (11 + 2*size*size)*6*8 bytes of transmission (image fully on screen; textcolor != bgColor)

Parameters
xhorizontal position of the top left corner of the character, columns from the left edge
yvertical position of the top left corner of the character, rows from the top edge
ccharacter to be printed
textColor16-bit color of the character
bgColor16-bit color of the background
sizenumber of pixels per character pixel (e.g. size==2 prints each pixel of font as 2x2 square)
Returns
none

◆ LCD_DrawFastHLine()

void LCD_DrawFastHLine ( int16_t  x,
int16_t  y,
int16_t  w,
uint16_t  color 
)

Draw a horizontal line.

Draw a horizontal line at the given coordinates with the given width and color. A horizontal line is parallel to the shorter side of the rectangular display
Requires (11 + 2*w) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the start of the line, columns from the left edge
yvertical position of the start of the line, rows from the top edge
whorizontal width of the line
color16-bit color, which can be produced by LCD_Color565()
Returns
none

◆ LCD_DrawFastVLine()

void LCD_DrawFastVLine ( int16_t  x,
int16_t  y,
int16_t  h,
uint16_t  color 
)

Draw a vertical line.

Draw a vertical line at the given coordinates with the given height and color.
A vertical line is parallel to the longer side of the rectangular display
Requires (11 + 2*h) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the start of the line, columns from the left edge
yvertical position of the start of the line, rows from the top edge
hvertical height of the line
color16-bit color, which can be produced by LCD_Color565()
Returns
none

◆ LCD_DrawPixel()

void LCD_DrawPixel ( int16_t  x,
int16_t  y,
uint16_t  color 
)

Color one pixel.

Color the pixel at the given coordinates with the given color.
Requires 13 bytes of transmission
x must be less than 128
x 0 is on the left, 126 is near the right
y must be less than 128 y 126 is near the wires, 0 is the side opposite the wires

Parameters
xhorizontal position of the pixel, columns from the left edge
yvertical position of the pixel, rows from the top edge
color16-bit color, which can be produced by LCD_Color565()
Returns
none

◆ LCD_DrawString()

uint32_t LCD_DrawString ( uint16_t  x,
uint16_t  y,
char *  pt,
int16_t  textColor 
)

Draw a string.

String draw function. 13 rows (0 to 12) and 21 characters (0 to 20)
Requires (11 + size*size*6*8) bytes of transmission for each character

Parameters
xcolumns from the left edge (0 to 20)
yrows from the top edge (0 to 12)
ptpointer to a null terminated string to be printed
textColor16-bit color of the characters
Returns
number of characters printed
Note
bgColor is Black and size is 1

◆ LCD_FillRect()

void LCD_FillRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint16_t  color 
)

Draw a filled rectangle.

Draw a filled rectangle at the given coordinates with the given width, height, and color.
Requires (11 + 2*w*h) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the top left corner of the rectangle, columns from the left edge
yvertical position of the top left corner of the rectangle, rows from the top edge
whorizontal width of the rectangle
hvertical height of the rectangle
color16-bit color, which can be produced by LCD_Color565()
Returns
none

◆ LCD_FillScreen()

void LCD_FillScreen ( uint16_t  color)

Fill the screen.

Fill the screen with the given color.
Requires 33,293 bytes of transmission

Parameters
color16-bit color, which can be produced by LCD_Color565()
Returns
none

◆ LCD_Init()

void LCD_Init ( void  )

Initialize MKII LCD.

Initialize Crystalfontz CFAF128128B-0145T color 128x128-pixel TFT LCD BoosterPack pins

  • J1.7 PB9 (SPI CLK)
  • J2.13 PB6 (SPI CS)
  • J2.15 PB8 (SPI MOSI)
  • J2.17 PB15(LCD ~RST) and
  • J4.31 PA13(LCD DC)
    Parameters
    none
    Returns
    none
    Note
    assumes GPIOA and GPIOB are reset and powered previously

◆ LCD_OutChar()

void LCD_OutChar ( char  ch)

Output a character.

Output one character to the LCD Position determined by LCD_SetCursor command Color set by LCD_SetTextColor

Parameters
ch8-bit ASCII character
Returns
none

◆ LCD_OutString()

void LCD_OutString ( char *  ptr)

Output a string.

Print a string of characters to the ST7735 LCD. Position determined by LCD_SetCursor command Color set by LCD_SetTextColor The string will not automatically wrap.

Parameters
ptrpointer to NULL-terminated ASCII string
Returns
none

◆ LCD_OutUDec()

void LCD_OutUDec ( uint32_t  n,
int16_t  textColor 
)

Output an unsigned decimal.

Output a 32-bit number in unsigned decimal format Position determined by LCD_SetCursor command

Parameters
n32-bit number to be transferred
textColor16-bit color of the numbers
Returns
none
Note
Variable format 1-10 digits with no space before or after

◆ LCD_OutUDec4()

void LCD_OutUDec4 ( uint32_t  n,
int16_t  textColor 
)

Output a 4-digit unsigned decimal.

Output a 32-bit number in unsigned 4-digit decimal format with no space before or after. Position determined by LCD_SetCursor command

Parameters
n32-bit number to be transferred
textColor16-bit color of the numbers
Returns
none
Note
Fixed format 4 digits with no space before or after

◆ LCD_OutUDec5()

void LCD_OutUDec5 ( uint32_t  n,
int16_t  textColor 
)

Output a 5-digit unsigned decimal.

Output a 32-bit number in unsigned 5-digit decimal format Position determined by LCD_SetCursor command

Parameters
n32-bit number to be transferred
textColor16-bit color of the numbers
Returns
none
Note
Fixed format 5 digits with no space before or after

◆ LCD_OutUFix2_1()

void LCD_OutUFix2_1 ( uint32_t  n,
int16_t  textColor 
)

Output a 2-digit fixed-point decimal.

Output a 32-bit number in unsigned 3-digit fixed point, 0.1 resolution numbers 0 to 999 printed as " 0.0" to "99.9" Position determined by LCD_SetCursor command

Parameters
n32-bit number to be transferred
textColor16-bit color of the numbers
Returns
none
Note
Fixed format 4 characters with no space before or after

◆ LCD_OutUHex2()

void LCD_OutUHex2 ( uint32_t  n,
int16_t  textColor 
)

Output a 2-digit hexadecimal number.

Output a 32-bit number in unsigned 2-digit hexadecimal format numbers 0 to 255 printed as "00," to "FF," Position determined by LCD_SetCursor command

Parameters
n32-bit number to be transferred
textColor16-bit color of the numbers
Returns
none
Note
Fixed format 3 characters with comma after

◆ LCD_PlotIncrement()

void LCD_PlotIncrement ( void  )

Moves the plot cursor in time.

Increment the plot between subsequent calls to LCD_PlotPoint(). Automatically wrap and clear the column to be printed to.

Parameters
none
Returns
none
Note
Assumes: LCD_Init() and LCD_Drawaxes() have been called

◆ LCD_PlotPoint()

void LCD_PlotPoint ( int32_t  data1,
uint16_t  color1 
)

Plot one point.

Plot a point on the chart. To plot several points in the same column, call this function repeatedly before calling LCD_PlotIncrement(). The units of the data are the same as the ymax and ymin values specified in the initialization function.

Parameters
data1value to be plotted (units not specified)
color116-bit color for the point, which can be produced by LCD_Color565()
Returns
none
Note
Assumes: LCD_Init() and LCD_Drawaxes() have been called

◆ LCD_SetCursor()

void LCD_SetCursor ( uint32_t  newX,
uint32_t  newY 
)

Move the cursor.

Move the cursor to the desired X- and Y-position. The next character of the next unsigned decimal will be printed here. X=0 is the leftmost column. Y=0 is the top row. The cursor is used by the "Out" functions, but not the "Draw" functions

Parameters
newXnew X-position of the cursor (0<=newX<=20)
newYnew Y-position of the cursor (0<=newY<=12)
Returns
none

◆ LCD_SetTextColor()

void LCD_SetTextColor ( uint16_t  color)

sets the text color

Sets the color in which the characters will be printed Background color is fixed at black

Parameters
color16-bit packed color
Returns
none

◆ LCD_SwapColor()

uint16_t LCD_SwapColor ( uint16_t  x)

Swaps red and blue.

Swaps the red and blue values of the given 16-bit packed color; green is unchanged.

Parameters
x16-bit color in format B, G, R
Returns
16-bit color in format R, G, B

◆ SSD1306_ClearBuffer()

void SSD1306_ClearBuffer ( void  )

Clear contents of display buffer (set all pixels to off).

Returns
None (void).
Note
Changes buffer contents only, no immediate effect on display. Follow up with a call to display(), or with other graphics commands as needed by one's own application.

◆ SSD1306_Dim()

void SSD1306_Dim ( int  dim)

Dim the display.

Parameters
dimtrue to enable lower brightness mode, false for full brightness.
Returns
None (void).
Note
This has an immediate effect on the display, no need to call the display() function – buffer contents are not changed.

◆ SSD1306_DrawBMP()

void SSD1306_DrawBMP ( uint8_t  xpos,
uint8_t  ypos,
const uint8_t *  ptr,
uint8_t  threshold,
uint16_t  color 
)

Draw a raw bitmap to the RAM buffer.

Parameters
xposHorizontal position of bottom left corner of image, columns from the left edge.
must be less than 128
0 is on the left; 126 is near the right
yposVertical position of bottom left corner of image, rows from the top edge.
must be less than 64
2 is near the top; 63 is at the bottom
ptrPointer to a 16-color BMP image.
thresholdGrayscale colors above this number make corresponding pixel 'on'.
0 to 14
0 is fine for ships, explosions, projectiles, and bunkers
colorPixel color, one of: SSD1306_BLACK, SSD1306_WHITE or SSD1306_INVERSE.
Returns
None (void).
Note
Bitmaps defined above were created for the LM3S1968 or LM3S8962's 4-bit grayscale OLED display. More recently they are created using Microsoft Paint (or your favorite drawing program), saved as a 16-color bitmap, and converted from binary to text using BmpConvert.exe. Then copy and paste this text into the program, which will create a constant containing the image that will be loaded into ROM at compile time. These images will still contain their header data and may contain padding to preserve 4-byte alignment. This function takes a bitmap in the previously described format and puts its image data in the proper location in the buffer so the image will appear on the screen after the next call to
SSD1306_DisplayBuffer();
The interface and operation of this process is modeled after RIT128x96x4_BMP(x, y, image);

◆ SSD1306_DrawChar()

void SSD1306_DrawChar ( int16_t  x,
int16_t  y,
char  letter,
uint16_t  color 
)

Draw a character.

Parameters
xColumn of display – 0 at left to (screen width - 1) at right.
yRow of display – 0 at top to (screen height - 1) at bottom.
letterASCII code of character to draw.
colorPixel color, one of: SSD1306_BLACK, SSD1306_WHITE or SSD1306_INVERSE.
Returns
None (void).
Note
Changes buffer contents only, no immediate effect on display. Follow up with a call to SSD1306_DisplayBuffer(), or with other graphics commands as needed by one's own application.

◆ SSD1306_DrawFastHLine()

void SSD1306_DrawFastHLine ( int16_t  x,
int16_t  y,
int16_t  w,
uint16_t  color 
)

Draw a horizontal line. This is also invoked by the Adafruit_GFX library in generating many higher-level graphics primitives.

Parameters
xLeftmost column – 0 at left to (screen width - 1) at right.
yRow of display – 0 at top to (screen height -1) at bottom.
wWidth of line, in pixels.
colorLine color, one of: SSD1306_BLACK, SSD1306_WHITE or SSD1306_INVERSE.
Returns
None (void).
Note
Changes buffer contents only, no immediate effect on display. Follow up with a call to SSD1306_DisplayBuffer(), or with other graphics commands as needed by one's own application.

◆ SSD1306_DrawFastVLine()

void SSD1306_DrawFastVLine ( int16_t  x,
int16_t  y,
int16_t  h,
uint16_t  color 
)

Draw a vertical line. This is also invoked by the Adafruit_GFX library in generating many higher-level graphics primitives.

Parameters
xColumn of display – 0 at left to (screen width -1) at right.
yTopmost row – 0 at top to (screen height - 1) at bottom.
hHeight of line, in pixels.
colorLine color, one of: SSD1306_BLACK, SSD1306_WHITE or SSD1306_INVERSE.
Returns
None (void).
Note
Changes buffer contents only, no immediate effect on display. Follow up with a call to SSD1306_DisplayBuffer(), or with other graphics commands as needed by one's own application.

◆ SSD1306_DrawFullImage()

void SSD1306_DrawFullImage ( const uint8_t *  ptr)

Fill the whole screen by drawing a 128x64 bitmap image.

Parameters
ptrPointer to 1024-byte image with no header or format data.
Returns
None (void).
Note
Assumes: OLED is in horizontal addressing mode (command 0x20, 0x00)
Image is sent to screen directly, RAM buffer is unchanged.

◆ SSD1306_DrawPixel()

void SSD1306_DrawPixel ( int16_t  x,
int16_t  y,
uint16_t  color 
)

Set/clear/invert a single pixel. This is also invoked by the Adafruit_GFX library in generating many higher-level graphics primitives.

Parameters
xColumn of display – 0 at left to (screen width - 1) at right.
yRow of display – 0 at top to (screen height - 1) at bottom.
colorPixel color, one of: SSD1306_BLACK, SSD1306_WHITE or SSD1306_INVERT.
Returns
None (void).
Note
Changes buffer contents only, no immediate effect on display. Follow up with a call to SSD1306_DisplayBuffer(), or with other graphics commands as needed by one's own application.

◆ SSD1306_DrawPoint()

void SSD1306_DrawPoint ( int32_t  x,
int32_t  y 
)

Set/clear/invert a single pixel. SSD1306_SetPlot initializes scaling.

Parameters
xColumn of display – minX at left to maxX at right.
yRow of display – maxY at top to minY at bottom.
Returns
None (void).
Note
Changes buffer contents only, no immediate effect on display. Follow up with a call to SSD1306_DisplayBuffer(), or with other graphics commands as needed by one's own application.

◆ SSD1306_DrawString()

void SSD1306_DrawString ( int16_t  x,
int16_t  y,
char *  pt,
uint16_t  color 
)

Draw a string.

Parameters
xColumn of display – 0 at left to (screen width - 1) at right.
yRow of display – 0 at top to (screen height - 1) at bottom.
ptpointer to null-terminated ASCII string of characters to draw.
colorPixel color, one of: SSD1306_BLACK, SSD1306_WHITE or SSD1306_INVERSE.
Returns
None (void).
Note
Changes buffer contents only, no immediate effect on display. Follow up with a call to SSD1306_DisplayBuffer(), or with other graphics commands as needed by one's own application.

◆ SSD1306_DrawUDec()

void SSD1306_DrawUDec ( int16_t  x,
int16_t  y,
uint16_t  n,
uint16_t  color 
)

Draw a 3 digit integer.

Parameters
xColumn of display – 0 at left to (screen width - 1) at right.
yRow of display – 0 at top to (screen height - 1) at bottom.
nunsigned number 0 to 999.
colorPixel color, one of: SSD1306_BLACK, SSD1306_WHITE or SSD1306_INVERSE.
Returns
None (void).
Note
Changes buffer contents only, no immediate effect on display. Follow up with a call to SSD1306_DisplayBuffer(), or with other graphics commands as needed by one's own application.

◆ SSD1306_getBuffer()

uint8_t* SSD1306_getBuffer ( void  )

Get base address of display buffer for direct reading or writing.

Returns
Pointer to an unsigned 8-bit array, column-major, columns padded to full byte boundary if needed.

◆ SSD1306_GetPixel()

int SSD1306_GetPixel ( int16_t  x,
int16_t  y 
)

Return color of a single pixel in display buffer.

Parameters
xColumn of display – 0 at left to (screen width - 1) at right.
yRow of display – 0 at top to (screen height -1) at bottom.
Returns
true if pixel is set (usually WHITE, unless display invert mode is enabled), false if clear (BLACK).
Note
Reads from buffer contents; may not reflect current contents of screen if SSD1306_DisplayBuffer() has not been called.

◆ SSD1306_Init()

int SSD1306_Init ( int  vccst)

II2 driver for SSD1306 OLED display.

Initialize OLED

Parameters
vccstVcc voltage parameter, uSSD1306_EXTERNALVCC or SSD1306_SWITCHCAPVCC
Returns
success or failure
Note
for EE319K use vccst=SSD1306_SWITCHCAPVCC

◆ SSD1306_InitPrintf()

void SSD1306_InitPrintf ( void  )

Initialize the SSD1306 for printf.

Returns
None (void).

◆ SSD1306_InvertDisplay()

void SSD1306_InvertDisplay ( int  i)

Enable or disable display invert mode (white-on-black vs black-on-white).

Parameters
iIf true, switch to invert mode (black-on-white), else normal mode (white-on-black).
Returns
None (void).
Note
This has an immediate effect on the display, no need to call the display() function – buffer contents are not changed, rather a different pixel mode of the display hardware is used. When enabled, drawing BLACK (value 0) pixels will actually draw white, WHITE (value 1) will draw black.

◆ SSD1306_OutBuffer()

void SSD1306_OutBuffer ( void  )

Copy all of RAM image to OLED. Use this command with SSD1306_ClearBuffer, and all Draw functions

Parameters
none
Returns
success or failure

◆ SSD1306_OutChar()

void SSD1306_OutChar ( char  data)

Print a character to the OLED.

Print a character to the SSD1306 OLED. The character will be printed at the current cursor position, the cursor will automatically be updated, and it will wrap to the next row or back to the top if necessary. One blank column of pixels will be printed on one side of the character for readability. Since characters are 8 pixels tall and 6 pixels wide, 12 characters fit per row, and there are six rows.

Parameters
datacharacter to print
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutClear()

void SSD1306_OutClear ( void  )

Clear the LCD by writing zeros to the entire screen and reset the cursor to (0,0) (top left corner of screen).

Returns
None (void).

◆ SSD1306_OutHex7()

void SSD1306_OutHex7 ( uint8_t  n)

Print one hex digit.

Output one hex digit to the SSD1306 OLED Just one character with no leading 0x

Parameters
nunsigned number 0-15 to print
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutSDec()

void SSD1306_OutSDec ( int16_t  n)

Print a 16-bit signed number to the OLED.

Output a 16-bit number in signed decimal format with a fixed size of six right-justified digits of output.

Parameters
n16-bit signed number
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutSFix1()

void SSD1306_OutSFix1 ( int32_t  n)

Print a 32-bit signed fixed-point number to the OLED.

Output a 32-bit number in signed 4-digit fixed point, 0.1 resolution fixed size of six right-justified characters.
numbers -9999 to 9999 printed as "-999.9" to "999.9"

Parameters
n32-bit signed number
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutString()

void SSD1306_OutString ( char *  ptr)

Print a string of characters to the OLED.

Print a string of characters to the SSD1306 OLED. The string will automatically wrap, so padding spaces may be needed to make the output look optimal.

Parameters
ptrpointer to NULL-terminated ASCII string
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutU3Fix1()

void SSD1306_OutU3Fix1 ( uint16_t  n)

Print a 16-bit unsigned fixed-point number to the OLED.

Output a 16-bit number in unsigned 4-digit fixed point, 0.1 resolution fixed size of five right-justified characters.
numbers 0 to 999 printed as " 0.0" to "999.9"

Parameters
n16-bit unsigned number
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutUDec()

void SSD1306_OutUDec ( uint16_t  n)

Print a 16-bit unsigned number to the OLED.

Output a 16-bit number in unsigned decimal format with a fixed size of five right-justified digits of output.

Parameters
n16-bit unsigned number
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutUDec16()

void SSD1306_OutUDec16 ( uint32_t  n)

Print three decimal digits.

Output three decimal digits to the SSD1306 OLED. Prints 4 characters with leading space

Parameters
nunsigned number 0-999 to print
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutUDec2()

void SSD1306_OutUDec2 ( uint32_t  n)

Print two decimal digits.

Output two decimal digits to the SSD1306 OLED. Prints 2 characters without leading space

Parameters
nunsigned number 0-99 to print
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutUFix1()

void SSD1306_OutUFix1 ( uint16_t  n)

Print a 16-bit unsigned fixed-point number to the OLED.

Output a 16-bit number in unsigned 3-digit fixed point, 0.1 resolution fixed size of four right-justified characters.
numbers 0 to 999 printed as " 0.0" to "99.9"

Parameters
n16-bit unsigned number
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutUHex32()

void SSD1306_OutUHex32 ( uint32_t  n)

Print 16 hex digits.

Output 16 hex digits to the SSD1306 OLED. Prints 16 characters with leading 0x

Parameters
nunsigned 32-bit number to print
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_OutUHex7()

void SSD1306_OutUHex7 ( uint8_t  n)

Print two hex digits.

Output two hex digits to the SSD1306 OLED. Prints 4 characters with leading 0x

Parameters
nunsigned number 0-255 to print
Returns
none
Note
use SSD1306_SetCursor to specify position

◆ SSD1306_SetCursor()

void SSD1306_SetCursor ( uint16_t  newX,
uint16_t  newY 
)

Move the cursor to the desired X- and Y-position. The next character will be printed here. X=0 is the leftmost column. Y=0 is the top row.

Parameters
newXnew X-position of the cursor (0<=newX<=20)
newYnew Y-position of the cursor (0<=newY<=7)
Returns
none

◆ SSD1306_SetPlot()

void SSD1306_SetPlot ( int32_t  minX,
int32_t  maxX,
int32_t  minY,
int32_t  maxY,
uint16_t  color 
)

Initialize parameters for plotting.

Parameters
minXminimum X value
maxXmaxamum X value
minYminimum Y value
maxYmaxamum Y value
colorPixel color, one of: SSD1306_BLACK, SSD1306_WHITE or SSD1306_INVERT.
Returns
None (void).
Note
minimum must be less than maximum

◆ SSD1306_startscrolldiagleft()

void SSD1306_startscrolldiagleft ( uint8_t  start,
uint8_t  stop 
)

Activate alternate diagonal scroll for all or part of the display.

Note
To scroll the whole display, run: SSD1306_startscrolldiagleft(0x00, 0x0F)
Parameters
startFirst row.
stopLast row.
Returns
None (void).

◆ SSD1306_startscrolldiagright()

void SSD1306_startscrolldiagright ( uint8_t  start,
uint8_t  stop 
)

Activate a diagonal scroll for all or part of the display.

Note
SSD1306_startscrolldiagright(0x00, 0x0F)
Parameters
startFirst row.
stopLast row.
Returns
None (void).

◆ SSD1306_startscrollleft()

void SSD1306_startscrollleft ( uint8_t  start,
uint8_t  stop 
)

Activate a left-handed scroll for all or part of the display.

Note
To scroll the whole display, run: SSD1306_startscrollleft(0x00, 0x0F)
Parameters
startFirst row.
stopLast row.
Returns
None (void).

◆ SSD1306_startscrollright()

void SSD1306_startscrollright ( uint8_t  start,
uint8_t  stop 
)

Activate a right-handed scroll for all or part of the display.

Note
To scroll the whole display, run: SSD1306_startscrollright(0x00, 0x0F)
Parameters
startFirst row.
stopLast row.
Returns
None (void).

◆ SSD1306_stopscroll()

void SSD1306_stopscroll ( void  )

Cease a previously-begun scrolling action.

Returns
None (void).

◆ ST7735_Color565()

uint16_t ST7735_Color565 ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

RGB to color creation.

Pass 8-bit (each) R,G,B and get back 16-bit packed color.

Parameters
rred value
ggreen value
bblue value
Returns
16-bit color

◆ ST7735_Drawaxes()

void ST7735_Drawaxes ( uint16_t  axisColor,
uint16_t  bgColor,
char *  xLabel,
char *  yLabel1,
uint16_t  label1Color,
char *  yLabel2,
uint16_t  label2Color,
int32_t  ymax,
int32_t  ymin 
)

Initializes a plot.

Set up the axes, labels, and other variables to allow data to be plotted in a chart using the functions ST7735_PlotPoint() and ST7735_PlotIncrement(). If yLabel2 is empty string, no yLabel2 is printed, and yLabel1 is centered

  • graphics routines
    • y coordinates 0 to 31 used for labels and messages
    • y coordinates 32 to 159 128 pixels high
    • x coordinates 0 to 127 128 pixels wide
Parameters
axisColor16-bit color for axes, which can be produced by LCD_Color565()
bgColor16-bit color for plot background, which can be produced by LCD_Color565()
xLabelpointer to a null terminated string for x-axis (~4 character space)
yLabel1pointer to a null terminated string for top of y-axis (~3-5 character space)
label1Color16-bit color for y-axis label1, which can be produced by LCD_Color565()
yLabel2pointer to a null terminated string for bottom of y-axis (~3 character space)
label2Color16-bit color for y-axis label2, which can be produced by LCD_Color565()
ymaxmaximum value to be printed
yminminimum value to be printed
Returns
none
Note
Assumes: ST7735_InitR() has been called

◆ ST7735_DrawBitmap()

void ST7735_DrawBitmap ( int16_t  x,
int16_t  y,
const uint16_t *  image,
int16_t  w,
int16_t  h 
)

Displays a BMP image.

Displays a 16-bit color BMP image. A bitmap file that is created by a PC image processing program has a header and may be padded with dummy columns so the data have four byte alignment. This function assumes that all of that has been stripped out, and the array image[] has one 16-bit halfword for each pixel to be displayed on the screen (encoded in reverse order, which is standard for bitmap files). An array can be created in this format from a 24-bit-per-pixel .bmp file using the associated BmpConvert16.exe converter program. (x,y) is the screen location of the lower left corner of BMP image
Requires (11 + 2*w*h) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the bottom left corner of the image, columns from the left edge
yvertical position of the bottom left corner of the image, rows from the top edge
imagepointer to a 16-bit color BMP image
wnumber of pixels wide
hnumber of pixels tall
Note
Must be less than or equal to 128 pixels wide by 160 pixels high
Returns
none

◆ ST7735_DrawChar()

void ST7735_DrawChar ( int16_t  x,
int16_t  y,
char  c,
int16_t  textColor,
int16_t  bgColor,
uint8_t  size 
)

Draw a character.

Advanced character draw function. This is similar to the function from Adafruit_GFX.c but adapted for this processor. However, this function only uses one call to setAddrWindow(), which allows it to run at least twice as fast.
Requires (11 + size*size*6*8) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the top left corner of the character, columns from the left edge
yvertical position of the top left corner of the character, rows from the top edge
ccharacter to be printed
textColor16-bit color of the character
bgColor16-bit color of the background
sizenumber of pixels per character pixel (e.g. size==2 prints each pixel of font as 2x2 square)
Returns
none

◆ ST7735_DrawCharS()

void ST7735_DrawCharS ( int16_t  x,
int16_t  y,
char  c,
int16_t  textColor,
int16_t  bgColor,
uint8_t  size 
)

Draw a character.

Simple character draw function. This is the same function from Adafruit_GFX.c but adapted for this processor. However, each call to ST7735_DrawPixel() calls setAddrWindow(), which needs to send many extra data and commands. If the background color is the same as the text color, no background will be printed, and text can be drawn right over existing images without covering them with a box.
Requires (11 + 2*size*size)*6*8 bytes of transmission (image fully on screen; textcolor != bgColor)

Parameters
xhorizontal position of the top left corner of the character, columns from the left edge
yvertical position of the top left corner of the character, rows from the top edge
ccharacter to be printed
textColor16-bit color of the character
bgColor16-bit color of the background
sizenumber of pixels per character pixel (e.g. size==2 prints each pixel of font as 2x2 square)
Returns
none

◆ ST7735_DrawCircle()

void ST7735_DrawCircle ( int16_t  x,
int16_t  y,
uint16_t  color 
)

Draw a circle.

Draw a circle (diameter of 10 pixels) at the given coordinates with the given color.
Requires (11*10+68*2)=178 bytes of transmission (assuming image on screen)

Parameters
xhorizontal position of the top left corner of the circle, columns from the left edge
yvertical position of the top left corner of the circle, rows from the top edge
color16-bit color, which can be produced by ST7735_Color565()
Returns
none

◆ ST7735_DrawFastHLine()

void ST7735_DrawFastHLine ( int16_t  x,
int16_t  y,
int16_t  w,
uint16_t  color 
)

Draw a horizontal line.

Draw a horizontal line at the given coordinates with the given width and color. A horizontal line is parallel to the shorter side of the rectangular display
Requires (11 + 2*w) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the start of the line, columns from the left edge
yvertical position of the start of the line, rows from the top edge
whorizontal width of the line
color16-bit color, which can be produced by LCD_Color565()
Returns
none

◆ ST7735_DrawFastVLine()

void ST7735_DrawFastVLine ( int16_t  x,
int16_t  y,
int16_t  h,
uint16_t  color 
)

Draw a vertical line.

Draw a vertical line at the given coordinates with the given height and color.
A vertical line is parallel to the longer side of the rectangular display
Requires (11 + 2*h) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the start of the line, columns from the left edge
yvertical position of the start of the line, rows from the top edge
hvertical height of the line
color16-bit color, which can be produced by LCD_Color565()
Returns
none

◆ ST7735_DrawLine()

void ST7735_DrawLine ( int32_t  x1,
int32_t  y1,
int32_t  x2,
int32_t  y2,
uint32_t  color 
)

draw line

Draws an arbitrary line
Inputs: (x1,y1) is the start point
(x2,y2) is the end point
x coordinates range from 0 to 127, 0 is left, 79 is right
y coordinates range from 0 to 159, 0 is top, 159 is bottom

Parameters
x1x-position starting point
y1y-position starting point
x2x-position end point
y2y-position end point
coloris 16-bit 5-6-5 R, G, B format
Returns
none

◆ ST7735_DrawPixel()

void ST7735_DrawPixel ( int16_t  x,
int16_t  y,
uint16_t  color 
)

Color one pixel.

Color the pixel at the given coordinates with the given color.
Requires 13 bytes of transmission
x must be less than 128
x 0 is on the left, 126 is near the right
y must be less than 160 y 159 is near the wires, 0 is the side opposite the wires

Parameters
xhorizontal position of the pixel, columns from the left edge
yvertical position of the pixel, rows from the top edge
color16-bit color, which can be produced by LCD_Color565()
Returns
none

◆ ST7735_DrawSmallCircle()

void ST7735_DrawSmallCircle ( int16_t  x,
int16_t  y,
uint16_t  color 
)

Draw a small circle.

Draw a small circle (diameter of 6 pixels) at the given coordinates with the given color.
Requires (11*6+24*2)=114 bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the top left corner of the circle, columns from the left edge
yvertical position of the top left corner of the circle, rows from the top edge
color16-bit color, which can be produced by ST7735_Color565()
Returns
none

◆ ST7735_DrawString()

uint32_t ST7735_DrawString ( uint16_t  x,
uint16_t  y,
char *  pt,
int16_t  textColor 
)

Draw a string.

String draw function. 16 rows (0 to 15) and 21 characters (0 to 20)
Requires (11 + size*size*6*8) bytes of transmission for each character

Parameters
xcolumns from the left edge (0 to 20)
yrows from the top edge (0 to 12)
ptpointer to a null terminated string to be printed
textColor16-bit color of the characters
Returns
number of characters printed
Note
bgColor is Black and size is 1

◆ ST7735_FillRect()

void ST7735_FillRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint16_t  color 
)

Draw a filled rectangle.

Draw a filled rectangle at the given coordinates with the given width, height, and color.
Requires (11 + 2*w*h) bytes of transmission (assuming image fully on screen)

Parameters
xhorizontal position of the top left corner of the rectangle, columns from the left edge
yvertical position of the top left corner of the rectangle, rows from the top edge
whorizontal width of the rectangle
hvertical height of the rectangle
color16-bit color, which can be produced by ST7735_Color565()
Returns
none

◆ ST7735_FillScreen()

void ST7735_FillScreen ( uint16_t  color)

Fill the screen.

Fill the screen with the given color.
Requires 40,971 bytes of transmission

Parameters
color16-bit color, which can be produced by ST7735_Color565()
Returns
none

◆ ST7735_InitB()

void ST7735_InitB ( void  )

Initialize ST7735B LCD.

Initialize ST7735B color 128x160-pixel TFT LCD

Parameters
none
Returns
none
Note
assumes GPIOA and GPIOB are reset and powered previously

Initialize ST7735B color 128x160-pixel TFT LCD

Parameters
none
Returns
none
Note
Assumes GPIOA and GPIOB are reset and powered previously

◆ ST7735_InitPrintf() [1/2]

void ST7735_InitPrintf ( enum initRFlags  option)

use ST7735 LCD to output from printf

Initialize the ST7735 for printf

  • Use INITR_REDTAB for Adafruit
    • Use INITR_BLACKTAB for Hiletgo
      Parameters
      optionone of none,INITR_GREENTAB,INITR_REDTAB,INITR_BLACKTAB
      Returns
      none

◆ ST7735_InitPrintf() [2/2]

void ST7735_InitPrintf ( void  )

Use ST7735 LCD to output from printf.

Initialize the ST7735 for printf. Stream printf data to ST7735 LCD

Parameters
none
Returns
none

◆ ST7735_InitR()

void ST7735_InitR ( enum initRFlags  option)

Initialize ST7735R LCD.

Initialize ST7735R color 128x160-pixel TFT LCD

Parameters
optionone of none,INITR_GREENTAB,INITR_REDTAB,INITR_BLACKTAB
Returns
none
Note
assumes GPIOA and GPIOB are reset and powered previously

Initialize ST7735R color 128x160-pixel TFT LCD

  • Use INITR_REDTAB for Adafruit
  • Use INITR_BLACKTAB for Hiletgo
    Parameters
    optionone of none,INITR_GREENTAB,INITR_REDTAB,INITR_BLACKTAB
    Returns
    none
    Note
    Assumes GPIOA and GPIOB are reset and powered previously

◆ ST7735_InvertDisplay()

void ST7735_InvertDisplay ( int  i)

invert display

Invert display.

Send the command to invert all of the colors. Requires 1 byte of transmission

Parameters
i0 to disable inversion; non-zero to enable inversion
Returns
none

◆ ST7735_Line()

void ST7735_Line ( uint16_t  x1,
uint16_t  y1,
uint16_t  x2,
uint16_t  y2,
uint16_t  color 
)

Draws line.

Draws one line on the ST7735 color LCD

  • (x1,y1) is the start point
  • (x2,y2) is the end point
  • x1 x2 must be less than 128, 0 is on the left, 126 is near the right
  • y1 y2 must be less than 160, 159 is near the wires, 0 is the side opposite the wires
Parameters
x1horizonal position
x2horizonal position
y1vertical position
y2vertical position
color16-bit color, which can be produced by ST7735_Color565()
Returns
none

◆ ST7735_OutChar()

void ST7735_OutChar ( char  ch)

Output a character.

Output one character to the LCD Position determined by ST7735_SetCursor command Color set by ST7735_SetTextColor

Parameters
ch8-bit ASCII character
Returns
none

◆ ST7735_OutCharTransparent()

void ST7735_OutCharTransparent ( char  ch)

Output a character transparently.

Output one character to the LCD Position determined by ST7735_SetCursor command Color set by ST7735_SetTextColor, background is transparent

Parameters
ch8-bit ASCII character
Returns
none

◆ ST7735_OutSDec2()

void ST7735_OutSDec2 ( int32_t  n,
uint32_t  l 
)

Output a signed decimal.

Output a 32-bit number in signed decimal format. x Position is 14 y position determined by line number Color is ST7735_YELLOW.

Parameters
nis 32-bit signed number to be transferred
lis line number
Returns
none
Note
Variable format 1-10 digits with no space before or after

◆ ST7735_OutString()

void ST7735_OutString ( char *  ptr)

Output a string.

Print a string of characters to the ST7735 LCD. Position determined by ST7735_SetCursor command Color set by ST7735_SetTextColor The string will not automatically wrap.

Parameters
ptrpointer to NULL-terminated ASCII string
Returns
none

◆ ST7735_OutStringTransparent()

void ST7735_OutStringTransparent ( char *  ptr)

Output a string transparently.

Print a string of characters to the ST7735 LCD. Position determined by ST7735_SetCursor command Color set by ST7735_SetTextColor, background is transparent The string will not automatically wrap.

Parameters
ptrpointer to NULL-terminated ASCII string
Returns
none

◆ ST7735_OutUDec()

void ST7735_OutUDec ( uint32_t  n)

Output an unsigned decimal.

Output a 32-bit number in unsigned decimal format. Position determined by ST7735_SetCursor command. Color set by ST7735_SetTextColor.

Parameters
n32-bit number to be transferred
Returns
none
Note
Variable format 1-10 digits with no space before or after

◆ ST7735_OutUDec4()

void ST7735_OutUDec4 ( uint32_t  n)

Output a 4-digit unsigned decimal.

Output a 32-bit number in unsigned 4-digit decimal format with no space before or after. Color set by ST7735_SetTextColor. Position determined by ST7735_SetCursor command

Parameters
n32-bit number to be transferred
Returns
none
Note
Fixed format 4 digits with no space before or after

◆ ST7735_OutUDec5()

void ST7735_OutUDec5 ( uint32_t  n)

Output a 5-digit unsigned decimal.

Output a 32-bit number in unsigned 5-digit decimal format with no space before or after. Color set by ST7735_SetTextColor. Position determined by ST7735_SetCursor command

Parameters
n32-bit number to be transferred
Returns
none
Note
Fixed format 5 digits with no space before or after

◆ ST7735_OutUFix2_1()

void ST7735_OutUFix2_1 ( uint32_t  n,
int16_t  textColor 
)

Output a 2-digit fixed-point decimal.

Output a 32-bit number in unsigned 3-digit fixed point, 0.1 resolution numbers 0 to 999 printed as " 0.0" to "99.9" Position determined by ST7735_SetCursor command

Parameters
n32-bit number to be transferred
textColor16-bit color of the numbers
Returns
none
Note
Fixed format 4 characters with no space before or after

◆ ST7735_OutUHex2()

void ST7735_OutUHex2 ( uint32_t  n,
int16_t  textColor 
)

Output a 2-digit hexadecimal number.

Output a 32-bit number in unsigned 2-digit hexadecimal format numbers 0 to 255 printed as "00," to "FF," Position determined by ST7735_SetCursor command

Parameters
n32-bit number to be transferred
textColor16-bit color of the numbers
Returns
none
Note
Fixed format 3 characters with comma after

◆ ST7735_PlotBar()

void ST7735_PlotBar ( int32_t  y)

Plot one bar.

Used in the voltage versus time bar plot, plot one bar at y It does output to display. The units of the data are the same as the ymax and ymin values specified in the initialization function. Call ST7735_PlotIncrement() to move time.

Parameters
yis the y coordinate of the bar plotted
Returns
none
Note
Assumes: ST7735_InitR() and ST7735_Drawaxes() have been called

◆ ST7735_PlotClear()

void ST7735_PlotClear ( int32_t  ymin,
int32_t  ymax 
)

Clear plot.

Clear the graphics buffer, set X coordinate to 0 This routine clears the display

Parameters
yminminimum plot value
ymaxmaximum plot value
Returns
none

◆ ST7735_PlotdBfs()

void ST7735_PlotdBfs ( int32_t  y)

Plot one bar.

Used in the amplitude versus frequency plot, plot one bar at y It does output to display. 0 to 0.625V scaled on a log plot from min to max. Call ST7735_PlotIncrement() to move x axis.

Parameters
yis the y ADC value of the bar plotted
Returns
none
Note
Assumes: ST7735_InitR() and ST7735_Drawaxes() have been called

◆ ST7735_PlotLine()

void ST7735_PlotLine ( int32_t  y)

Plot one line.

Used in the voltage versus time plot, plot line to new point It does output to display

Parameters
yvalue to be plotted
Returns
none
Note
Assumes: ST7735_InitR() and ST7735_Drawaxes() have been called

◆ ST7735_PlotNext()

void ST7735_PlotNext ( void  )

Move x-axis parameter.

Used in all the plots to step the X coordinate one pixel. ST7735_PlotIncrement will erase the new line (clearing the display as it goes). ST7735_PlotNext does not erase the new line (plots over itself as it wraps). X steps from 0 to 127, then back to 0 again It does not output to display

Parameters
none
Returns
none

◆ ST7735_PlotNextErase()

void ST7735_PlotNextErase ( void  )

Move X coordinate

Used in all the plots to step the X coordinate one pixel X steps from 0 to 127, then back to 0 again It clears the vertical space into which the next pixel will be drawn

Parameters
none
Returns
none

◆ ST7735_PlotPoint()

void ST7735_PlotPoint ( int32_t  y)

Plot one point.

Plot a point on the chart. To plot several points in the same column, call this function repeatedly before calling ST7735PlotIncrement(). The units of the data are the same as the ymax and ymin values specified in the initialization function.

Parameters
yvalue to be plotted (units not specified)
Returns
none
Note
Assumes: ST7735_InitR() and ST7735_Drawaxes() have been called

◆ ST7735_PlotPoint2()

void ST7735_PlotPoint2 ( int32_t  data1,
uint16_t  color1 
)

Plot one point with color.

Plot a point on the chart. To plot several points in the same column, call this function repeatedly before calling ST7735_PlotIncrement(). The units of the data are the same as the ymax and ymin values specified in the initialization function.

Parameters
data1value to be plotted (units not specified)
color116-bit color for the point, which can be produced by ST7735_Color565()
Returns
none
Note
Assumes: ST7735_InitR() and ST7735_Drawaxes() have been called

◆ ST7735_PlotPoints()

void ST7735_PlotPoints ( int32_t  y1,
int32_t  y2 
)

Plot two points.

Used in the voltage versus time plot, plot two points at y1, y2 It does output to display. The units of the data are the same as the ymax and ymin values specified in the initialization function. Call ST7735_PlotIncrement() to move time.

Parameters
y1is the y coordinate of the first point plotted
y2is the y coordinate of the second point plotted
Returns
none
Note
Assumes: ST7735_InitR() and ST7735_Drawaxes() have been called

◆ ST7735_sDecOut2()

void ST7735_sDecOut2 ( int32_t  n)

fixed point output resolution 0.01

Fixed point output resolution 0.01.

Outputs signed fixed point number to LCD. The format signed 32-bit with resolution 0.01. The range -99.99 to +99.99

ST7735_sDecOut2
Parameter LCD display
12345 " **.**"
2345 " 23.45"
-8100 "-81.00"
-102 " -1.02"
31 " 0.31"
-12345 "-**.**"
Parameters
nsigned 32-bit integer part of fixed-point number
Returns
none
Note
send exactly 6 characters to the LCD

Outputs signed fixed point number to LCD. The format signed 32-bit with resolution 0.01. The range -99.99 to +99.99

ST7735_sDecOut2
Parameter LCD display
12345 " **.**"
2345 " 23.45"
-8100 "-81.00"
-102 " -1.02"
31 " 0.31"
-12345 "-**.**"
Parameters
nsigned 32-bit integer part of fixed-point number
Returns
none
Note
Send exactly 6 characters to the LCD

◆ ST7735_SetCursor()

void ST7735_SetCursor ( uint32_t  newX,
uint32_t  newY 
)

Move the cursor.

Move the cursor to the desired X- and Y-position. The next character of the next unsigned decimal will be printed here. X=0 is the leftmost column. Y=0 is the top row. The cursor is used by the "Out" functions, but not the "Draw" functions

Parameters
newXnew X-position of the cursor (0<=newX<=20)
newYnew Y-position of the cursor (0<=newY<=15)
Returns
none

◆ ST7735_SetRotation()

void ST7735_SetRotation ( uint8_t  m)

Change rotation.

Change the image rotation. Requires 2 bytes of transmission

Parameters
mnew rotation value (0 to 3)
Returns
none

◆ ST7735_SetTextColor()

void ST7735_SetTextColor ( uint16_t  color)

sets the text color

Sets the text color.

Sets the color in which the characters will be printed Background color is fixed at black

Parameters
color16-bit packed color
Returns
none

◆ ST7735_SetX()

void ST7735_SetX ( int32_t  newX)

set X-position

Set X-position.

Used in all the plots to change the X coordinate to new location X exists in the range from 0 to 127, Input values less than 0 get changed to 0, Input values greater than 127 get changed to 127 It does not output to display

Parameters
newXis the new value that the global X will be
Returns
none

◆ ST7735_SwapColor()

uint16_t ST7735_SwapColor ( uint16_t  x)

Swaps red and blue.

Swaps the red and blue values of the given 16-bit packed color; green is unchanged.

Parameters
x16-bit color in format B, G, R
Returns
16-bit color in format R, G, B

◆ ST7735_uBinOut6()

void ST7735_uBinOut6 ( uint32_t  n)

fixed point output resolution 1/64

Fixed point output resolution 1/64.

unsigned 32-bit binary fixed-point with a resolution of 1/64. The full-scale range is from 0 to 999.99. If the integer part is larger than 63999, it signifies an error. The ST7735_uBinOut6 function takes an unsigned 32-bit integer part of the binary fixed-point number and outputs the fixed-point value on the LCD

ST7735_uBinOut6
Parameter LCD display
0 " 0.00"
1 " 0.01"
16 " 0.25"
25 " 0.39"
125 " 1.95"
128 " 2.00"
1250 " 19.53"
7500 "117.19"
63999 "999.99"
64000 "***.**"
Parameters
nunsigned 32-bit integer part of binary fixed-point number
Returns
none
Note
send exactly 6 characters to the LCD

unsigned 32-bit binary fixed-point with a resolution of 1/64. The full-scale range is from 0 to 999.99. If the integer part is larger than 63999, it signifies an error. The ST7735_uBinOut6 function takes an unsigned 32-bit integer part of the binary fixed-point number and outputs the fixed-point value on the LCD

ST7735_uBinOut6
Parameter LCD display
0 " 0.00"
1 " 0.01"
16 " 0.25"
25 " 0.39"
125 " 1.95"
128 " 2.00"
1250 " 19.53"
7500 "117.19"
63999 "999.99"
64000 "***.**"
Parameters
nunsigned 32-bit integer part of binary fixed-point number
Returns
none
Note
Send exactly 6 characters to the LCD

◆ ST7735_XYplot()

void ST7735_XYplot ( uint32_t  num,
int32_t  bufX[],
int32_t  bufY[] 
)

XY plot.

Plot an array of (x,y) data, neglect any points outside the minX maxY minY maxY bounds

Parameters
numnumber of data points in the two arrays
bufXarray of 32-bit fixed-point data, resolution= 0.001
bufYarray of 32-bit fixed-point data, resolution= 0.001
Returns
none
Note
assumes ST7735_XYplotInit has been previously called

Plot an array of (x,y) data, neglect any points outside the minX maxY minY maxY bounds

Parameters
numnumber of data points in the two arrays
bufXarray of 32-bit fixed-point data, resolution= 0.001
bufYarray of 32-bit fixed-point data, resolution= 0.001
Returns
none
Note
Assumes ST7735_XYplotInit has been previously called

◆ ST7735_XYplotInit()

void ST7735_XYplotInit ( char *  title,
int32_t  minX,
int32_t  maxX,
int32_t  minY,
int32_t  maxY 
)

initialize XY plot

Initialize XY plot.

Specify the X and Y axes for an x-y scatter plot Draw the title and clear the plot area

Parameters
titleASCII string to label the plot, null-termination
minXsmallest X data value allowed, resolution= 0.001
maxXlargest X data value allowed, resolution= 0.001
minYsmallest Y data value allowed, resolution= 0.001
maxYlargest Y data value allowed, resolution= 0.001
Returns
none
Note
assumes minX < maxX, and miny < maxY

Specify the X and Y axes for an x-y scatter plot Draw the title and clear the plot area

Parameters
titleASCII string to label the plot, null-termination
minXsmallest X data value allowed, resolution= 0.001
maxXlargest X data value allowed, resolution= 0.001
minYsmallest Y data value allowed, resolution= 0.001
maxYlargest Y data value allowed, resolution= 0.001
Returns
none
Note
Sssumes minX < maxX, and miny < maxY

◆ ST7735PlotIncrement()

void ST7735PlotIncrement ( void  )

Moves the plot cursor in time.

Increment the plot between subsequent calls to ST7735_PlotPoint(). Automatically wrap and clear the column to be printed to. ST7735_PlotIncrement will erase the new line (clearing the display as it goes). ST7735_PlotNext does not erase the new line (plots over itself as it wraps).

Parameters
none
Returns
none
Note
Assumes: ST7735_InitR() and ST7735_Drawaxes() have been called