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