/**************************************************************************//** * @brief LCD Light up or shut off Battery Indicator * @param lcd Pointer to LCD register block * @param batteryLevel Battery Level, 0 to 4 (0 turns all off) *****************************************************************************/ void LCD_Battery(LCD_TypeDef *lcd, int batteryLevel) { uint32_t com, bitvalue; int i, on; for (i = 0; i < 4; i++) { if (i < batteryLevel) { on = 1; } else { on = 0; } com = EFMDisplay.Battery.com[i]; bitvalue = 1 << EFMDisplay.Battery.bit[i]; if (on) { LCD_enableSegment(lcd, com, bitvalue); } else { LCD_disableSegment(lcd, com, bitvalue); } } }
/**************************************************************************//** * @brief LCD Light up or shut off Ring of Indicators * @param lcd Pointer to LCD register block * @param anum "Segment number" on "Ring", range 0 - 7 * @param on Zero is off, non-zero is on *****************************************************************************/ void LCD_ARing(LCD_TypeDef *lcd, int anum, int on) { uint32_t com, bitvalue; com = EFMDisplay.ARing.com[anum]; bitvalue = 1 << EFMDisplay.ARing.bit[anum]; if (on) { LCD_enableSegment(lcd, com, bitvalue); } else { LCD_disableSegment(lcd, com, bitvalue); } }
/**************************************************************************//** * @brief LCD Light up or shut off Energy Mode indicator * @param lcd Pointer to LCD register block * @pararm em Energy Mode numer 0 to 4 * @param on Zero is off, non-zero is on *****************************************************************************/ void LCD_EnergyMode(LCD_TypeDef *lcd, int em, int on) { uint32_t com, bitvalue; com = EFMDisplay.EMode.com[em]; bitvalue = 1 << EFMDisplay.EMode.bit[em]; if (on) { LCD_enableSegment(lcd, com, bitvalue); } else { LCD_disableSegment(lcd, com, bitvalue); } }
/**************************************************************************//** * @brief Turn all segments on numeric display off * @param lcd Pointer to LCD register structure *****************************************************************************/ void LCD_NumberOff(LCD_TypeDef *lcd) { int digit, i, bit, com; /* Turn off all segments */ for (digit = 0; digit < 4; digit++) { for (i = 0; i < 7; i++) { bit = EFMDisplay.Number[digit].bit[i]; com = EFMDisplay.Number[digit].com[i]; LCD_disableSegment(lcd, com, 1 << bit); } } return; }
/**************************************************************************//** * @brief Write text on LCD display * @param lcd Pointer to LCD register structure * @param string Text string to show on display *****************************************************************************/ void LCD_Write(LCD_TypeDef *lcd, char *string) { int data, length, index; uint16_t bitfield; uint32_t value; uint32_t com, bit; int i; length = strlen(string); index = 0; /* fill out all characters on display */ for (index = 0; index < 7; index++) { if (index < length) { data = (int) *string; } else /* padding with space */ { data = 0x20; /* SPACE */ } /* defined letters currently starts at "SPACE" - 0x20; */ data = data - 0x20; bitfield = EM_alphabet[data]; for (i = 0; i < 14; i++) { bit = EFMDisplay.Text[index].bit[i]; com = EFMDisplay.Text[index].com[i]; value = (1 << bit); if (bitfield & (1 << i)) { /* Turn on segment */ LCD_enableSegment(lcd, com, value); } else { /* Turn off segment */ LCD_disableSegment(lcd, com, value); } } string++; } while (lcd->SYNCBUSY) ; }
/**************************************************************************//** * @brief Write number on numeric part on LCD display * @param lcd Pointer to LCD control block * @param value Numeric value to put on display, in range -999 to +9999 *****************************************************************************/ void LCD_Number(LCD_TypeDef *lcd, int value) { int num, i, com, bit, digit, div, neg; uint16_t bitpattern; /* Parameter consistancy check */ if (value >= 9999) { value = 9999; } if (value <= -1000) { value = -999; } if (value < 0) { value = abs(value); neg = 1; } else { neg = 0; } /* Extract useful digits */ div = 1; for (digit = 0; digit < 4; digit++) { num = (value / div) % 10; if ((neg == 1) && (digit == 3)) num = 10; bitpattern = EM_Numbers[num]; for (i = 0; i < 7; i++) { bit = EFMDisplay.Number[digit].bit[i]; com = EFMDisplay.Number[digit].com[i]; if (bitpattern & (1 << i)) { LCD_enableSegment(lcd, com, 1 << bit); } else { LCD_disableSegment(lcd, com, 1 << bit); } } div = div * 10; } }
/**************************************************************************//** * @brief LCD Light up or shut off various symbols on LCD Display * @param lcd Pointer to LCD register block * @param s Which symbol to turn on or off * @param on Zero is off, non-zero is on *****************************************************************************/ void LCD_Symbol(LCD_TypeDef *lcd, lcdSymbol s, int on) { int com, bit; switch (s) { case LCD_SYMBOL_GECKO: com = 3; bit = 8; break; case LCD_SYMBOL_ANT: com = 3; bit = 1; break; case LCD_SYMBOL_PAD0: com = 1; bit = 8; break; case LCD_SYMBOL_PAD1: com = 2; bit = 8; break; case LCD_SYMBOL_AM: com = 4; bit = 0; break; case LCD_SYMBOL_PM: com = 4; bit = 3; break; case LCD_SYMBOL_EFM32: com = 0; bit = 8; break; case LCD_SYMBOL_MINUS: com = 0; bit = 9; break; case LCD_SYMBOL_COL3: com = 0; bit = 16; break; case LCD_SYMBOL_COL5: com = 0; bit = 24; break; case LCD_SYMBOL_COL10: com = 4; bit = 7; break; case LCD_SYMBOL_DP2: com = 4; bit = 2; break; case LCD_SYMBOL_DP3: com = 5; bit = 2; break; case LCD_SYMBOL_DP4: com = 6; bit = 2; break; case LCD_SYMBOL_DP5: com = 7; bit = 2; break; case LCD_SYMBOL_DP6: com = 0; bit = 21; break; case LCD_SYMBOL_DP10: com = 4; bit = 5; break; } if (on) { LCD_enableSegment(lcd, com, 1 << bit); } else { LCD_disableSegment(lcd, com, 1 << bit); } }