Ken Todotani
/
eDISP
eDisp library and sample code
Embed:
(wiki syntax)
Show/hide line numbers
eDisp.h
00001 /* mbed eDISP Library 00002 * Copyright (c) 2010 todotani 00003 * Version 0.1 (March 6, 2010) 00004 * Released under the MIT License: http://mbed.org/license/mit 00005 */ 00006 00007 #ifndef MBED_EDISP_H 00008 #define MBED_EDISP_H 00009 00010 #include "mbed.h" 00011 #include "Stream.h" 00012 00013 // Text Color code 00014 #define BLACK 30 00015 #define RED 31 00016 #define GREEN 32 00017 #define YELLOW 33 00018 #define BLUE 34 00019 #define PURPLE 35 00020 #define AQUA 36 00021 #define WHITE 37 00022 #define TRANSPARENT 49 // default background color 00023 00024 // RGB555 color code (converted from 32bit color code) 00025 #define RGB_Black (0 << 10) + (0 << 5) + 0 00026 #define RGB_Navy (0 << 10) + (0 << 5) + 0x80/8 00027 #define RGB_Silver (0xc0/8 << 10) + (0xc0/8 << 5) + 0xc0/8 00028 #define RGB_Blue (0 << 10) + (0 << 5) + 0xff/8 00029 #define RGB_Maroon (0x80/8 << 10) + (0 << 5) + 0 00030 #define RGB_Purple (0x80/8 << 10) + (0 << 5) + 0x80/8 00031 #define RGB_Red (0xff/8 << 10) + (0 << 5) + 0 00032 #define RGB_Fuchsia (0xff/8 << 10) + (0 << 5) + 0xff/8 00033 #define RGB_Green (0 << 10) + (0x80/8 << 5) + 0 00034 #define RGB_Teal (0 << 10) + (0x80/8 << 5) + 0x80/8 00035 #define RGB_Lime (0 << 10) + (0xff/8 << 5) + 0 00036 #define RGB_Aqua (0 << 10) + (0xff/8 << 5) + 0xff/8 00037 #define RGB_Olive (0x80/8 << 10) + (0x80/8 << 5) + 0 00038 #define RGB_Gray (0x80/8 << 10) + (0x80/8 << 5) + 0x80/8 00039 #define RGB_Yellow (0xff/8 << 10) + (0xff/8 << 5) + 0 00040 #define RGB_White (0xff/8 << 10) + (0xff/8 << 5) + 0xff/8 00041 00042 00043 namespace mbed { 00044 00045 /* Class: eDisp 00046 * Driver for eDISP (http://www.ddlab.jp/shop/edisp/syouhin.cgi) 00047 * 00048 * Allows you to print to a Text LCD screen, set color and locate/cls. 00049 * Also support graphics functions fillRect, drawLine 00050 * 00051 */ 00052 class eDisp : public Stream { 00053 public: 00054 /* Constructor: eDisp 00055 * Create a eDisp object, connected to the specified pins 00056 * 00057 * All signals must be connected to pair of Serial Tx/Rx pin 00058 * (p9/p10, p13/p14 or p28/p27) 00059 * 00060 * Variables: 00061 * tx - Used to specify tx of Serial port 00062 * rx - Used to specify rx of Serial port (acturally not used) 00063 * baud - baudrate of serial port 00064 */ 00065 eDisp(PinName tx, PinName rx, int baud = 19200, 00066 int columns = 40, int rows = 15); 00067 00068 #if 0 // Inhereted from Stream, for documentation only 00069 /* Function: putc 00070 * Write a character 00071 * 00072 * Variables: 00073 * c - The character to write to the serial port 00074 */ 00075 int putc(int c); 00076 00077 /* Function: printf 00078 * Write a formated string 00079 * 00080 * Variables: 00081 * format - A printf-style format string, followed by the 00082 * variables to use in formating the string. 00083 */ 00084 int printf(const char* format, ...); 00085 #endif 00086 00087 /* Function: locate 00088 * set cursor position 00089 * Variables: 00090 * colum - x position (0 - 39) 00091 * row - y position (0 - 14) 00092 */ 00093 void locate(int column, int row); 00094 00095 /* Function: textColor 00096 * Set text color 00097 * Variables: 00098 * color - Text color code 00099 */ 00100 void textColor(int color); 00101 00102 /* Function: backgroundColor 00103 * Set backgound color 00104 * Variables: 00105 * color - Text color code 00106 */ 00107 void backgroundColor(int color); 00108 00109 /* Function: cls 00110 * Clear the screen, and locate to 0,0 00111 */ 00112 void cls(); 00113 00114 /* Function: reset 00115 * Set default text/backgroudn color, clear the screen, and locate to 0,0 00116 */ 00117 void reset(); 00118 00119 /* Function: fillRect 00120 * Fill secreen with specified color 00121 * Variables: 00122 * buffer - number of screen buffer (0 - 3) 00123 * width - width of rectangle (1 - 320) 00124 * hight - hight of rectangle (1 - 240) 00125 * x - x coordinate (0 - 319) of upper left point 00126 * y - y coordinate (0 - 239) of upper left point 00127 * color - RGB555 color code 0rrrrrgggggbbbbb 00128 */ 00129 void fillRect(int buffer, int width, int hight, int x, int y, int color ); 00130 00131 /* Function: drawLine 00132 * draw line from (x0, y0) to (x1, y1) 00133 * Variables: 00134 * buffer - number of screen buffer (0 - 3) 00135 * x0 - coordinate x (0 - 319) of start point 00136 * y0 - coordinate y (0 - 319) of start point 00137 * x1 - coordinate x (0 - 319) of end point 00138 * y1 - coordinate y (0 - 319) of end point 00139 * color - RGB555 color code 0rrrrrgggggbbbbb 00140 */ 00141 void drawLine(int buffer, int x0, int y0, int x1, int y1, int color); 00142 00143 protected: 00144 virtual int _putc(int c); 00145 virtual int _getc(); 00146 void newline(); 00147 00148 Serial _serial; 00149 int _baud; 00150 int _row; 00151 int _column; 00152 int _columns; // Number of max columns 00153 int _rows; // Number of max rows 00154 }; 00155 00156 #endif 00157 }
Generated on Sat Jul 23 2022 13:30:29 by 1.7.2