Extendes Version of TextLCD which scrolls oversized lines.

Dependents:   RF22_MAX_test_Send

Extended version of TextLCD, which can scoll oversized lines. Uses a ticker!

Committer:
charly
Date:
Thu Apr 04 19:07:26 2013 +0000
Revision:
5:e3b565c4190c
Parent:
3:1d7a7a249647
Disable Ticker while changing settings. realloc instead of malloc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charly 1:d7cc0e2a55ba 1 /** mbed Library for scrolling text in Text-LCDs based on the Class TextLCD
charly 0:0ae9963c4e06 2 * Copyright by Karl Zweimueller
charly 0:0ae9963c4e06 3 *
charly 0:0ae9963c4e06 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
charly 0:0ae9963c4e06 5 * of this software and associated documentation files (the "Software"), to deal
charly 0:0ae9963c4e06 6 * in the Software without restriction, including without limitation the rights
charly 0:0ae9963c4e06 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
charly 0:0ae9963c4e06 8 * copies of the Software, and to permit persons to whom the Software is
charly 0:0ae9963c4e06 9 * furnished to do so, subject to the following conditions:
charly 0:0ae9963c4e06 10 *
charly 0:0ae9963c4e06 11 * The above copyright notice and this permission notice shall be included in
charly 0:0ae9963c4e06 12 * all copies or substantial portions of the Software.
charly 0:0ae9963c4e06 13 *
charly 0:0ae9963c4e06 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
charly 0:0ae9963c4e06 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
charly 0:0ae9963c4e06 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
charly 0:0ae9963c4e06 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
charly 0:0ae9963c4e06 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
charly 0:0ae9963c4e06 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
charly 0:0ae9963c4e06 20 * THE SOFTWARE.
charly 0:0ae9963c4e06 21 */
charly 0:0ae9963c4e06 22
charly 0:0ae9963c4e06 23 #ifndef TEXTLCDSCROLL_H
charly 0:0ae9963c4e06 24 #define TEXTLCDSCROLL_H
charly 0:0ae9963c4e06 25
charly 0:0ae9963c4e06 26 #include "TextLCD.h"
charly 0:0ae9963c4e06 27
charly 0:0ae9963c4e06 28
charly 0:0ae9963c4e06 29 /** TextLCDScroll class which handles horizontal scrolling text if it doesn't fit in one line, based on class TextLCD
charly 0:0ae9963c4e06 30 *
charly 0:0ae9963c4e06 31 * Example:
charly 0:0ae9963c4e06 32 * @code
charly 0:0ae9963c4e06 33 * #include "TextLCDScroll.h"
charly 0:0ae9963c4e06 34 * #include "mbed.h"
charly 0:0ae9963c4e06 35 *
charly 0:0ae9963c4e06 36 * TextLCDScroll lcd(p30, p29, p28, p27, p26, p25, TextLCD::LCD16x2); // rs, e, d0-d3
charly 0:0ae9963c4e06 37 *
charly 0:0ae9963c4e06 38 * int main() {
charly 0:0ae9963c4e06 39 *
charly 0:0ae9963c4e06 40 * lcd.cls();
charly 0:0ae9963c4e06 41 * lcd.setLine(0,"TextLCDScroll!");
charly 0:0ae9963c4e06 42 * lcd.setLine(1,"This line can be rather long. The quick brown fox jumps over the lazy dog.");
charly 0:0ae9963c4e06 43 * }
charly 0:0ae9963c4e06 44 * @endcode
charly 0:0ae9963c4e06 45 */
charly 0:0ae9963c4e06 46 class TextLCDScroll: public TextLCD {
charly 0:0ae9963c4e06 47 public:
charly 0:0ae9963c4e06 48
charly 0:0ae9963c4e06 49 /** How should we scroll horizontal in one line
charly 0:0ae9963c4e06 50 */
charly 0:0ae9963c4e06 51 enum ScrollModes {
charly 1:d7cc0e2a55ba 52 leftright /** Scroll left ande the right */
charly 1:d7cc0e2a55ba 53 ,left /** Scroll only left - default */
charly 0:0ae9963c4e06 54 };
charly 0:0ae9963c4e06 55
charly 0:0ae9963c4e06 56 /** Create a TextLCDScroll Object with pins and Type from TextLCD
charly 0:0ae9963c4e06 57 *
charly 0:0ae9963c4e06 58 * @param rs Instruction/data control line
charly 0:0ae9963c4e06 59 * @param e Enable line (clock)
charly 0:0ae9963c4e06 60 * @param d4-d7 Data lines for using as a 4-bit interface
charly 0:0ae9963c4e06 61 * @param type Sets the panel size/addressing mode (default = LCD16x2)
charly 0:0ae9963c4e06 62 */
charly 0:0ae9963c4e06 63 TextLCDScroll(PinName rs, PinName e, PinName d4, PinName d5,
charly 0:0ae9963c4e06 64 PinName d6, PinName d7, TextLCD::LCDType type);
charly 0:0ae9963c4e06 65
charly 0:0ae9963c4e06 66
charly 1:d7cc0e2a55ba 67 /** Display a string str on line Line. Replaces old text on this Line.
charly 0:0ae9963c4e06 68 * @param Line Line, where text should be displayed. first Line=0
charly 3:1d7a7a249647 69 * @param *str the string to display (c-string)
charly 0:0ae9963c4e06 70 */
charly 3:1d7a7a249647 71 bool setLine( int Line, char *str);
charly 3:1d7a7a249647 72
charly 3:1d7a7a249647 73 /* Clear the display
charly 3:1d7a7a249647 74 *
charly 3:1d7a7a249647 75 */
charly 3:1d7a7a249647 76 void cls();
charly 0:0ae9963c4e06 77
charly 1:d7cc0e2a55ba 78 /** Set the speed, how fast to scroll the text in Characters per Second
charly 0:0ae9963c4e06 79 * @param speed Speed for scrolling in Characters per Second. Range 0.1 ... 10
charly 0:0ae9963c4e06 80 */
charly 0:0ae9963c4e06 81 bool setSpeed( int speed);
charly 0:0ae9963c4e06 82
charly 0:0ae9963c4e06 83 /** Set the Scroll-Mode. Deault "left"
charly 0:0ae9963c4e06 84 * @param mode a valid mode. See ScrollModes
charly 0:0ae9963c4e06 85 */
charly 0:0ae9963c4e06 86 bool setScrollMode( ScrollModes mode);
charly 0:0ae9963c4e06 87
charly 0:0ae9963c4e06 88 private:
charly 5:e3b565c4190c 89 void startTicker();
charly 0:0ae9963c4e06 90
charly 0:0ae9963c4e06 91 void ScrollRightLeft();
charly 0:0ae9963c4e06 92
charly 0:0ae9963c4e06 93 void ScrollLeft();
charly 0:0ae9963c4e06 94
charly 0:0ae9963c4e06 95 Ticker tick;
charly 0:0ae9963c4e06 96 ScrollModes _mode;
charly 2:66723c542cef 97
charly 2:66723c542cef 98 // these are changed in interrupt-routine!
charly 2:66723c542cef 99 volatile int* _direction;
charly 2:66723c542cef 100 volatile int* _actPos;
charly 5:e3b565c4190c 101 volatile int _speed;
charly 3:1d7a7a249647 102
charly 3:1d7a7a249647 103 char* line[99];
charly 2:66723c542cef 104
charly 0:0ae9963c4e06 105 };
charly 0:0ae9963c4e06 106
charly 0:0ae9963c4e06 107 #endif