Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of EFM32_SegmentLCD by
EFM32_SegmentLCD.cpp
00001 /***************************************************************************//** 00002 * @file EFM32_SegmentLCD.cpp 00003 * @brief Driver class for the segment LCD's on some of the EFM32 kits. 00004 ******************************************************************************* 00005 * @section License 00006 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b> 00007 ******************************************************************************* 00008 * 00009 * Permission is granted to anyone to use this software for any purpose, 00010 * including commercial applications, and to alter it and redistribute it 00011 * freely, subject to the following restrictions: 00012 * 00013 * 1. The origin of this software must not be misrepresented; you must not 00014 * claim that you wrote the original software. 00015 * 2. Altered source versions must be plainly marked as such, and must not be 00016 * misrepresented as being the original software. 00017 * 3. This notice may not be removed or altered from any source distribution. 00018 * 00019 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no 00020 * obligation to support this Software. Silicon Labs is providing the 00021 * Software "AS IS", with no express or implied warranties of any kind, 00022 * including, but not limited to, any implied warranties of merchantability 00023 * or fitness for any particular purpose or warranties against infringement 00024 * of any proprietary rights of a third party. 00025 * 00026 * Silicon Labs will not be liable for any consequential, incidental, or 00027 * special damages, or any other relief, or for any claim by any third party, 00028 * arising from your use of this Software. 00029 * 00030 ******************************************************************************/ 00031 00032 #include <mbed.h> 00033 #include "pinmap.h" 00034 #include "EFM32_SegmentLCD.h" 00035 #include "segmentlcd.h" 00036 #include "sleep_api.h" 00037 00038 namespace silabs { 00039 /* 00040 * Constructor. 00041 */ 00042 EFM32_SegmentLCD::EFM32_SegmentLCD() { 00043 /* Set all pins used for the LCD to disabled. */ 00044 uint32_t num_pins = sizeof(outPins) / sizeof(outPins[0]); 00045 for(uint8_t i = 0; i < num_pins; i++) { 00046 pin_mode(outPins[i], Disabled); 00047 } 00048 00049 /* Initialize the LCD without voltage booster */ 00050 SegmentLCD_Init(false); 00051 00052 /* Block sleep mode */ 00053 blockSleepMode(EM2); 00054 } 00055 00056 EFM32_SegmentLCD::~EFM32_SegmentLCD() { 00057 /* Shut off LCD peripheral */ 00058 SegmentLCD_Disable(); 00059 00060 /* Unblock sleep mode */ 00061 unblockSleepMode(EM2); 00062 } 00063 00064 void EFM32_SegmentLCD::AllOff( void ) { 00065 SegmentLCD_AllOff(); 00066 } 00067 00068 void EFM32_SegmentLCD::AllOn( void ) { 00069 SegmentLCD_AllOn(); 00070 } 00071 00072 /* 00073 * Switch off (clear) the alphanumeric portion of the display 00074 */ 00075 void EFM32_SegmentLCD::AlphaNumberOff(void) { 00076 SegmentLCD_AlphaNumberOff(); 00077 } 00078 00079 /* 00080 * Switch specified segment on the ring on/off 00081 * anum: ring segment index 00082 * on: true to turn on, false to turn off 00083 */ 00084 void EFM32_SegmentLCD::ARing(int anum, bool on) { 00085 SegmentLCD_ARing(anum, (on ? 1 : 0)); 00086 } 00087 00088 /* 00089 * Display a battery level on the LCD. 00090 * 0 = off 00091 * 1 = lowest block 00092 * 2 = lowest + second-to-lowest 00093 * ... 00094 */ 00095 void EFM32_SegmentLCD::Battery(int batteryLevel) { 00096 SegmentLCD_Battery(batteryLevel); 00097 } 00098 00099 /* 00100 * Display an energy mode ring on the LCD. 00101 * em = energy mode number to display 00102 * on = true to turn on, false to turn off. 00103 */ 00104 void EFM32_SegmentLCD::EnergyMode(int em, bool on) { 00105 SegmentLCD_EnergyMode(em, (on ? 1 : 0)); 00106 } 00107 00108 /* 00109 * Display an unsigned integer on the alphanumeric 00110 * portion of the display as a hex value. 00111 * 00112 * num = number to display 00113 */ 00114 void EFM32_SegmentLCD::LowerHex( uint32_t num ) { 00115 SegmentLCD_LowerHex(num); 00116 } 00117 00118 /* 00119 * Display a signed integer as decimal number on 00120 * the alphanumeric part of the display. 00121 */ 00122 void EFM32_SegmentLCD::LowerNumber( int num ) { 00123 SegmentLCD_LowerNumber(num); 00124 } 00125 00126 /* 00127 * Display a signed integer on the numeric part 00128 * of the display (clock area). 00129 * max = 9999, min = -9999 00130 */ 00131 void EFM32_SegmentLCD::Number(int value) { 00132 SegmentLCD_Number(value); 00133 } 00134 00135 /* 00136 * Clear the numeric part of the display. 00137 */ 00138 void EFM32_SegmentLCD::NumberOff(void) { 00139 SegmentLCD_NumberOff(); 00140 } 00141 00142 /* 00143 * Turn a predefined symbol on or off. 00144 * lcdSymbol = predefined symbol in segmentlcdconfig_*.h 00145 * on = true to turn on, false to turn off. 00146 */ 00147 void EFM32_SegmentLCD::Symbol(lcdSymbol s, bool on) { 00148 SegmentLCD_Symbol(s, (on ? 1 : 0)); 00149 } 00150 00151 /* 00152 * Display an unsigned short integer as a hex value 00153 * on the numeric part of the display. 00154 * max = FFFF, min = 0 00155 */ 00156 void EFM32_SegmentLCD::UnsignedHex(uint16_t value) { 00157 SegmentLCD_UnsignedHex(value); 00158 } 00159 00160 /* 00161 * Display a 7-character string on the alphanumeric 00162 * portion of the display. 00163 */ 00164 void EFM32_SegmentLCD::Write(char *string) { 00165 SegmentLCD_Write(string); 00166 } 00167 00168 00169 }
Generated on Tue Jul 19 2022 15:26:32 by
1.7.2