stepper mottor for pumps

Dependencies:   mbed

Committer:
ekasinambela
Date:
Sun Jun 19 21:32:08 2016 +0000
Revision:
1:8431b042a2eb
modify stepper motor

Who changed what in which revision?

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