Display text on LCD displays (even on multiple ones). Allow to create windows (frames) on display, and to combine them (split, add, duplicate, scroll). See http://mbed.org/users/hlipka/notebook/lcdwindow/ for more information.
textlcdadapter.cpp@9:2fe93daa2106, 2011-02-22 (annotated)
- Committer:
- hlipka
- Date:
- Tue Feb 22 22:57:44 2011 +0000
- Revision:
- 9:2fe93daa2106
- Parent:
- 4:aa08e82834dc
fixed semaphore handling - should now be really thread safe (can be called from interrupts)
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 | |
hlipka | 4:aa08e82834dc | 28 | TextLCDAdapter::TextLCDAdapter(TextLCD *lcd) { |
hlipka | 4:aa08e82834dc | 29 | _lcd=lcd; |
hlipka | 4:aa08e82834dc | 30 | } |
hlipka | 4:aa08e82834dc | 31 | void TextLCDAdapter::clear() { |
hlipka | 4:aa08e82834dc | 32 | _lcd->cls(); |
hlipka | 4:aa08e82834dc | 33 | } |
hlipka | 4:aa08e82834dc | 34 | |
hlipka | 4:aa08e82834dc | 35 | int TextLCDAdapter::getRows() { |
hlipka | 4:aa08e82834dc | 36 | return _lcd->rows(); |
hlipka | 4:aa08e82834dc | 37 | } |
hlipka | 4:aa08e82834dc | 38 | int TextLCDAdapter::getColumns() { |
hlipka | 4:aa08e82834dc | 39 | return _lcd->columns(); |
hlipka | 4:aa08e82834dc | 40 | } |
hlipka | 4:aa08e82834dc | 41 | void TextLCDAdapter::character(int column, int row, int c) { |
hlipka | 4:aa08e82834dc | 42 | } |
hlipka | 4:aa08e82834dc | 43 | |
hlipka | 4:aa08e82834dc | 44 | int TextLCDAdapter::putc(int c) { |
hlipka | 4:aa08e82834dc | 45 | return _lcd->putc(c); |
hlipka | 4:aa08e82834dc | 46 | } |
hlipka | 4:aa08e82834dc | 47 | int TextLCDAdapter::printf(const char* format, ...) { |
hlipka | 4:aa08e82834dc | 48 | // create and start the va_list |
hlipka | 4:aa08e82834dc | 49 | va_list listPointer ; |
hlipka | 4:aa08e82834dc | 50 | va_start( listPointer, format ) ; |
hlipka | 4:aa08e82834dc | 51 | |
hlipka | 4:aa08e82834dc | 52 | // vsprintf is an example of |
hlipka | 4:aa08e82834dc | 53 | // a function that works with |
hlipka | 4:aa08e82834dc | 54 | // an "already started" va_list |
hlipka | 4:aa08e82834dc | 55 | static char buf[ 1024 ] ; |
hlipka | 4:aa08e82834dc | 56 | vsprintf( buf, format, listPointer ) ; |
hlipka | 4:aa08e82834dc | 57 | |
hlipka | 4:aa08e82834dc | 58 | return _lcd->printf(buf); |
hlipka | 4:aa08e82834dc | 59 | } |