Damien GORISSE
/
MiniProjet_DG
Description dans le rapport.
LED_Bar.h@0:34945468db9f, 2017-04-02 (annotated)
- Committer:
- Damien75
- Date:
- Sun Apr 02 09:48:30 2017 +0000
- Revision:
- 0:34945468db9f
Projet C++ embarqu? MBED; Damien et Nicolas
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Damien75 | 0:34945468db9f | 1 | /* |
Damien75 | 0:34945468db9f | 2 | LED bar library V1.0 |
Damien75 | 0:34945468db9f | 3 | 2010 Copyright (c) Seeed Technology Inc. All right reserved. |
Damien75 | 0:34945468db9f | 4 | |
Damien75 | 0:34945468db9f | 5 | Original Author: LG |
Damien75 | 0:34945468db9f | 6 | Modify: Loovee, 2014-2-26 |
Damien75 | 0:34945468db9f | 7 | User can choose which Io to be used. |
Damien75 | 0:34945468db9f | 8 | |
Damien75 | 0:34945468db9f | 9 | This library is free software; you can redistribute it and/or |
Damien75 | 0:34945468db9f | 10 | modify it under the terms of the GNU Lesser General Public |
Damien75 | 0:34945468db9f | 11 | License as published by the Free Software Foundation; either |
Damien75 | 0:34945468db9f | 12 | version 2.1 of the License, or (at your option) any later version. |
Damien75 | 0:34945468db9f | 13 | |
Damien75 | 0:34945468db9f | 14 | This library is distributed in the hope that it will be useful, |
Damien75 | 0:34945468db9f | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
Damien75 | 0:34945468db9f | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
Damien75 | 0:34945468db9f | 17 | Lesser General Public License for more details. |
Damien75 | 0:34945468db9f | 18 | |
Damien75 | 0:34945468db9f | 19 | You should have received a copy of the GNU Lesser General Public |
Damien75 | 0:34945468db9f | 20 | License along with this library; if not, write to the Free Software |
Damien75 | 0:34945468db9f | 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Damien75 | 0:34945468db9f | 22 | */ |
Damien75 | 0:34945468db9f | 23 | |
Damien75 | 0:34945468db9f | 24 | #include "mbed.h" |
Damien75 | 0:34945468db9f | 25 | |
Damien75 | 0:34945468db9f | 26 | #ifndef LED_Bar_H |
Damien75 | 0:34945468db9f | 27 | #define LED_Bar_H |
Damien75 | 0:34945468db9f | 28 | |
Damien75 | 0:34945468db9f | 29 | #define CMDMODE 0x0000 // Work on 8-bit mode |
Damien75 | 0:34945468db9f | 30 | #define ON 0x00ff // 8-bit 1 data |
Damien75 | 0:34945468db9f | 31 | #define SHUT 0x0000 // 8-bit 0 data |
Damien75 | 0:34945468db9f | 32 | |
Damien75 | 0:34945468db9f | 33 | /** |
Damien75 | 0:34945468db9f | 34 | * The LED_Bar interface |
Damien75 | 0:34945468db9f | 35 | */ |
Damien75 | 0:34945468db9f | 36 | class LED_Bar |
Damien75 | 0:34945468db9f | 37 | { |
Damien75 | 0:34945468db9f | 38 | |
Damien75 | 0:34945468db9f | 39 | public: |
Damien75 | 0:34945468db9f | 40 | LED_Bar(PinName pinClk, PinName pinDta); |
Damien75 | 0:34945468db9f | 41 | |
Damien75 | 0:34945468db9f | 42 | /** |
Damien75 | 0:34945468db9f | 43 | * Set led single bit, a bit contrl a led |
Damien75 | 0:34945468db9f | 44 | * @param index_bits which bit. if 0x05, then led 0 and led 3 will on, the others will off |
Damien75 | 0:34945468db9f | 45 | */ |
Damien75 | 0:34945468db9f | 46 | void ledIndexBit(unsigned int index_bits); |
Damien75 | 0:34945468db9f | 47 | |
Damien75 | 0:34945468db9f | 48 | /** |
Damien75 | 0:34945468db9f | 49 | * Set level, frm 0 to 10. |
Damien75 | 0:34945468db9f | 50 | * @param level Level 0 means all leds off while level 5 means 5led on and the other will off |
Damien75 | 0:34945468db9f | 51 | */ |
Damien75 | 0:34945468db9f | 52 | void setLevel(int level); |
Damien75 | 0:34945468db9f | 53 | |
Damien75 | 0:34945468db9f | 54 | /** |
Damien75 | 0:34945468db9f | 55 | * Control a single led |
Damien75 | 0:34945468db9f | 56 | * @param num which led |
Damien75 | 0:34945468db9f | 57 | * @param st 1: on 0: off |
Damien75 | 0:34945468db9f | 58 | */ |
Damien75 | 0:34945468db9f | 59 | void setSingleLed(int num, int st); |
Damien75 | 0:34945468db9f | 60 | |
Damien75 | 0:34945468db9f | 61 | private: |
Damien75 | 0:34945468db9f | 62 | /** |
Damien75 | 0:34945468db9f | 63 | * Pin for clock |
Damien75 | 0:34945468db9f | 64 | */ |
Damien75 | 0:34945468db9f | 65 | DigitalOut __pinClk; |
Damien75 | 0:34945468db9f | 66 | |
Damien75 | 0:34945468db9f | 67 | /** |
Damien75 | 0:34945468db9f | 68 | * Pin for data |
Damien75 | 0:34945468db9f | 69 | */ |
Damien75 | 0:34945468db9f | 70 | DigitalOut __pinDta; |
Damien75 | 0:34945468db9f | 71 | |
Damien75 | 0:34945468db9f | 72 | /** |
Damien75 | 0:34945468db9f | 73 | * LED State |
Damien75 | 0:34945468db9f | 74 | */ |
Damien75 | 0:34945468db9f | 75 | unsigned int __led_state; |
Damien75 | 0:34945468db9f | 76 | |
Damien75 | 0:34945468db9f | 77 | void send16bitData(unsigned int data); |
Damien75 | 0:34945468db9f | 78 | void latchData(void); |
Damien75 | 0:34945468db9f | 79 | |
Damien75 | 0:34945468db9f | 80 | }; |
Damien75 | 0:34945468db9f | 81 | |
Damien75 | 0:34945468db9f | 82 | #endif |