Yoshihiko Nagoya / Mbed 2 deprecated q9_poker

Dependencies:   mbed

Committer:
Ayokura
Date:
Sun Nov 21 15:06:11 2010 +0000
Revision:
0:234f286e40c7
q9_poker

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ayokura 0:234f286e40c7 1 /* mbed TextLCD Library, for a 4-bit LCD based on HD44780
Ayokura 0:234f286e40c7 2 * Copyright (c) 2007-2010, sford
Ayokura 0:234f286e40c7 3 *
Ayokura 0:234f286e40c7 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
Ayokura 0:234f286e40c7 5 * of this software and associated documentation files (the "Software"), to deal
Ayokura 0:234f286e40c7 6 * in the Software without restriction, including without limitation the rights
Ayokura 0:234f286e40c7 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Ayokura 0:234f286e40c7 8 * copies of the Software, and to permit persons to whom the Software is
Ayokura 0:234f286e40c7 9 * furnished to do so, subject to the following conditions:
Ayokura 0:234f286e40c7 10 *
Ayokura 0:234f286e40c7 11 * The above copyright notice and this permission notice shall be included in
Ayokura 0:234f286e40c7 12 * all copies or substantial portions of the Software.
Ayokura 0:234f286e40c7 13 *
Ayokura 0:234f286e40c7 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Ayokura 0:234f286e40c7 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Ayokura 0:234f286e40c7 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Ayokura 0:234f286e40c7 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Ayokura 0:234f286e40c7 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Ayokura 0:234f286e40c7 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Ayokura 0:234f286e40c7 20 * THE SOFTWARE.
Ayokura 0:234f286e40c7 21 */
Ayokura 0:234f286e40c7 22
Ayokura 0:234f286e40c7 23 #ifndef MBED_TEXTLCD_H
Ayokura 0:234f286e40c7 24 #define MBED_TEXTLCD_H
Ayokura 0:234f286e40c7 25
Ayokura 0:234f286e40c7 26 #include "mbed.h"
Ayokura 0:234f286e40c7 27
Ayokura 0:234f286e40c7 28 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
Ayokura 0:234f286e40c7 29 *
Ayokura 0:234f286e40c7 30 * Currently supports 16x2, 20x2 and 20x4 panels
Ayokura 0:234f286e40c7 31 *
Ayokura 0:234f286e40c7 32 * @code
Ayokura 0:234f286e40c7 33 * #include "mbed.h"
Ayokura 0:234f286e40c7 34 * #include "TextLCD.h"
Ayokura 0:234f286e40c7 35 *
Ayokura 0:234f286e40c7 36 * TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d0-d3
Ayokura 0:234f286e40c7 37 *
Ayokura 0:234f286e40c7 38 * int main() {
Ayokura 0:234f286e40c7 39 * lcd.printf("Hello World!\n");
Ayokura 0:234f286e40c7 40 * }
Ayokura 0:234f286e40c7 41 * @endcode
Ayokura 0:234f286e40c7 42 */
Ayokura 0:234f286e40c7 43 class TextLCD : public Stream {
Ayokura 0:234f286e40c7 44 public:
Ayokura 0:234f286e40c7 45
Ayokura 0:234f286e40c7 46 /** LCD panel format */
Ayokura 0:234f286e40c7 47 enum LCDType {
Ayokura 0:234f286e40c7 48 LCD16x2 /**< 16x2 LCD panel (default) */
Ayokura 0:234f286e40c7 49 , LCD16x2B /**< 16x2 LCD panel alternate addressing */
Ayokura 0:234f286e40c7 50 , LCD20x2 /**< 20x2 LCD panel */
Ayokura 0:234f286e40c7 51 , LCD20x4 /**< 20x4 LCD panel */
Ayokura 0:234f286e40c7 52 };
Ayokura 0:234f286e40c7 53
Ayokura 0:234f286e40c7 54 /** Create a TextLCD interface
Ayokura 0:234f286e40c7 55 *
Ayokura 0:234f286e40c7 56 * @param rs Instruction/data control line
Ayokura 0:234f286e40c7 57 * @param e Enable line (clock)
Ayokura 0:234f286e40c7 58 * @param d0-d3 Data lines
Ayokura 0:234f286e40c7 59 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Ayokura 0:234f286e40c7 60 */
Ayokura 0:234f286e40c7 61 TextLCD(PinName rs, PinName e, PinName d0, PinName d1, PinName d2, PinName d3, LCDType type = LCD16x2);
Ayokura 0:234f286e40c7 62
Ayokura 0:234f286e40c7 63 #if DOXYGEN_ONLY
Ayokura 0:234f286e40c7 64 /** Write a character to the LCD
Ayokura 0:234f286e40c7 65 *
Ayokura 0:234f286e40c7 66 * @param c The character to write to the display
Ayokura 0:234f286e40c7 67 */
Ayokura 0:234f286e40c7 68 int putc(int c);
Ayokura 0:234f286e40c7 69
Ayokura 0:234f286e40c7 70 /** Write a formated string to the LCD
Ayokura 0:234f286e40c7 71 *
Ayokura 0:234f286e40c7 72 * @param format A printf-style format string, followed by the
Ayokura 0:234f286e40c7 73 * variables to use in formating the string.
Ayokura 0:234f286e40c7 74 */
Ayokura 0:234f286e40c7 75 int printf(const char* format, ...);
Ayokura 0:234f286e40c7 76 #endif
Ayokura 0:234f286e40c7 77
Ayokura 0:234f286e40c7 78 /** Locate to a screen column and row
Ayokura 0:234f286e40c7 79 *
Ayokura 0:234f286e40c7 80 * @param column The horizontal position from the left, indexed from 0
Ayokura 0:234f286e40c7 81 * @param row The vertical position from the top, indexed from 0
Ayokura 0:234f286e40c7 82 */
Ayokura 0:234f286e40c7 83 void locate(int column, int row);
Ayokura 0:234f286e40c7 84
Ayokura 0:234f286e40c7 85 /** Clear the screen and locate to 0,0 */
Ayokura 0:234f286e40c7 86 void cls();
Ayokura 0:234f286e40c7 87
Ayokura 0:234f286e40c7 88 int rows();
Ayokura 0:234f286e40c7 89 int columns();
Ayokura 0:234f286e40c7 90
Ayokura 0:234f286e40c7 91 protected:
Ayokura 0:234f286e40c7 92
Ayokura 0:234f286e40c7 93 // Stream implementation functions
Ayokura 0:234f286e40c7 94 virtual int _putc(int value);
Ayokura 0:234f286e40c7 95 virtual int _getc();
Ayokura 0:234f286e40c7 96
Ayokura 0:234f286e40c7 97 int address(int column, int row);
Ayokura 0:234f286e40c7 98 void character(int column, int row, int c);
Ayokura 0:234f286e40c7 99 void writeByte(int value);
Ayokura 0:234f286e40c7 100 void writeCommand(int command);
Ayokura 0:234f286e40c7 101 void writeData(int data);
Ayokura 0:234f286e40c7 102
Ayokura 0:234f286e40c7 103 DigitalOut _rs, _e;
Ayokura 0:234f286e40c7 104 BusOut _d;
Ayokura 0:234f286e40c7 105 LCDType _type;
Ayokura 0:234f286e40c7 106
Ayokura 0:234f286e40c7 107 int _column;
Ayokura 0:234f286e40c7 108 int _row;
Ayokura 0:234f286e40c7 109 };
Ayokura 0:234f286e40c7 110
Ayokura 0:234f286e40c7 111 #endif