Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
SerialGraphicLCD Class Reference
Interface to the Sparkfun Serial Graphic LCD, LCD-09351; and Graphic LCD Serial Backpack, LCD-09352. More...
#include <SerialGraphicLCD.h>
Public Member Functions | |
SerialGraphicLCD (PinName tx, PinName rx) | |
Create a new interface to a Serial Graphic LCD Note that the display lower left corner is coordinates 0, 0. | |
SerialGraphicLCD (PinName tx, PinName rx, int firmware) | |
Create a new interface to a Serial Graphic LCD Note that the display lower left corner is coordinates 0, 0. | |
void | clear (void) |
clear the screen | |
void | pos (int col, int row) |
set text position in rows, columns | |
void | posXY (int x, int y) |
set text position in x, y coordinates | |
void | pixel (int x, int y, bool set) |
set or erase a pixel | |
void | line (int x1, int y1, int x2, int y2, bool set) |
draw or erase a line | |
void | circle (int x, int y, int r, bool set) |
set or reset a circle | |
void | rect (int x1, int y1, int x2, int y2) |
draw a rectangle | |
void | rect (int x1, int y1, int x2, int y2, bool set) |
draw or erase a rectangle (SD firmware only) | |
void | rectFill (int x1, int y1, int x2, int y2, char fillByte) |
Draw a filled box. | |
void | erase (int x1, int y1, int x2, int y2) |
erase a rectangular area | |
void | backlight (int i) |
set backlight duty cycle | |
void | reverseMode (void) |
clear screen and put in reverse mode | |
void | lcdbaud (int b) |
configure the lcd baud rate so you have to call this along with baud() to change communication speeds | |
void | resolution (int type) |
sets the resolution of the LCD so that the pos() call works properly defaults to LCD_128x64. | |
void | resolution (int x, int y) |
sets the resolution of the LCD in x and y coordinates which determines how rows and columns are calculated in the pos() call. |
Detailed Description
Interface to the Sparkfun Serial Graphic LCD, LCD-09351; and Graphic LCD Serial Backpack, LCD-09352.
Derived class from Serial so that you can conveniently printf(), putc(), etc to the display.
Example:
#include "mbed.h" #include "SerialGraphicLCD.h" SerialGraphicLCD lcd(p26, p25); int main() { lcd.baud(115200); // default baud rate while (1) { lcd.clear(); lcd.rect(3, 3, 20, 20); lcd.printf("Hello World!"); lcd.pixel(14, 35, true); lcd.pixel(16, 36, true); lcd.pixel(18, 37, true); lcd.pos(5, 30); lcd.printf("Hi"); lcd.circle(50, 20, 20, true); lcd.pos(50, 20); lcd.printf("Howdy"); lcd.line(0, 0, 25, 25, true); wait(2); } }
Definition at line 63 of file SerialGraphicLCD.h.
Constructor & Destructor Documentation
SerialGraphicLCD | ( | PinName | tx, |
PinName | rx | ||
) |
Create a new interface to a Serial Graphic LCD Note that the display lower left corner is coordinates 0, 0.
Rows start at the top at 0, columns start at the left at 0.
- Parameters:
-
tx -- mbed transmit pin rx -- mbed receive pin
Definition at line 6 of file SerialGraphicLCD.cpp.
SerialGraphicLCD | ( | PinName | tx, |
PinName | rx, | ||
int | firmware | ||
) |
Create a new interface to a Serial Graphic LCD Note that the display lower left corner is coordinates 0, 0.
Rows start at the top at 0, columns start at the left at 0.
- Parameters:
-
tx -- mbed transmit pin rx -- mbed receive pin firmware -- SFE_FW, stock firmware or SD_FW, summoningdark firmware
Definition at line 13 of file SerialGraphicLCD.cpp.
Member Function Documentation
void backlight | ( | int | i ) |
set backlight duty cycle
- Parameters:
-
i is the duty cycle from 0 to 100; 0 is off, 100 is full power
Definition at line 121 of file SerialGraphicLCD.cpp.
void circle | ( | int | x, |
int | y, | ||
int | r, | ||
bool | set | ||
) |
set or reset a circle
- Parameters:
-
x is the x coordinate of the circle center y is the y coordinate of the circle center r is the radius of the circle set if true sets the pixel, if false, clears it
Definition at line 59 of file SerialGraphicLCD.cpp.
void clear | ( | void | ) |
clear the screen
Definition at line 20 of file SerialGraphicLCD.cpp.
void erase | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 | ||
) |
erase a rectangular area
- Parameters:
-
x1 is the x coordinate of the upper left of the area y1 is the y coordinate of the upper left of the area x2 is the x coordinate of the lower right of the area y2 is the y coordinate of the lower right of the area
Definition at line 112 of file SerialGraphicLCD.cpp.
void lcdbaud | ( | int | b ) |
configure the lcd baud rate so you have to call this along with baud() to change communication speeds
- Parameters:
-
b is the baud rate, LCD_4800, LCD_9600, LCD_19200, LCD_38400, LCD_57600 or LCD_115200
Definition at line 151 of file SerialGraphicLCD.cpp.
void line | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
bool | set | ||
) |
draw or erase a line
- Parameters:
-
x1 is the x coordinate of the start of the line y1 is the y coordinate of the start of the line x2 is the x coordinate of the end of the line y2 is the y coordinate of the end of the line set if true sets the line, if false, erases it
Definition at line 49 of file SerialGraphicLCD.cpp.
void pixel | ( | int | x, |
int | y, | ||
bool | set | ||
) |
set or erase a pixel
- Parameters:
-
x is the x coordinate y is the y coordinate set if true sets the pixel, if false, erases it
Definition at line 41 of file SerialGraphicLCD.cpp.
void pos | ( | int | col, |
int | row | ||
) |
set text position in rows, columns
- Parameters:
-
col is the col coordinate row is the row coordinate
Definition at line 25 of file SerialGraphicLCD.cpp.
void posXY | ( | int | x, |
int | y | ||
) |
set text position in x, y coordinates
- Parameters:
-
x is the x coordinate y is the y coordinate
Definition at line 32 of file SerialGraphicLCD.cpp.
void rect | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
bool | set | ||
) |
draw or erase a rectangle (SD firmware only)
- Parameters:
-
x1 is the x coordinate of the upper left of the rectangle y1 is the y coordinate of the upper left of the rectangle x2 is the x coordinate of the lower right of the rectangle y2 is the y coordinate of the lower right of the rectangle
Definition at line 82 of file SerialGraphicLCD.cpp.
void rect | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 | ||
) |
draw a rectangle
- Parameters:
-
x1 is the x coordinate of the upper left of the rectangle y1 is the y coordinate of the upper left of the rectangle x2 is the x coordinate of the lower right of the rectangle y2 is the y coordinate of the lower right of the rectangle
Definition at line 71 of file SerialGraphicLCD.cpp.
void rectFill | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
char | fillByte | ||
) |
Draw a filled box.
- Parameters:
-
x1 is the x coordinate of the upper left of the rectangle y1 is the y coordinate of the upper left of the rectangle x2 is the x coordinate of the lower right of the rectangle y2 is the y coordinate of the lower right of the rectangle fillByte describes 1 8-pixel high stripe that is repeated every x pixels and every 8 y pixels. The most useful are CLEAR (0x00) to clear the box, and FILL (0xFF) to fill it.
Definition at line 93 of file SerialGraphicLCD.cpp.
void resolution | ( | int | type ) |
sets the resolution of the LCD so that the pos() call works properly defaults to LCD_128x64.
- Parameters:
-
type is the type of LCD, either LCD_128x64 or LCD_160x128
Definition at line 134 of file SerialGraphicLCD.cpp.
void resolution | ( | int | x, |
int | y | ||
) |
sets the resolution of the LCD in x and y coordinates which determines how rows and columns are calculated in the pos() call.
Defaults to x=128, y=64
- Parameters:
-
x is the number of horizontal pixels y is the number of vertical pixels
Definition at line 145 of file SerialGraphicLCD.cpp.
void reverseMode | ( | void | ) |
clear screen and put in reverse mode
Definition at line 129 of file SerialGraphicLCD.cpp.
Generated on Tue Jul 12 2022 14:09:28 by 1.7.2