128x64 grafical display with KS0107B and KS0108B controller
Display.h@3:6c18ab81111c, 2010-09-07 (annotated)
- Committer:
- hornfeldt
- Date:
- Tue Sep 07 07:17:53 2010 +0000
- Revision:
- 3:6c18ab81111c
- Parent:
- 1:1d06bc155ef3
Licensed as MIT
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hornfeldt | 3:6c18ab81111c | 1 | /* |
hornfeldt | 3:6c18ab81111c | 2 | Copyright (c) 2010 Anders Hörnfeldt |
hornfeldt | 3:6c18ab81111c | 3 | |
hornfeldt | 3:6c18ab81111c | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
hornfeldt | 3:6c18ab81111c | 5 | of this software and associated documentation files (the "Software"), to deal |
hornfeldt | 3:6c18ab81111c | 6 | in the Software without restriction, including without limitation the rights |
hornfeldt | 3:6c18ab81111c | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
hornfeldt | 3:6c18ab81111c | 8 | copies of the Software, and to permit persons to whom the Software is |
hornfeldt | 3:6c18ab81111c | 9 | furnished to do so, subject to the following conditions: |
hornfeldt | 3:6c18ab81111c | 10 | |
hornfeldt | 3:6c18ab81111c | 11 | The above copyright notice and this permission notice shall be included in |
hornfeldt | 3:6c18ab81111c | 12 | all copies or substantial portions of the Software. |
hornfeldt | 3:6c18ab81111c | 13 | |
hornfeldt | 3:6c18ab81111c | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
hornfeldt | 3:6c18ab81111c | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
hornfeldt | 3:6c18ab81111c | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
hornfeldt | 3:6c18ab81111c | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
hornfeldt | 3:6c18ab81111c | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
hornfeldt | 3:6c18ab81111c | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
hornfeldt | 3:6c18ab81111c | 20 | THE SOFTWARE. |
hornfeldt | 3:6c18ab81111c | 21 | */ |
hornfeldt | 0:45771b38d50d | 22 | #ifndef DISPLAY_H |
hornfeldt | 0:45771b38d50d | 23 | #define DISPLAY_H |
hornfeldt | 0:45771b38d50d | 24 | |
hornfeldt | 0:45771b38d50d | 25 | #define RS_f = 1 |
hornfeldt | 0:45771b38d50d | 26 | #define RW_f = 2 |
hornfeldt | 0:45771b38d50d | 27 | #define CS1_f = 4 |
hornfeldt | 0:45771b38d50d | 28 | #define CS2_f = 8 |
hornfeldt | 0:45771b38d50d | 29 | |
hornfeldt | 0:45771b38d50d | 30 | #include "mbed.h" |
hornfeldt | 0:45771b38d50d | 31 | #include "font.h" |
hornfeldt | 0:45771b38d50d | 32 | |
hornfeldt | 1:1d06bc155ef3 | 33 | class Display { |
hornfeldt | 0:45771b38d50d | 34 | public: |
hornfeldt | 0:45771b38d50d | 35 | // Constructor: |
hornfeldt | 0:45771b38d50d | 36 | Display (PinName _RS, PinName _RW, PinName _E, PinName _CS1, PinName _CS2, PinName DB0, PinName DB1, PinName DB2, PinName DB3, PinName DB4, PinName DB5, PinName DB6, PinName DB7); |
hornfeldt | 0:45771b38d50d | 37 | // Send write command to Display |
hornfeldt | 0:45771b38d50d | 38 | // Page 0-7, y 0-127 |
hornfeldt | 0:45771b38d50d | 39 | void write (int page, int y, unsigned int data); |
hornfeldt | 0:45771b38d50d | 40 | // |
hornfeldt | 1:1d06bc155ef3 | 41 | void SetAddress(int); |
hornfeldt | 0:45771b38d50d | 42 | int SendCommand(unsigned int, int); |
hornfeldt | 0:45771b38d50d | 43 | // Row 0-7, col 0-122 |
hornfeldt | 1:1d06bc155ef3 | 44 | void writec(int row, int Y, int c); |
hornfeldt | 1:1d06bc155ef3 | 45 | |
hornfeldt | 0:45771b38d50d | 46 | private: |
hornfeldt | 0:45771b38d50d | 47 | BusInOut DB; |
hornfeldt | 0:45771b38d50d | 48 | DigitalOut RS; |
hornfeldt | 0:45771b38d50d | 49 | DigitalOut RW; |
hornfeldt | 0:45771b38d50d | 50 | DigitalOut E; |
hornfeldt | 0:45771b38d50d | 51 | DigitalOut CS1; |
hornfeldt | 0:45771b38d50d | 52 | DigitalOut CS2; |
hornfeldt | 0:45771b38d50d | 53 | int CurCol; |
hornfeldt | 0:45771b38d50d | 54 | }; |
hornfeldt | 0:45771b38d50d | 55 | |
hornfeldt | 1:1d06bc155ef3 | 56 | class DisplayTTY : public Stream { |
hornfeldt | 0:45771b38d50d | 57 | public: |
hornfeldt | 1:1d06bc155ef3 | 58 | DisplayTTY (Display *d, int _row, int _startY, int _numOfChars=10, int _numOfRows=1, int _charOffset=6, int _flags=0); |
hornfeldt | 1:1d06bc155ef3 | 59 | void cls(); |
hornfeldt | 1:1d06bc155ef3 | 60 | protected: |
hornfeldt | 1:1d06bc155ef3 | 61 | virtual int _putc (int c); |
hornfeldt | 1:1d06bc155ef3 | 62 | virtual int _getc(); |
hornfeldt | 1:1d06bc155ef3 | 63 | virtual void newline(); |
hornfeldt | 1:1d06bc155ef3 | 64 | Display *kalle; |
hornfeldt | 0:45771b38d50d | 65 | int row; |
hornfeldt | 0:45771b38d50d | 66 | int startY; |
hornfeldt | 0:45771b38d50d | 67 | int numOfChars; |
hornfeldt | 0:45771b38d50d | 68 | int numOfRows; |
hornfeldt | 0:45771b38d50d | 69 | int charOffset; |
hornfeldt | 0:45771b38d50d | 70 | int flags; |
hornfeldt | 1:1d06bc155ef3 | 71 | int CursPosY; |
hornfeldt | 1:1d06bc155ef3 | 72 | int CursPosW; |
hornfeldt | 0:45771b38d50d | 73 | }; |
hornfeldt | 0:45771b38d50d | 74 | |
hornfeldt | 0:45771b38d50d | 75 | #endif |