MAXREFDES143#: DeepCover Embedded Security in IoT Authenticated Sensing & Notification
Dependencies: MaximInterface mbed
Display.hpp
00001 /******************************************************************************* 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 *******************************************************************************/ 00032 00033 #ifndef DISPLAY_HPP 00034 #define DISPLAY_HPP 00035 00036 #include <stdint.h> 00037 #include <stddef.h> 00038 #include <string> 00039 00040 namespace mbed { class I2C; } 00041 00042 /// Interface to the Newhaven Display NHD-C0220BiZ-FS(RGB)-FBW-3VM LCD module 00043 /// and MAX7306 PWM LED driver for backlight color selection. 00044 class Display { 00045 public: 00046 /// Display line referenced from top 00047 enum Line { FirstLine = 0, SecondLine }; 00048 00049 /// 24-bit RGB color for the backlight. 00050 struct Color { 00051 uint8_t R, G, B; 00052 }; 00053 00054 /// Length in character os a display line. 00055 static const size_t lineLength = 20; 00056 00057 /// @param I2C_interface A configured I2C interface to use for communication. 00058 /// @param LCD_I2C_address LCD module bus address in mbed format. 00059 /// @param LED_driver_I2C_addr PWM LED driver (MAX7306) bus address in mbed format. 00060 Display (mbed::I2C & I2C_intf, uint8_t LCD_I2C_addr, 00061 uint8_t LED_driver_I2C_addr); 00062 00063 /// Initialize display components. 00064 void initialize(); 00065 00066 /// Clear all display lines. 00067 void clearDisplay(); 00068 00069 /// Clear a specific display line. 00070 void clearLine(Line line); 00071 00072 /// Write a single character to the display at the current cursor position. 00073 void writeCharacter(uint8_t character); 00074 00075 /// Write text to the display at the current cursor position. 00076 void writeText(const std::string & text); 00077 00078 /// Set cursor to a certain line and zero-index position within the line. 00079 void setCursorPosition(Line line, size_t position = 0); 00080 00081 /// Writes text to the display starting at the beginning of the line. 00082 void writeLine(const std::string & text, Line line); 00083 00084 /// Writes text to the display starting at the beginning of the line and 00085 /// clears the remainder of the line. 00086 void writeCompleteLine(const std::string & text, Line line); 00087 00088 /// Writes a message to the display with text wrapping allowed at spaces. 00089 void writeMessage(const std::string & text); 00090 00091 /// Set the display backlight to a certain color. 00092 void setBackLightColor(const Color & color); 00093 00094 private: 00095 mbed::I2C & m_I2C_intf; 00096 uint8_t m_LCD_I2C_addr, m_LED_driver_I2C_addr; 00097 00098 void initializeLCD(); 00099 void initializeLED_Driver(); 00100 }; 00101 00102 #endif
Generated on Wed Jul 13 2022 21:31:02 by 1.7.2