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.
window.cpp@9:2fe93daa2106, 2011-02-22 (annotated)
- Committer:
- hlipka
- Date:
- Tue Feb 22 22:57:44 2011 +0000
- Revision:
- 9:2fe93daa2106
- Parent:
- 3:e5d5e2fe4bf6
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 | 2:5ac5bab7daaf | 1 | /* |
hlipka | 2:5ac5bab7daaf | 2 | * mbed LCDWindow library |
hlipka | 2:5ac5bab7daaf | 3 | * Copyright (c) 2010 Hendrik Lipka |
hlipka | 2:5ac5bab7daaf | 4 | * |
hlipka | 2:5ac5bab7daaf | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
hlipka | 2:5ac5bab7daaf | 6 | * of this software and associated documentation files (the "Software"), to deal |
hlipka | 2:5ac5bab7daaf | 7 | * in the Software without restriction, including without limitation the rights |
hlipka | 2:5ac5bab7daaf | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
hlipka | 2:5ac5bab7daaf | 9 | * copies of the Software, and to permit persons to whom the Software is |
hlipka | 2:5ac5bab7daaf | 10 | * furnished to do so, subject to the following conditions: |
hlipka | 2:5ac5bab7daaf | 11 | * |
hlipka | 2:5ac5bab7daaf | 12 | * The above copyright notice and this permission notice shall be included in |
hlipka | 2:5ac5bab7daaf | 13 | * all copies or substantial portions of the Software. |
hlipka | 2:5ac5bab7daaf | 14 | * |
hlipka | 2:5ac5bab7daaf | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
hlipka | 2:5ac5bab7daaf | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
hlipka | 2:5ac5bab7daaf | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
hlipka | 2:5ac5bab7daaf | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
hlipka | 2:5ac5bab7daaf | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
hlipka | 2:5ac5bab7daaf | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
hlipka | 2:5ac5bab7daaf | 21 | * THE SOFTWARE. |
hlipka | 2:5ac5bab7daaf | 22 | */ |
hlipka | 2:5ac5bab7daaf | 23 | |
hlipka | 2:5ac5bab7daaf | 24 | #include "window.h" |
hlipka | 2:5ac5bab7daaf | 25 | |
hlipka | 2:5ac5bab7daaf | 26 | void Window::locate(int column, int row) { |
hlipka | 2:5ac5bab7daaf | 27 | _column = column; |
hlipka | 2:5ac5bab7daaf | 28 | _row = row; |
hlipka | 2:5ac5bab7daaf | 29 | } |
hlipka | 2:5ac5bab7daaf | 30 | |
hlipka | 2:5ac5bab7daaf | 31 | int Window::_putc(int value) { |
hlipka | 2:5ac5bab7daaf | 32 | if (value == '\n') { |
hlipka | 2:5ac5bab7daaf | 33 | _column = 0; |
hlipka | 2:5ac5bab7daaf | 34 | _row++; |
hlipka | 2:5ac5bab7daaf | 35 | if (_row >= getRows()) { |
hlipka | 2:5ac5bab7daaf | 36 | _row = 0; |
hlipka | 2:5ac5bab7daaf | 37 | } |
hlipka | 2:5ac5bab7daaf | 38 | } else { |
hlipka | 2:5ac5bab7daaf | 39 | character(_column, _row, value); |
hlipka | 2:5ac5bab7daaf | 40 | _column++; |
hlipka | 2:5ac5bab7daaf | 41 | if (_column >= getColumns()) { |
hlipka | 2:5ac5bab7daaf | 42 | _column = 0; |
hlipka | 2:5ac5bab7daaf | 43 | _row++; |
hlipka | 2:5ac5bab7daaf | 44 | if (_row >= getRows()) { |
hlipka | 2:5ac5bab7daaf | 45 | _row = 0; |
hlipka | 2:5ac5bab7daaf | 46 | } |
hlipka | 2:5ac5bab7daaf | 47 | } |
hlipka | 2:5ac5bab7daaf | 48 | } |
hlipka | 2:5ac5bab7daaf | 49 | return value; |
hlipka | 3:e5d5e2fe4bf6 | 50 | } |
hlipka | 3:e5d5e2fe4bf6 | 51 | |
hlipka | 3:e5d5e2fe4bf6 | 52 | Window::Window() |
hlipka | 3:e5d5e2fe4bf6 | 53 | { |
hlipka | 3:e5d5e2fe4bf6 | 54 | _guard=new Semaphore(); |
hlipka | 2:5ac5bab7daaf | 55 | } |