segmentlcd.c File Reference

Segment LCD Display driver.

License

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

SPDX-License-Identifier: Zlib

The licensor of this software is Silicon Laboratories Inc.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

Definition in file segmentlcd.c.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include "em_device.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "segmentlcd.h"

Data Structures

struct  ARING_TypeDef
 Defines segment COM and BIT fields for A-wheel (suited for Anim)
 
struct  ARRAY_TypeDef
 Defines segment COM and BIT fields for array.
 
struct  BATTERY_TypeDef
 Defines segment COM and BIT fields for Battery (suited for Anim)
 
struct  Block_TypeDef
 Defines segment COM and BIT fields for top and bottom row blocks. The bit pattern shown above for characters can be split into upper and lower portions for animation purposes. There are separate COM and BIT numbers which together represent a set of stacked blocks which can be shown on two rows in the segmented LCD screen.
 
struct  CHAR_TypeDef
 Defines each text symbol's segment in terms of COM and BIT numbers, in a way that we can enumerate each bit for each text segment in the following bit pattern:
 
struct  EM_TypeDef
 Defines segment COM and BIT fields for Energy Modes on display.
 
struct  MCU_DISPLAY
 Defines prototype for all segments in display.
 
struct  NUMBER_TypeDef
 Defines segment COM and BIT fields numeric display.
 

Macros

#define ALPHA_DIGITS   7
 
#define ALPHA_VAL_MAX   9999999
 
#define ALPHA_VAL_MIN   -9999999
 
#define NUM_DIGITS   4
 
#define NUM_VAL_MAX   9999
 
#define NUM_VAL_MAX_HEX   0xFFFF
 
#define NUM_VAL_MIN   -999
 

Functions

static void displayBlock (SegmentLCD_BlockMode_TypeDef topMode[SEGMENT_LCD_NUM_BLOCK_COLUMNS], SegmentLCD_BlockMode_TypeDef botMode[SEGMENT_LCD_NUM_BLOCK_COLUMNS])
 Working instance of LCD display.
 
void SegmentLCD_AllOff (void)
 Disable all segments.
 
void SegmentLCD_AllOn (void)
 Enable all segments.
 
void SegmentLCD_AlphaNumberOff (void)
 Turn all segments on alpha characters in display off.
 
void SegmentLCD_ARing (int anum, int on)
 Light up or shut off Ring of Indicators.
 
void SegmentLCD_Battery (int batteryLevel)
 Light up or shut off Battery Indicator.
 
void SegmentLCD_Block (SegmentLCD_BlockMode_TypeDef topMode[SEGMENT_LCD_NUM_BLOCK_COLUMNS], SegmentLCD_BlockMode_TypeDef botMode[SEGMENT_LCD_NUM_BLOCK_COLUMNS])
 
void SegmentLCD_chargeRedistributionEnable (bool enable)
 Enabling/disabling dynamic charge redistribution.
 
void SegmentLCD_Disable (void)
 Disables LCD controller.
 
void SegmentLCD_EnergyMode (int em, int on)
 Light up or shut off Energy Mode indicator.
 
void SegmentLCD_Init (bool useBoost)
 Segment LCD Initialization routine for EFM32 STK display.
 
void SegmentLCD_LowerHex (uint32_t num)
 Write a hexadecimal number on lower alphanumeric part of Segment LCD display.
 
void SegmentLCD_LowerNumber (int num)
 Write number on lower alphanumeric part of Segment LCD display.
 
void SegmentLCD_Number (int value)
 Write number on numeric part on Segment LCD display.
 
void SegmentLCD_NumberOff (void)
 Turn all segments on numeric digits in display off.
 
unsigned int SegmentLCD_segCnt (unsigned int segdl, unsigned int segdh)
 Counting the number of active segments in a single common line.
 
void SegmentLCD_Symbol (lcdSymbol s, int on)
 Light up or shut off various symbols on Segment LCD.
 
void SegmentLCD_UnsignedHex (uint32_t value)
 Write hexadecimal number on numeric part on Segment LCD display.
 
void SegmentLCD_updateCHGRDST (void)
 Dynamically switching charge redistribution ON/OFF based on display contents.
 
void SegmentLCD_Write (const char *string)
 Write text on LCD display.
 

Variables

static const uint16_t Blocks []
 Defines highlighted segments for the block display.
 
static const MCU_DISPLAY EFM_Display = EFM_DISPLAY_DEF
 Working instance of LCD display.
 
static const uint16_t Segment_Alphabet []
 Defines higlighted segments for the alphabet, starting from "blank" (SPACE) Uses bit pattern as defined for text segments above. E.g. a capital O, would have bits 0 1 2 3 4 5 => 0x003f defined.
 
static const uint16_t Segment_Numbers []
 Defines higlighted segments for the numeric display.