Fork of LCD-Window which works with Enhanced TextLCD from Wim
Fork of LcdWindow by
textlcdadapter.cpp@13:99b500b05716, 2016-01-13 (annotated)
- Committer:
- charly
- Date:
- Wed Jan 13 19:38:54 2016 +0000
- Revision:
- 13:99b500b05716
- Parent:
- 12:393329d0e050
added enableDisplay and disableDisplay for Terminal to stop the output to LCD.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hlipka | 4:aa08e82834dc | 1 | /* |
hlipka | 4:aa08e82834dc | 2 | * mbed LCDWindow library |
hlipka | 4:aa08e82834dc | 3 | * Copyright (c) 2010 Hendrik Lipka |
hlipka | 4:aa08e82834dc | 4 | * |
hlipka | 4:aa08e82834dc | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
hlipka | 4:aa08e82834dc | 6 | * of this software and associated documentation files (the "Software"), to deal |
hlipka | 4:aa08e82834dc | 7 | * in the Software without restriction, including without limitation the rights |
hlipka | 4:aa08e82834dc | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
hlipka | 4:aa08e82834dc | 9 | * copies of the Software, and to permit persons to whom the Software is |
hlipka | 4:aa08e82834dc | 10 | * furnished to do so, subject to the following conditions: |
hlipka | 4:aa08e82834dc | 11 | * |
hlipka | 4:aa08e82834dc | 12 | * The above copyright notice and this permission notice shall be included in |
hlipka | 4:aa08e82834dc | 13 | * all copies or substantial portions of the Software. |
hlipka | 4:aa08e82834dc | 14 | * |
hlipka | 4:aa08e82834dc | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
hlipka | 4:aa08e82834dc | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
hlipka | 4:aa08e82834dc | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
hlipka | 4:aa08e82834dc | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
hlipka | 4:aa08e82834dc | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
hlipka | 4:aa08e82834dc | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
hlipka | 4:aa08e82834dc | 21 | * THE SOFTWARE. |
hlipka | 4:aa08e82834dc | 22 | */ |
hlipka | 4:aa08e82834dc | 23 | |
hlipka | 4:aa08e82834dc | 24 | #include "textlcdadapter.h" |
hlipka | 4:aa08e82834dc | 25 | #include <stdarg.h> |
hlipka | 4:aa08e82834dc | 26 | |
hlipka | 4:aa08e82834dc | 27 | |
charly | 10:d40c70908bf0 | 28 | TextLCDAdapter::TextLCDAdapter(TextLCD_Base *lcd) { |
hlipka | 4:aa08e82834dc | 29 | _lcd=lcd; |
charly | 12:393329d0e050 | 30 | _columns = _lcd->columns(); |
charly | 12:393329d0e050 | 31 | _rows = _lcd->rows(); |
hlipka | 4:aa08e82834dc | 32 | } |
hlipka | 4:aa08e82834dc | 33 | void TextLCDAdapter::clear() { |
hlipka | 4:aa08e82834dc | 34 | _lcd->cls(); |
hlipka | 4:aa08e82834dc | 35 | } |
hlipka | 4:aa08e82834dc | 36 | |
charly | 10:d40c70908bf0 | 37 | void TextLCDAdapter::writeText(const unsigned int column, const unsigned int row, const char text[]){ |
charly | 12:393329d0e050 | 38 | if ((column > getColumns()) || (row > getRows())){ |
charly | 12:393329d0e050 | 39 | return; |
charly | 12:393329d0e050 | 40 | } |
charly | 10:d40c70908bf0 | 41 | _lcd->locate(column,row); |
charly | 10:d40c70908bf0 | 42 | int i=0; |
charly | 12:393329d0e050 | 43 | while((text[i]!=0) && (column+i < getColumns())) |
charly | 10:d40c70908bf0 | 44 | { |
charly | 10:d40c70908bf0 | 45 | _lcd->putc(text[i]); |
charly | 10:d40c70908bf0 | 46 | i++; |
charly | 10:d40c70908bf0 | 47 | } |
charly | 10:d40c70908bf0 | 48 | } |
charly | 10:d40c70908bf0 | 49 | |
hlipka | 4:aa08e82834dc | 50 | void TextLCDAdapter::character(int column, int row, int c) { |
charly | 12:393329d0e050 | 51 | if ((column > getColumns()) || (row > getRows())){ |
charly | 12:393329d0e050 | 52 | return; |
charly | 12:393329d0e050 | 53 | } |
charly | 10:d40c70908bf0 | 54 | _lcd->locate(column,row); |
charly | 10:d40c70908bf0 | 55 | _lcd->putc(c); |
hlipka | 4:aa08e82834dc | 56 | } |
hlipka | 4:aa08e82834dc | 57 | |
hlipka | 4:aa08e82834dc | 58 | int TextLCDAdapter::putc(int c) { |
hlipka | 4:aa08e82834dc | 59 | return _lcd->putc(c); |
hlipka | 4:aa08e82834dc | 60 | } |
hlipka | 4:aa08e82834dc | 61 | int TextLCDAdapter::printf(const char* format, ...) { |
hlipka | 4:aa08e82834dc | 62 | // create and start the va_list |
hlipka | 4:aa08e82834dc | 63 | va_list listPointer ; |
hlipka | 4:aa08e82834dc | 64 | va_start( listPointer, format ) ; |
hlipka | 4:aa08e82834dc | 65 | |
hlipka | 4:aa08e82834dc | 66 | // vsprintf is an example of |
hlipka | 4:aa08e82834dc | 67 | // a function that works with |
hlipka | 4:aa08e82834dc | 68 | // an "already started" va_list |
hlipka | 4:aa08e82834dc | 69 | static char buf[ 1024 ] ; |
hlipka | 4:aa08e82834dc | 70 | vsprintf( buf, format, listPointer ) ; |
hlipka | 4:aa08e82834dc | 71 | |
hlipka | 4:aa08e82834dc | 72 | return _lcd->printf(buf); |
hlipka | 4:aa08e82834dc | 73 | } |