A collection of Analog Devices drivers for the mbed platform
For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
libraries/EVAL_ADXL362_ARDZ/Lcd.h@33:c3ec596a29c2, 2016-11-07 (annotated)
- Committer:
- Adrian Suciu
- Date:
- Mon Nov 07 16:27:12 2016 +0200
- Revision:
- 33:c3ec596a29c2
- Parent:
- 29:c693bdaac786
Added CN0391, CN0396 and CN0397 shields
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Adrian Suciu |
24:dae7123d432a | 1 | /** |
Adrian Suciu |
24:dae7123d432a | 2 | ****************************************************************************** |
Adrian Suciu |
24:dae7123d432a | 3 | * @file Lcd.c |
Adrian Suciu |
24:dae7123d432a | 4 | * @brief Header file for ST7565R LCD control. |
Adrian Suciu |
24:dae7123d432a | 5 | * @author ADI |
Adrian Suciu |
24:dae7123d432a | 6 | * @date March 2016 |
Adrian Suciu |
24:dae7123d432a | 7 | * |
Adrian Suciu |
24:dae7123d432a | 8 | ******************************************************************************* |
Adrian Suciu |
24:dae7123d432a | 9 | * Copyright 2015(c) Analog Devices, Inc. |
Adrian Suciu |
24:dae7123d432a | 10 | * |
Adrian Suciu |
24:dae7123d432a | 11 | * All rights reserved. |
Adrian Suciu |
24:dae7123d432a | 12 | * |
Adrian Suciu |
24:dae7123d432a | 13 | * Redistribution and use in source and binary forms, with or without modification, |
Adrian Suciu |
24:dae7123d432a | 14 | * are permitted provided that the following conditions are met: |
Adrian Suciu |
24:dae7123d432a | 15 | * - Redistributions of source code must retain the above copyright |
Adrian Suciu |
24:dae7123d432a | 16 | * notice, this list of conditions and the following disclaimer. |
Adrian Suciu |
24:dae7123d432a | 17 | * - Redistributions in binary form must reproduce the above copyright |
Adrian Suciu |
24:dae7123d432a | 18 | * notice, this list of conditions and the following disclaimer in |
Adrian Suciu |
24:dae7123d432a | 19 | * the documentation and/or other materials provided with the |
Adrian Suciu |
24:dae7123d432a | 20 | * distribution. |
Adrian Suciu |
24:dae7123d432a | 21 | * - Neither the name of Analog Devices, Inc. nor the names of its |
Adrian Suciu |
24:dae7123d432a | 22 | * contributors may be used to endorse or promote products derived |
Adrian Suciu |
24:dae7123d432a | 23 | * from this software without specific prior written permission. |
Adrian Suciu |
24:dae7123d432a | 24 | * - The use of this software may or may not infringe the patent rights |
Adrian Suciu |
24:dae7123d432a | 25 | * of one or more patent holders. This license does not release you |
Adrian Suciu |
24:dae7123d432a | 26 | * from the requirement that you obtain separate licenses from these |
Adrian Suciu |
24:dae7123d432a | 27 | * patent holders to use this software. |
Adrian Suciu |
24:dae7123d432a | 28 | * - Use of the software either in source or binary form, must be run |
Adrian Suciu |
24:dae7123d432a | 29 | * on or directly connected to an Analog Devices Inc. component. |
Adrian Suciu |
24:dae7123d432a | 30 | * |
Adrian Suciu |
24:dae7123d432a | 31 | * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED |
Adrian Suciu |
24:dae7123d432a | 32 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY |
Adrian Suciu |
24:dae7123d432a | 33 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
Adrian Suciu |
24:dae7123d432a | 34 | * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
Adrian Suciu |
24:dae7123d432a | 35 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
Adrian Suciu |
24:dae7123d432a | 36 | * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Adrian Suciu |
24:dae7123d432a | 37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
Adrian Suciu |
24:dae7123d432a | 38 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Adrian Suciu |
24:dae7123d432a | 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Adrian Suciu |
24:dae7123d432a | 40 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Adrian Suciu |
24:dae7123d432a | 41 | * |
Adrian Suciu |
24:dae7123d432a | 42 | ******************************************************************************* |
Adrian Suciu |
24:dae7123d432a | 43 | **/ |
Adrian Suciu |
24:dae7123d432a | 44 | #ifndef LCD_H_ |
Adrian Suciu |
24:dae7123d432a | 45 | #define LCD_H_ |
Adrian Suciu |
24:dae7123d432a | 46 | |
Adrian Suciu |
24:dae7123d432a | 47 | |
Adrian Suciu |
24:dae7123d432a | 48 | /******************************************************************************/ |
Adrian Suciu |
24:dae7123d432a | 49 | /***************************** Include Files **********************************/ |
Adrian Suciu |
24:dae7123d432a | 50 | /******************************************************************************/ |
Adrian Suciu |
24:dae7123d432a | 51 | #include <stdio.h> |
Adrian Suciu |
24:dae7123d432a | 52 | #include "mbed.h" |
Adrian Suciu |
24:dae7123d432a | 53 | |
Adrian Suciu |
29:c693bdaac786 | 54 | |
Adrian Suciu |
29:c693bdaac786 | 55 | /** |
Adrian Suciu |
29:c693bdaac786 | 56 | * @brief Lcd class |
Adrian Suciu |
29:c693bdaac786 | 57 | */ |
Adrian Suciu |
24:dae7123d432a | 58 | class Lcd |
Adrian Suciu |
24:dae7123d432a | 59 | { |
Adrian Suciu |
24:dae7123d432a | 60 | public: |
Adrian Suciu |
24:dae7123d432a | 61 | |
Adrian Suciu |
24:dae7123d432a | 62 | const static uint8_t pui8Rec8x8[8]; |
Adrian Suciu |
24:dae7123d432a | 63 | const static uint8_t pui8RecInv8x8[8]; |
Adrian Suciu |
24:dae7123d432a | 64 | const static uint8_t pui8font5x7[96][5]; ///< Symbol matrix structure: Font (8x14) |
Adrian Suciu |
24:dae7123d432a | 65 | |
Adrian Suciu |
24:dae7123d432a | 66 | Lcd(PinName rst = D3, PinName a0 = D5, PinName bl = D8, PinName cs = D6, |
Adrian Suciu |
24:dae7123d432a | 67 | PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = |
Adrian Suciu |
24:dae7123d432a | 68 | SPI_SCK); |
Adrian Suciu |
24:dae7123d432a | 69 | void init(void); |
Adrian Suciu |
24:dae7123d432a | 70 | void display_string(uint8_t ui8row, uint8_t ui8col, int8_t *pi8str); |
Adrian Suciu |
24:dae7123d432a | 71 | void display_symbol(uint8_t ui8row, uint8_t ui8col, uint8_t ui8width, |
Adrian Suciu |
24:dae7123d432a | 72 | const uint8_t *pui8symbol); |
Adrian Suciu |
24:dae7123d432a | 73 | void fill_pages(uint8_t ui8start, uint8_t ui8num, uint8_t ui8Data); |
Adrian Suciu |
24:dae7123d432a | 74 | void set_line(uint8_t ui8line); |
Adrian Suciu |
24:dae7123d432a | 75 | void set_cursor(uint8_t ui8PA, uint8_t ui8CA); |
Adrian Suciu |
24:dae7123d432a | 76 | void bl_enable(); |
Adrian Suciu |
24:dae7123d432a | 77 | void bl_disable(); |
Adrian Suciu |
24:dae7123d432a | 78 | |
Adrian Suciu |
24:dae7123d432a | 79 | void write_cmd(uint8_t cmd); |
Adrian Suciu |
24:dae7123d432a | 80 | void write_data(uint8_t data); |
Adrian Suciu |
24:dae7123d432a | 81 | |
Adrian Suciu |
24:dae7123d432a | 82 | |
Adrian Suciu |
24:dae7123d432a | 83 | typedef enum { |
Adrian Suciu |
24:dae7123d432a | 84 | CMD_DISPLAY_OFF = 0xAE, |
Adrian Suciu |
24:dae7123d432a | 85 | CMD_DISPLAY_ON = 0xAF, |
Adrian Suciu |
24:dae7123d432a | 86 | CMD_SET_DISP_START_LINE = 0x40, |
Adrian Suciu |
24:dae7123d432a | 87 | CMD_SET_PAGE = 0xB0, |
Adrian Suciu |
24:dae7123d432a | 88 | CMD_SET_COLUMN_UPPER = 0x10, |
Adrian Suciu |
24:dae7123d432a | 89 | CMD_SET_COLUMN_LOWER = 0x00, |
Adrian Suciu |
24:dae7123d432a | 90 | CMD_SET_ADC_NORMAL = 0xA0, |
Adrian Suciu |
24:dae7123d432a | 91 | CMD_SET_ADC_REVERSE = 0xA1, |
Adrian Suciu |
24:dae7123d432a | 92 | CMD_SET_DISP_NORMAL = 0xA6, |
Adrian Suciu |
24:dae7123d432a | 93 | CMD_SET_DISP_REVERSE = 0xA7, |
Adrian Suciu |
24:dae7123d432a | 94 | CMD_SET_ALLPTS_NORMAL = 0xA4, |
Adrian Suciu |
24:dae7123d432a | 95 | CMD_SET_ALLPTS_ON = 0xA5, |
Adrian Suciu |
24:dae7123d432a | 96 | CMD_SET_BIAS_9 = 0xA2, |
Adrian Suciu |
24:dae7123d432a | 97 | CMD_SET_BIAS_7 = 0xA3, |
Adrian Suciu |
24:dae7123d432a | 98 | CMD_RMW = 0xE0, |
Adrian Suciu |
24:dae7123d432a | 99 | CMD_RMW_CLEAR = 0xEE, |
Adrian Suciu |
24:dae7123d432a | 100 | CMD_INTERNAL_RESET = 0xE2, |
Adrian Suciu |
24:dae7123d432a | 101 | CMD_SET_COM_NORMAL = 0xC0, |
Adrian Suciu |
24:dae7123d432a | 102 | CMD_SET_COM_REVERSE = 0xC8, |
Adrian Suciu |
24:dae7123d432a | 103 | CMD_SET_POWER_CONTROL = 0x28, |
Adrian Suciu |
24:dae7123d432a | 104 | CMD_SET_RESISTOR_RATIO = 0x20, |
Adrian Suciu |
24:dae7123d432a | 105 | CMD_SET_VOLUME_FIRST = 0x81, |
Adrian Suciu |
24:dae7123d432a | 106 | CMD_SET_VOLUME_SECOND = 0, |
Adrian Suciu |
24:dae7123d432a | 107 | CMD_SET_STATIC_OFF = 0xAC, |
Adrian Suciu |
24:dae7123d432a | 108 | CMD_SET_STATIC_ON = 0xAD, |
Adrian Suciu |
24:dae7123d432a | 109 | CMD_SET_STATIC_REG = 0x0, |
Adrian Suciu |
24:dae7123d432a | 110 | CMD_SET_BOOSTER_FIRST = 0xF8, |
Adrian Suciu |
24:dae7123d432a | 111 | CMD_SET_BOOSTER_234 = 0, |
Adrian Suciu |
24:dae7123d432a | 112 | CMD_SET_BOOSTER_5 = 1, |
Adrian Suciu |
24:dae7123d432a | 113 | CMD_SET_BOOSTER_6 = 3, |
Adrian Suciu |
24:dae7123d432a | 114 | CMD_NOP = 0xE3, |
Adrian Suciu |
24:dae7123d432a | 115 | CMD_TEST = 0xF0, |
Adrian Suciu |
24:dae7123d432a | 116 | } lcd_commands_t; |
Adrian Suciu |
24:dae7123d432a | 117 | |
Adrian Suciu |
24:dae7123d432a | 118 | static const uint8_t LCD_COLUMNS = 128u; |
Adrian Suciu |
24:dae7123d432a | 119 | static const uint8_t LCD_PAGES = 4u; |
Adrian Suciu |
24:dae7123d432a | 120 | static const uint8_t LCD_LINES = 64u; |
Adrian Suciu |
24:dae7123d432a | 121 | static const uint8_t UP_X = 112; |
Adrian Suciu |
24:dae7123d432a | 122 | static const uint8_t LEFT_X = 104; |
Adrian Suciu |
24:dae7123d432a | 123 | static const uint8_t RIGHT_X = 120; |
Adrian Suciu |
24:dae7123d432a | 124 | static const uint8_t DOWN_X = 112; |
Adrian Suciu |
24:dae7123d432a | 125 | static const uint8_t CENTER_X = 112; |
Adrian Suciu |
24:dae7123d432a | 126 | static const uint8_t ACC_LIMIT = 80; |
Adrian Suciu |
24:dae7123d432a | 127 | static const uint8_t FONT_Y_SIZE = 8; ///< Font size for Y |
Adrian Suciu |
24:dae7123d432a | 128 | static const uint8_t OFFS_ASCII = 32; ///< ASCII offset |
Adrian Suciu |
24:dae7123d432a | 129 | |
Adrian Suciu |
24:dae7123d432a | 130 | static const float ACC_TEMP_BIAS = 350 ; ///< Accelerometer temperature bias(in ADC codes) at 25 Deg C |
Adrian Suciu |
24:dae7123d432a | 131 | static const float ACC_TEMP_SENSITIVITY = 0.065; ///< Accelerometer temperature sensitivity from datasheet (DegC per Code) |
Adrian Suciu |
24:dae7123d432a | 132 | |
Adrian Suciu |
24:dae7123d432a | 133 | private: |
Adrian Suciu |
24:dae7123d432a | 134 | |
Adrian Suciu |
24:dae7123d432a | 135 | DigitalOut rst, a0, bl, cs; |
Adrian Suciu |
24:dae7123d432a | 136 | SPI lcd_spi; |
Adrian Suciu |
24:dae7123d432a | 137 | |
Adrian Suciu |
24:dae7123d432a | 138 | |
Adrian Suciu |
24:dae7123d432a | 139 | |
Adrian Suciu |
24:dae7123d432a | 140 | }; |
Adrian Suciu |
24:dae7123d432a | 141 | |
Adrian Suciu |
24:dae7123d432a | 142 | #endif /* LCD_H_ */ |