Programme d'une sonde de température DHT 11 associée à de la sauvegarde de données sur clé USB et à l'affichage de ces données sur afficheur LCD

Dependencies:   FatFileSystemCpp mbed

Committer:
Fanta025
Date:
Tue Jun 02 14:19:54 2015 +0000
Revision:
0:ed0b4e66d2ad
Programme d'une sonde de temp?rature DHT 11 associ?e ? de la sauvegarde de donn?es sur USB et un affichage sur ?cran LCD

Who changed what in which revision?

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