Karl Zweimüller / LcdWindow

Fork of LcdWindow by Hendrik Lipka

Committer:
charly
Date:
Mon Jan 04 20:22:17 2016 +0000
Revision:
10:d40c70908bf0
Parent:
4:aa08e82834dc
Child:
12:393329d0e050
Adapted for EnhancedLCD. Disabled semaphore as there are problem with new mbed-library.

Who changed what in which revision?

UserRevisionLine numberNew 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;
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
charly 10:d40c70908bf0 35 void TextLCDAdapter::writeText(const unsigned int column, const unsigned int row, const char text[]){
charly 10:d40c70908bf0 36 _lcd->locate(column,row);
charly 10:d40c70908bf0 37 int i=0;
charly 10:d40c70908bf0 38 while(text[i]!=0)
charly 10:d40c70908bf0 39 {
charly 10:d40c70908bf0 40 _lcd->putc(text[i]);
charly 10:d40c70908bf0 41 i++;
charly 10:d40c70908bf0 42 }
charly 10:d40c70908bf0 43 }
charly 10:d40c70908bf0 44
hlipka 4:aa08e82834dc 45 int TextLCDAdapter::getRows() {
hlipka 4:aa08e82834dc 46 return _lcd->rows();
hlipka 4:aa08e82834dc 47 }
hlipka 4:aa08e82834dc 48 int TextLCDAdapter::getColumns() {
hlipka 4:aa08e82834dc 49 return _lcd->columns();
hlipka 4:aa08e82834dc 50 }
hlipka 4:aa08e82834dc 51 void TextLCDAdapter::character(int column, int row, int c) {
charly 10:d40c70908bf0 52 _lcd->locate(column,row);
charly 10:d40c70908bf0 53 _lcd->putc(c);
hlipka 4:aa08e82834dc 54 }
hlipka 4:aa08e82834dc 55
hlipka 4:aa08e82834dc 56 int TextLCDAdapter::putc(int c) {
hlipka 4:aa08e82834dc 57 return _lcd->putc(c);
hlipka 4:aa08e82834dc 58 }
hlipka 4:aa08e82834dc 59 int TextLCDAdapter::printf(const char* format, ...) {
hlipka 4:aa08e82834dc 60 // create and start the va_list
hlipka 4:aa08e82834dc 61 va_list listPointer ;
hlipka 4:aa08e82834dc 62 va_start( listPointer, format ) ;
hlipka 4:aa08e82834dc 63
hlipka 4:aa08e82834dc 64 // vsprintf is an example of
hlipka 4:aa08e82834dc 65 // a function that works with
hlipka 4:aa08e82834dc 66 // an "already started" va_list
hlipka 4:aa08e82834dc 67 static char buf[ 1024 ] ;
hlipka 4:aa08e82834dc 68 vsprintf( buf, format, listPointer ) ;
hlipka 4:aa08e82834dc 69
hlipka 4:aa08e82834dc 70 return _lcd->printf(buf);
hlipka 4:aa08e82834dc 71 }