fork of original freetronics library
Fork of Freetronics_16x2_LCD by
freetronicsLCDShield.h@1:ddcefddda4a7, 2013-10-27 (annotated)
- Committer:
- KKempeneers
- Date:
- Sun Oct 27 07:07:53 2013 +0000
- Revision:
- 1:ddcefddda4a7
- Parent:
- 0:01f3d38f8b6d
- Child:
- 2:f40a5df43d09
A basic library for the Freetronics arduino LCD shield. The library is primarily targeted for the KL25Z mbed enabled microcontrollers, that is all hardware definitions default to the ports that correspond to the LCD shield 's arduino footprint.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
KKempeneers | 1:ddcefddda4a7 | 1 | /* mbed freetronicsLCDShield Library, written by Koen J.F. Kempeneers |
KKempeneers | 1:ddcefddda4a7 | 2 | * koen.kempeneers@damiaaninstituut.be |
KKempeneers | 1:ddcefddda4a7 | 3 | * |
KKempeneers | 1:ddcefddda4a7 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
KKempeneers | 1:ddcefddda4a7 | 5 | * of this software and associated documentation files (the "Software"), to deal |
KKempeneers | 1:ddcefddda4a7 | 6 | * in the Software without restriction, including without limitation the rights |
KKempeneers | 1:ddcefddda4a7 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
KKempeneers | 1:ddcefddda4a7 | 8 | * copies of the Software, and to permit persons to whom the Software is |
KKempeneers | 1:ddcefddda4a7 | 9 | * furnished to do so, subject to the following conditions: |
KKempeneers | 1:ddcefddda4a7 | 10 | * |
KKempeneers | 1:ddcefddda4a7 | 11 | * The above copyright notice and this permission notice shall be included in |
KKempeneers | 1:ddcefddda4a7 | 12 | * all copies or substantial portions of the Software. |
KKempeneers | 1:ddcefddda4a7 | 13 | * |
KKempeneers | 1:ddcefddda4a7 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
KKempeneers | 1:ddcefddda4a7 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
KKempeneers | 1:ddcefddda4a7 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
KKempeneers | 1:ddcefddda4a7 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
KKempeneers | 1:ddcefddda4a7 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
KKempeneers | 1:ddcefddda4a7 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
KKempeneers | 1:ddcefddda4a7 | 20 | * THE SOFTWARE. |
KKempeneers | 1:ddcefddda4a7 | 21 | */ |
KKempeneers | 1:ddcefddda4a7 | 22 | |
KKempeneers | 1:ddcefddda4a7 | 23 | #ifndef FREETRONICSLCDSHIELD_H |
KKempeneers | 1:ddcefddda4a7 | 24 | #define FREETRONICSLCDSHIELD_H |
KKempeneers | 1:ddcefddda4a7 | 25 | |
KKempeneers | 0:01f3d38f8b6d | 26 | #define LEFT 0 |
KKempeneers | 0:01f3d38f8b6d | 27 | #define RIGHT 1 |
KKempeneers | 0:01f3d38f8b6d | 28 | |
KKempeneers | 0:01f3d38f8b6d | 29 | class freetronicsLCDShield : public Stream { |
KKempeneers | 0:01f3d38f8b6d | 30 | private: |
KKempeneers | 0:01f3d38f8b6d | 31 | // Functions |
KKempeneers | 0:01f3d38f8b6d | 32 | void writeByte (int byte); |
KKempeneers | 0:01f3d38f8b6d | 33 | void writeCommand (int command); |
KKempeneers | 0:01f3d38f8b6d | 34 | void writeData (int data); |
KKempeneers | 0:01f3d38f8b6d | 35 | void character(int line, int col, int value); |
KKempeneers | 0:01f3d38f8b6d | 36 | |
KKempeneers | 0:01f3d38f8b6d | 37 | // Hardware |
KKempeneers | 0:01f3d38f8b6d | 38 | DigitalOut _rs, _e; |
KKempeneers | 0:01f3d38f8b6d | 39 | BusOut _d; |
KKempeneers | 0:01f3d38f8b6d | 40 | PwmOut _bl; |
KKempeneers | 0:01f3d38f8b6d | 41 | AnalogIn _a0; |
KKempeneers | 0:01f3d38f8b6d | 42 | |
KKempeneers | 0:01f3d38f8b6d | 43 | public: |
KKempeneers | 0:01f3d38f8b6d | 44 | // Constructor |
KKempeneers | 0:01f3d38f8b6d | 45 | freetronicsLCDShield (PinName rs = PTA13, |
KKempeneers | 0:01f3d38f8b6d | 46 | PinName e = PTD5, |
KKempeneers | 0:01f3d38f8b6d | 47 | PinName d0 = PTA4, |
KKempeneers | 0:01f3d38f8b6d | 48 | PinName d1 = PTA5, |
KKempeneers | 0:01f3d38f8b6d | 49 | PinName d2 = PTC8, |
KKempeneers | 0:01f3d38f8b6d | 50 | PinName d3 = PTC9, |
KKempeneers | 0:01f3d38f8b6d | 51 | PinName bl = PTA12, |
KKempeneers | 0:01f3d38f8b6d | 52 | PinName a0 = PTB0); |
KKempeneers | 0:01f3d38f8b6d | 53 | |
KKempeneers | 1:ddcefddda4a7 | 54 | void writeCGRAM (char address, const char *ptr, char nbytes); |
KKempeneers | 0:01f3d38f8b6d | 55 | void setCursorPosition (int line, int col); |
KKempeneers | 0:01f3d38f8b6d | 56 | void setBackLight (bool blStatus); |
KKempeneers | 0:01f3d38f8b6d | 57 | void setBackLight (float blIntensity); |
KKempeneers | 1:ddcefddda4a7 | 58 | void setCursor (bool cStatus = true, bool blink = false); |
KKempeneers | 1:ddcefddda4a7 | 59 | void shiftLeft (void); |
KKempeneers | 1:ddcefddda4a7 | 60 | void shiftRight (void); |
KKempeneers | 1:ddcefddda4a7 | 61 | void shift (bool direction); |
KKempeneers | 0:01f3d38f8b6d | 62 | void cls (void); |
KKempeneers | 0:01f3d38f8b6d | 63 | void home(void); |
KKempeneers | 0:01f3d38f8b6d | 64 | |
KKempeneers | 0:01f3d38f8b6d | 65 | float readButton(void); |
KKempeneers | 0:01f3d38f8b6d | 66 | |
KKempeneers | 0:01f3d38f8b6d | 67 | protected: |
KKempeneers | 0:01f3d38f8b6d | 68 | // Stream implementation functions |
KKempeneers | 0:01f3d38f8b6d | 69 | virtual int _putc(int value); |
KKempeneers | 0:01f3d38f8b6d | 70 | virtual int _getc(); |
KKempeneers | 1:ddcefddda4a7 | 71 | }; |
KKempeneers | 1:ddcefddda4a7 | 72 | |
KKempeneers | 1:ddcefddda4a7 | 73 | #endif |