LCD implementation of our project.
Dependencies: mbed mbed-rtos MLX90614
st7565LCD.h@10:97389d774ae1, 2015-06-03 (annotated)
- Committer:
- ovidiup13
- Date:
- Wed Jun 03 17:42:47 2015 +0000
- Revision:
- 10:97389d774ae1
- Parent:
- 0:1e597b0f8b3b
working version, comment out thermo in main;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ovidiup13 | 0:1e597b0f8b3b | 1 | /* |
ovidiup13 | 0:1e597b0f8b3b | 2 | $Id:$ |
ovidiup13 | 0:1e597b0f8b3b | 3 | |
ovidiup13 | 0:1e597b0f8b3b | 4 | ST7565 LCD library! |
ovidiup13 | 0:1e597b0f8b3b | 5 | |
ovidiup13 | 0:1e597b0f8b3b | 6 | Copyright (C) 2010 Limor Fried, Adafruit Industries |
ovidiup13 | 0:1e597b0f8b3b | 7 | |
ovidiup13 | 0:1e597b0f8b3b | 8 | This library is free software; you can redistribute it and/or |
ovidiup13 | 0:1e597b0f8b3b | 9 | modify it under the terms of the GNU Lesser General Public |
ovidiup13 | 0:1e597b0f8b3b | 10 | License as published by the Free Software Foundation; either |
ovidiup13 | 0:1e597b0f8b3b | 11 | version 2.1 of the License, or (at your option) any later version. |
ovidiup13 | 0:1e597b0f8b3b | 12 | |
ovidiup13 | 0:1e597b0f8b3b | 13 | This library is distributed in the hope that it will be useful, |
ovidiup13 | 0:1e597b0f8b3b | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
ovidiup13 | 0:1e597b0f8b3b | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ovidiup13 | 0:1e597b0f8b3b | 16 | Lesser General Public License for more details. |
ovidiup13 | 0:1e597b0f8b3b | 17 | |
ovidiup13 | 0:1e597b0f8b3b | 18 | You should have received a copy of the GNU Lesser General Public |
ovidiup13 | 0:1e597b0f8b3b | 19 | License along with this library; if not, write to the Free Software |
ovidiup13 | 0:1e597b0f8b3b | 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
ovidiup13 | 0:1e597b0f8b3b | 21 | |
ovidiup13 | 0:1e597b0f8b3b | 22 | // some of this code was written by <cstone@pobox.com> originally; it is in the public domain. |
ovidiup13 | 0:1e597b0f8b3b | 23 | */ |
ovidiup13 | 0:1e597b0f8b3b | 24 | |
ovidiup13 | 0:1e597b0f8b3b | 25 | |
ovidiup13 | 0:1e597b0f8b3b | 26 | #ifndef _st7565LCD_H_ |
ovidiup13 | 0:1e597b0f8b3b | 27 | #define _st7565LCD_H_ |
ovidiup13 | 0:1e597b0f8b3b | 28 | |
ovidiup13 | 0:1e597b0f8b3b | 29 | #include "mbed.h" |
ovidiup13 | 0:1e597b0f8b3b | 30 | |
ovidiup13 | 0:1e597b0f8b3b | 31 | #define swap(a, b) { uint8_t t = a; a = b; b = t; } |
ovidiup13 | 0:1e597b0f8b3b | 32 | |
ovidiup13 | 0:1e597b0f8b3b | 33 | #define BLACK 1 |
ovidiup13 | 0:1e597b0f8b3b | 34 | #define WHITE 0 |
ovidiup13 | 0:1e597b0f8b3b | 35 | |
ovidiup13 | 0:1e597b0f8b3b | 36 | #define LCDWIDTH 128 |
ovidiup13 | 0:1e597b0f8b3b | 37 | #define LCDHEIGHT 64 |
ovidiup13 | 0:1e597b0f8b3b | 38 | |
ovidiup13 | 0:1e597b0f8b3b | 39 | #define INITIAL_CONTRAST 0x18 |
ovidiup13 | 0:1e597b0f8b3b | 40 | |
ovidiup13 | 0:1e597b0f8b3b | 41 | #define CMD_DISPLAY_OFF 0xAE |
ovidiup13 | 0:1e597b0f8b3b | 42 | #define CMD_DISPLAY_ON 0xAF |
ovidiup13 | 0:1e597b0f8b3b | 43 | |
ovidiup13 | 0:1e597b0f8b3b | 44 | #define CMD_SET_DISP_START_LINE 0x40 |
ovidiup13 | 0:1e597b0f8b3b | 45 | #define CMD_SET_PAGE 0xB0 |
ovidiup13 | 0:1e597b0f8b3b | 46 | |
ovidiup13 | 0:1e597b0f8b3b | 47 | #define CMD_SET_COLUMN_UPPER 0x10 |
ovidiup13 | 0:1e597b0f8b3b | 48 | #define CMD_SET_COLUMN_LOWER 0x00 |
ovidiup13 | 0:1e597b0f8b3b | 49 | |
ovidiup13 | 0:1e597b0f8b3b | 50 | #define CMD_SET_ADC_NORMAL 0xA0 |
ovidiup13 | 0:1e597b0f8b3b | 51 | #define CMD_SET_ADC_REVERSE 0xA1 |
ovidiup13 | 0:1e597b0f8b3b | 52 | |
ovidiup13 | 0:1e597b0f8b3b | 53 | #define CMD_SET_DISP_NORMAL 0xA6 |
ovidiup13 | 0:1e597b0f8b3b | 54 | #define CMD_SET_DISP_REVERSE 0xA7 |
ovidiup13 | 0:1e597b0f8b3b | 55 | |
ovidiup13 | 0:1e597b0f8b3b | 56 | #define CMD_SET_ALLPTS_NORMAL 0xA4 |
ovidiup13 | 0:1e597b0f8b3b | 57 | #define CMD_SET_ALLPTS_ON 0xA5 |
ovidiup13 | 0:1e597b0f8b3b | 58 | #define CMD_SET_BIAS_9 0xA2 |
ovidiup13 | 0:1e597b0f8b3b | 59 | #define CMD_SET_BIAS_7 0xA3 |
ovidiup13 | 0:1e597b0f8b3b | 60 | |
ovidiup13 | 0:1e597b0f8b3b | 61 | #define CMD_RMW 0xE0 |
ovidiup13 | 0:1e597b0f8b3b | 62 | #define CMD_RMW_CLEAR 0xEE |
ovidiup13 | 0:1e597b0f8b3b | 63 | #define CMD_INTERNAL_RESET 0xE2 |
ovidiup13 | 0:1e597b0f8b3b | 64 | #define CMD_SET_COM_NORMAL 0xC0 |
ovidiup13 | 0:1e597b0f8b3b | 65 | #define CMD_SET_COM_REVERSE 0xC8 |
ovidiup13 | 0:1e597b0f8b3b | 66 | #define CMD_SET_POWER_CONTROL 0x28 |
ovidiup13 | 0:1e597b0f8b3b | 67 | #define CMD_SET_RESISTOR_RATIO 0x20 |
ovidiup13 | 0:1e597b0f8b3b | 68 | #define CMD_SET_VOLUME_FIRST 0x81 |
ovidiup13 | 0:1e597b0f8b3b | 69 | #define CMD_SET_VOLUME_SECOND 0x00 |
ovidiup13 | 0:1e597b0f8b3b | 70 | #define CMD_SET_STATIC_OFF 0xAC |
ovidiup13 | 0:1e597b0f8b3b | 71 | #define CMD_SET_STATIC_ON 0xAD |
ovidiup13 | 0:1e597b0f8b3b | 72 | #define CMD_SET_STATIC_REG 0x0 |
ovidiup13 | 0:1e597b0f8b3b | 73 | #define CMD_SET_BOOSTER_FIRST 0xF8 |
ovidiup13 | 0:1e597b0f8b3b | 74 | #define CMD_SET_BOOSTER_234 0 |
ovidiup13 | 0:1e597b0f8b3b | 75 | #define CMD_SET_BOOSTER_5 1 |
ovidiup13 | 0:1e597b0f8b3b | 76 | #define CMD_SET_BOOSTER_6 3 |
ovidiup13 | 0:1e597b0f8b3b | 77 | #define CMD_NOP 0xE3 |
ovidiup13 | 0:1e597b0f8b3b | 78 | #define CMD_TEST 0xF0 |
ovidiup13 | 0:1e597b0f8b3b | 79 | |
ovidiup13 | 0:1e597b0f8b3b | 80 | class ST7565 { |
ovidiup13 | 0:1e597b0f8b3b | 81 | |
ovidiup13 | 0:1e597b0f8b3b | 82 | private: |
ovidiup13 | 0:1e597b0f8b3b | 83 | SPI _spi; |
ovidiup13 | 0:1e597b0f8b3b | 84 | DigitalOut _cs; |
ovidiup13 | 0:1e597b0f8b3b | 85 | DigitalOut _rst; |
ovidiup13 | 0:1e597b0f8b3b | 86 | DigitalOut _a0; |
ovidiup13 | 0:1e597b0f8b3b | 87 | void spiwrite(uint8_t c); |
ovidiup13 | 0:1e597b0f8b3b | 88 | void my_setpixel(uint8_t x, uint8_t y, uint8_t color); |
ovidiup13 | 0:1e597b0f8b3b | 89 | |
ovidiup13 | 0:1e597b0f8b3b | 90 | //uint8_t buffer[128*64/8]; |
ovidiup13 | 0:1e597b0f8b3b | 91 | public: |
ovidiup13 | 0:1e597b0f8b3b | 92 | ST7565(PinName mosi, PinName sclk, PinName cs, PinName rst, PinName a0); |
ovidiup13 | 0:1e597b0f8b3b | 93 | ~ST7565() {}; |
ovidiup13 | 0:1e597b0f8b3b | 94 | void st7565_init(void); |
ovidiup13 | 0:1e597b0f8b3b | 95 | void begin(uint8_t contrast); |
ovidiup13 | 0:1e597b0f8b3b | 96 | void st7565_command(uint8_t c); |
ovidiup13 | 0:1e597b0f8b3b | 97 | void st7565_data(uint8_t c); |
ovidiup13 | 0:1e597b0f8b3b | 98 | void st7565_set_brightness(uint8_t val); |
ovidiup13 | 0:1e597b0f8b3b | 99 | void clear_display(void); |
ovidiup13 | 0:1e597b0f8b3b | 100 | void clear(); |
ovidiup13 | 0:1e597b0f8b3b | 101 | void display(); |
ovidiup13 | 0:1e597b0f8b3b | 102 | |
ovidiup13 | 0:1e597b0f8b3b | 103 | void setpixel(uint8_t x, uint8_t y, uint8_t color); |
ovidiup13 | 0:1e597b0f8b3b | 104 | uint8_t getpixel(uint8_t x, uint8_t y); |
ovidiup13 | 0:1e597b0f8b3b | 105 | void fillcircle(uint8_t x0, uint8_t y0, uint8_t r, |
ovidiup13 | 0:1e597b0f8b3b | 106 | uint8_t color); |
ovidiup13 | 0:1e597b0f8b3b | 107 | void drawcircle(uint8_t x0, uint8_t y0, uint8_t r, |
ovidiup13 | 0:1e597b0f8b3b | 108 | uint8_t color); |
ovidiup13 | 0:1e597b0f8b3b | 109 | void drawrect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, |
ovidiup13 | 0:1e597b0f8b3b | 110 | uint8_t color); |
ovidiup13 | 0:1e597b0f8b3b | 111 | void fillrect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, |
ovidiup13 | 0:1e597b0f8b3b | 112 | uint8_t color); |
ovidiup13 | 0:1e597b0f8b3b | 113 | void drawline(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, |
ovidiup13 | 0:1e597b0f8b3b | 114 | uint8_t color); |
ovidiup13 | 0:1e597b0f8b3b | 115 | void drawchar(uint8_t x, uint8_t line, char c); |
ovidiup13 | 0:1e597b0f8b3b | 116 | void drawstring(uint8_t x, uint8_t line, char *c); |
ovidiup13 | 0:1e597b0f8b3b | 117 | /*void drawbitmap(uint8_t x, uint8_t y, |
ovidiup13 | 0:1e597b0f8b3b | 118 | const uint8_t *bitmap, uint8_t w, uint8_t h, |
ovidiup13 | 0:1e597b0f8b3b | 119 | uint8_t color);*/ |
ovidiup13 | 0:1e597b0f8b3b | 120 | uint8_t _BV(uint8_t bit); |
ovidiup13 | 0:1e597b0f8b3b | 121 | uint8_t _nBV(uint8_t bit); |
ovidiup13 | 0:1e597b0f8b3b | 122 | |
ovidiup13 | 0:1e597b0f8b3b | 123 | }; |
ovidiup13 | 0:1e597b0f8b3b | 124 | |
ovidiup13 | 0:1e597b0f8b3b | 125 | #endif |