Extendes Version of TextLCD which scrolls oversized lines.
Dependents: RF22_MAX_test_Send
TextLCDScroll.h
00001 /** mbed Library for scrolling text in Text-LCDs based on the Class TextLCD 00002 * Copyright by Karl Zweimueller 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 * THE SOFTWARE. 00021 */ 00022 00023 #ifndef TEXTLCDSCROLL_H 00024 #define TEXTLCDSCROLL_H 00025 00026 #include "TextLCD.h" 00027 00028 00029 /** TextLCDScroll class which handles horizontal scrolling text if it doesn't fit in one line, based on class TextLCD 00030 * 00031 * Example: 00032 * @code 00033 * #include "TextLCDScroll.h" 00034 * #include "mbed.h" 00035 * 00036 * TextLCDScroll lcd(p30, p29, p28, p27, p26, p25, TextLCD::LCD16x2); // rs, e, d0-d3 00037 * 00038 * int main() { 00039 * 00040 * lcd.cls(); 00041 * lcd.setLine(0,"TextLCDScroll!"); 00042 * lcd.setLine(1,"This line can be rather long. The quick brown fox jumps over the lazy dog."); 00043 * } 00044 * @endcode 00045 */ 00046 class TextLCDScroll: public TextLCD { 00047 public: 00048 00049 /** How should we scroll horizontal in one line 00050 */ 00051 enum ScrollModes { 00052 leftright /** Scroll left ande the right */ 00053 ,left /** Scroll only left - default */ 00054 }; 00055 00056 /** Create a TextLCDScroll Object with pins and Type from TextLCD 00057 * 00058 * @param rs Instruction/data control line 00059 * @param e Enable line (clock) 00060 * @param d4-d7 Data lines for using as a 4-bit interface 00061 * @param type Sets the panel size/addressing mode (default = LCD16x2) 00062 */ 00063 TextLCDScroll(PinName rs, PinName e, PinName d4, PinName d5, 00064 PinName d6, PinName d7, TextLCD::LCDType type); 00065 00066 00067 /** Display a string str on line Line. Replaces old text on this Line. 00068 * @param Line Line, where text should be displayed. first Line=0 00069 * @param *str the string to display (c-string) 00070 */ 00071 bool setLine( int Line, char *str); 00072 00073 /* Clear the display 00074 * 00075 */ 00076 void cls(); 00077 00078 /** Set the speed, how fast to scroll the text in Characters per Second 00079 * @param speed Speed for scrolling in Characters per Second. Range 0.1 ... 10 00080 */ 00081 bool setSpeed( int speed); 00082 00083 /** Set the Scroll-Mode. Deault "left" 00084 * @param mode a valid mode. See ScrollModes 00085 */ 00086 bool setScrollMode( ScrollModes mode); 00087 00088 private: 00089 void startTicker(); 00090 00091 void ScrollRightLeft(); 00092 00093 void ScrollLeft(); 00094 00095 Ticker tick; 00096 ScrollModes _mode; 00097 00098 // these are changed in interrupt-routine! 00099 volatile int* _direction; 00100 volatile int* _actPos; 00101 volatile int _speed; 00102 00103 char* line[99]; 00104 00105 }; 00106 00107 #endif
Generated on Tue Jul 12 2022 19:38:16 by
1.7.2