エレキジャックweb mbed入門 mbed RMCS鉄道模型自動制御システム 課題1です。完成したmbed RMCSユニットの最初の動作確認です。

Dependencies:   mbed

Committer:
takeuchi
Date:
Thu Jan 19 00:45:29 2012 +0000
Revision:
0:7afb9387d07c

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takeuchi 0:7afb9387d07c 1 /* mbed TextLCD Library
takeuchi 0:7afb9387d07c 2 * Copyright (c) 2007-2009 sford
takeuchi 0:7afb9387d07c 3 * Released under the MIT License: http://mbed.org/license/mit
takeuchi 0:7afb9387d07c 4 */
takeuchi 0:7afb9387d07c 5
takeuchi 0:7afb9387d07c 6 #ifndef MBED_TEXTLCD_H
takeuchi 0:7afb9387d07c 7 #define MBED_TEXTLCD_H
takeuchi 0:7afb9387d07c 8
takeuchi 0:7afb9387d07c 9 #include "Stream.h"
takeuchi 0:7afb9387d07c 10 #include "DigitalOut.h"
takeuchi 0:7afb9387d07c 11 #include "BusOut.h"
takeuchi 0:7afb9387d07c 12
takeuchi 0:7afb9387d07c 13 namespace mbed {
takeuchi 0:7afb9387d07c 14
takeuchi 0:7afb9387d07c 15 /* Class: TextLCD
takeuchi 0:7afb9387d07c 16 * A 16x2 Text LCD controller
takeuchi 0:7afb9387d07c 17 *
takeuchi 0:7afb9387d07c 18 * Allows you to print to a Text LCD screen, and locate/cls. Could be
takeuchi 0:7afb9387d07c 19 * turned in to a more generic libray.
takeuchi 0:7afb9387d07c 20 *
takeuchi 0:7afb9387d07c 21 * If you are connecting multiple displays, you can connect them all in
takeuchi 0:7afb9387d07c 22 * parallel except for the enable (e) pin, which must be unique for each
takeuchi 0:7afb9387d07c 23 * display.
takeuchi 0:7afb9387d07c 24 *
takeuchi 0:7afb9387d07c 25 * Example:
takeuchi 0:7afb9387d07c 26 * > #include "mbed.h"
takeuchi 0:7afb9387d07c 27 * > #include "TextLCD.h"
takeuchi 0:7afb9387d07c 28 * >
takeuchi 0:7afb9387d07c 29 * > TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d0, d1, d2, d3
takeuchi 0:7afb9387d07c 30 * >
takeuchi 0:7afb9387d07c 31 * > int main() {
takeuchi 0:7afb9387d07c 32 * > lcd.printf("Hello World!");
takeuchi 0:7afb9387d07c 33 * > }
takeuchi 0:7afb9387d07c 34 */
takeuchi 0:7afb9387d07c 35 class TextLCD : public Stream {
takeuchi 0:7afb9387d07c 36
takeuchi 0:7afb9387d07c 37 public:
takeuchi 0:7afb9387d07c 38 /* Constructor: TextLCD
takeuchi 0:7afb9387d07c 39 * Create a TextLCD object, connected to the specified pins
takeuchi 0:7afb9387d07c 40 *
takeuchi 0:7afb9387d07c 41 * All signals must be connected to DigitalIn compatible pins.
takeuchi 0:7afb9387d07c 42 *
takeuchi 0:7afb9387d07c 43 * Variables:
takeuchi 0:7afb9387d07c 44 * rs - Used to specify data or command
takeuchi 0:7afb9387d07c 45 * rw - Used to determine read or write
takeuchi 0:7afb9387d07c 46 * e - enable
takeuchi 0:7afb9387d07c 47 * d0..d3 - The data lines
takeuchi 0:7afb9387d07c 48 */
takeuchi 0:7afb9387d07c 49 TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1,
takeuchi 0:7afb9387d07c 50 PinName d2, PinName d3, int columns , int rows );
takeuchi 0:7afb9387d07c 51
takeuchi 0:7afb9387d07c 52 #if 0 // Inhereted from Stream, for documentation only
takeuchi 0:7afb9387d07c 53 /* Function: putc
takeuchi 0:7afb9387d07c 54 * Write a character
takeuchi 0:7afb9387d07c 55 *
takeuchi 0:7afb9387d07c 56 * Variables:
takeuchi 0:7afb9387d07c 57 * c - The character to write to the serial port
takeuchi 0:7afb9387d07c 58 */
takeuchi 0:7afb9387d07c 59 int putc(int c);
takeuchi 0:7afb9387d07c 60
takeuchi 0:7afb9387d07c 61 /* Function: printf
takeuchi 0:7afb9387d07c 62 * Write a formated string
takeuchi 0:7afb9387d07c 63 *
takeuchi 0:7afb9387d07c 64 * Variables:
takeuchi 0:7afb9387d07c 65 * format - A printf-style format string, followed by the
takeuchi 0:7afb9387d07c 66 * variables to use in formating the string.
takeuchi 0:7afb9387d07c 67 */
takeuchi 0:7afb9387d07c 68 int printf(const char* format, ...);
takeuchi 0:7afb9387d07c 69 #endif
takeuchi 0:7afb9387d07c 70
takeuchi 0:7afb9387d07c 71 /* Function: locate
takeuchi 0:7afb9387d07c 72 * Locate to a certian position
takeuchi 0:7afb9387d07c 73 *
takeuchi 0:7afb9387d07c 74 * Variables:
takeuchi 0:7afb9387d07c 75 * column - the column to locate to, from 0..15
takeuchi 0:7afb9387d07c 76 * row - the row to locate to, from 0..1
takeuchi 0:7afb9387d07c 77 */
takeuchi 0:7afb9387d07c 78 virtual void locate(int column, int row);
takeuchi 0:7afb9387d07c 79
takeuchi 0:7afb9387d07c 80 /* Function: cls
takeuchi 0:7afb9387d07c 81 * Clear the screen, and locate to 0,0
takeuchi 0:7afb9387d07c 82 */
takeuchi 0:7afb9387d07c 83 virtual void cls();
takeuchi 0:7afb9387d07c 84
takeuchi 0:7afb9387d07c 85 virtual void reset();
takeuchi 0:7afb9387d07c 86
takeuchi 0:7afb9387d07c 87 protected:
takeuchi 0:7afb9387d07c 88
takeuchi 0:7afb9387d07c 89 void clock();
takeuchi 0:7afb9387d07c 90 void writeData(int data);
takeuchi 0:7afb9387d07c 91 void writeCommand(int command);
takeuchi 0:7afb9387d07c 92 void writeByte(int value);
takeuchi 0:7afb9387d07c 93 void writeNibble(int value);
takeuchi 0:7afb9387d07c 94 virtual int _putc(int c);
takeuchi 0:7afb9387d07c 95 virtual int _getc();
takeuchi 0:7afb9387d07c 96 virtual void newline();
takeuchi 0:7afb9387d07c 97
takeuchi 0:7afb9387d07c 98 int _row;
takeuchi 0:7afb9387d07c 99 int _column;
takeuchi 0:7afb9387d07c 100 DigitalOut _rw, _rs, _e;
takeuchi 0:7afb9387d07c 101 BusOut _d;
takeuchi 0:7afb9387d07c 102 int _columns;
takeuchi 0:7afb9387d07c 103 int _rows;
takeuchi 0:7afb9387d07c 104
takeuchi 0:7afb9387d07c 105 };
takeuchi 0:7afb9387d07c 106
takeuchi 0:7afb9387d07c 107 }
takeuchi 0:7afb9387d07c 108
takeuchi 0:7afb9387d07c 109 #endif