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