Futaba S-BUS Library. Let you control 16 servos and 2 digital channels

Dependencies:   mbed

Committer:
Digixx
Date:
Wed Mar 07 18:18:43 2012 +0000
Revision:
0:83e415034198

        

Who changed what in which revision?

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