ELEC 351 environmental sensor / Mbed 2 deprecated give_to_pete

Dependencies:   mbed BMP280 ELEC350-Practicals-FZ429_2

Committer:
ChrisHayes
Date:
Fri Nov 16 13:19:35 2018 +0000
Revision:
0:d01bf1d73c6e
first_code_most_of_task_1

Who changed what in which revision?

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