juan jose carranza garcia / Mbed 2 deprecated LCD_KL46z_Example

Dependencies:   mbed

Committer:
JuanBorra
Date:
Sat Apr 13 20:42:47 2019 +0000
Revision:
0:702e0e56ae11
Added LCD example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JuanBorra 0:702e0e56ae11 1 #include "seg_LCD.h"
JuanBorra 0:702e0e56ae11 2
JuanBorra 0:702e0e56ae11 3 const static uint8_t LCD_Frontplane_Pin[LCD_NUM_FRONTPLANE_PINS] = {LCD_FRONTPLANE0, LCD_FRONTPLANE1, LCD_FRONTPLANE2, LCD_FRONTPLANE3, LCD_FRONTPLANE4, LCD_FRONTPLANE5, LCD_FRONTPLANE6, LCD_FRONTPLANE7};
JuanBorra 0:702e0e56ae11 4 const static uint8_t LCD_Backplane_Pin[LCD_NUM_BACKPLANE_PINS] = {LCD_BACKPLANE0, LCD_BACKPLANE1, LCD_BACKPLANE2, LCD_BACKPLANE3};
JuanBorra 0:702e0e56ae11 5
JuanBorra 0:702e0e56ae11 6 void SegLCD_Init(void){ //Initializes all components of SLCD on the FRDM-KL46Z
JuanBorra 0:702e0e56ae11 7
JuanBorra 0:702e0e56ae11 8 SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK | SIM_SCGC5_SLCD_MASK; //Enable Clock to ports B, C, D and E, and SegLCD Peripheral
JuanBorra 0:702e0e56ae11 9 LCD->GCR |= LCD_GCR_PADSAFE_MASK; //Set PADSAFE to disable LCD while configuring
JuanBorra 0:702e0e56ae11 10 LCD->GCR &= ~LCD_GCR_LCDEN_MASK; //Clear LCDEN (LCD Enable) while configuring
JuanBorra 0:702e0e56ae11 11
JuanBorra 0:702e0e56ae11 12
JuanBorra 0:702e0e56ae11 13 //Configure pins *From Reference manual, set pins to MUX 0 for normal LCD display operation, only use MUX 7 if using LCD fault detection
JuanBorra 0:702e0e56ae11 14 PORTB->PCR[7] = PORT_PCR_MUX(0u); //Set PTB7 to LCD_P7
JuanBorra 0:702e0e56ae11 15 PORTB->PCR[8] = PORT_PCR_MUX(0u); //Set PTB8 to LCD_P8
JuanBorra 0:702e0e56ae11 16 PORTB->PCR[10] = PORT_PCR_MUX(0u); //Set PTB10 to LCD_P10
JuanBorra 0:702e0e56ae11 17 PORTB->PCR[11] = PORT_PCR_MUX(0u); //Set PTB11 to LCD_P11
JuanBorra 0:702e0e56ae11 18 PORTB->PCR[21] = PORT_PCR_MUX(0u); //Set PTB21 to LCD_P17
JuanBorra 0:702e0e56ae11 19 PORTB->PCR[22] = PORT_PCR_MUX(0u); //Set PTB22 to LCD_P18
JuanBorra 0:702e0e56ae11 20 PORTB->PCR[23] = PORT_PCR_MUX(0u); //Set PTB23 to LCD_P19
JuanBorra 0:702e0e56ae11 21 PORTC->PCR[17] = PORT_PCR_MUX(0u); //Set PTC17 to LCD_P37
JuanBorra 0:702e0e56ae11 22 PORTC->PCR[18] = PORT_PCR_MUX(0u); //Set PTC18 to LCD_P38
JuanBorra 0:702e0e56ae11 23 PORTD->PCR[0] = PORT_PCR_MUX(0u); //Set PTD0 to LCD_P40
JuanBorra 0:702e0e56ae11 24 PORTE->PCR[4] = PORT_PCR_MUX(0u); //Set PTE4 to LCD_P52
JuanBorra 0:702e0e56ae11 25 PORTE->PCR[5] = PORT_PCR_MUX(0u); //Set PTE5 to LCD_P53
JuanBorra 0:702e0e56ae11 26
JuanBorra 0:702e0e56ae11 27
JuanBorra 0:702e0e56ae11 28 //Configure LCD Registers
JuanBorra 0:702e0e56ae11 29 //Configure LCD_GCR - General Control Register, controls most options in LCD Peripheral
JuanBorra 0:702e0e56ae11 30 LCD->GCR =//LCD_GCR_RVEN_MASK | //Clear LCD_GCR_RVEN, disable voltage regulator.
JuanBorra 0:702e0e56ae11 31 LCD_GCR_RVTRIM(0x00) | //Set RVTRIM to 0, irrelevant as voltage regulator is disabled, but setting it to a known state.
JuanBorra 0:702e0e56ae11 32 LCD_GCR_CPSEL_MASK | //Set LCD_GCR_CPSEL to use capacitor charge pump.
JuanBorra 0:702e0e56ae11 33 LCD_GCR_LADJ(0x03) | //Set LCD_GCR_LADJ to 11, slow clock rate = lower power, but higher load capacitance on the LCD requires higher clock speed.
JuanBorra 0:702e0e56ae11 34 //LCD_GCR_VSUPPLY | //Clear LCD_GCR_VSUPPLY, drive VLL3 externally.
JuanBorra 0:702e0e56ae11 35 LCD_GCR_PADSAFE_MASK | //Set LCD_GCR_PADSAFE, leave enabled during configuration process.
JuanBorra 0:702e0e56ae11 36 //LCD_GCR_FDCIEN_MASK | //Clear LCD_GCR_FDCIEN, No interrupt from fault dection.
JuanBorra 0:702e0e56ae11 37 LCD_GCR_ALTDIV(0x00) | //Set LCD_GCR_ALTDIV to 11, divide alternate clock by 512. This is assuming an 8MHz External Crystal is used.
JuanBorra 0:702e0e56ae11 38 //LCD_GCR_ALTSOURCE_MASK | //Set LCD_GCR_ALTSOURCE, Part of setting clock source to OSCERCLK, or external oscillator.
JuanBorra 0:702e0e56ae11 39 LCD_GCR_FFR_MASK | //Set LCD_GCR_FFR, allow an LCD Frame Frequency of 46.6Hz to 146.2Hz. Disable to change range to 23.3Hz to 73.1Hz.
JuanBorra 0:702e0e56ae11 40 //LCD_GCR_LCDDOZE_MASK | //Clear LCD_GCR_LCDDOZE, allows LCD peripheral to run even in doze mode. Set to disable LCD in doze mode.
JuanBorra 0:702e0e56ae11 41 //LCD_GCR_LCDSTP_MASK | //Clear LCD_GCR_LCDSTP, allows LCD peripheral to run even in stop mode. Set to disable LCD in stop mode.
JuanBorra 0:702e0e56ae11 42 //LCD_GCR_LCDEN_MASK | //Clear LCD_GCR_LCDEN, Disables all front and backplane pins. Leave disabled during configuration process.
JuanBorra 0:702e0e56ae11 43 LCD_GCR_SOURCE_MASK | //Set LCD_GCR_SOURCE, Part of setting clock source to OSCERCLK, or external oscillator.
JuanBorra 0:702e0e56ae11 44 LCD_GCR_LCLK(0x04) | //Set LCD_GCR_LCLK to 111, LCD Clock prescaler where LCD controller frame frequency = LCD clock/((DUTY | 1) x 8 x (4 | LCLK[2:0]) x Y), where Y = 2, 2, 3, 3, 4, 5, 8, 16 chosen by module duty cycle config
JuanBorra 0:702e0e56ae11 45 LCD_GCR_DUTY(0x03); //Set LCD_GCR_DUTY to 011, Have 4 backplane pins, so need a 1/4 duty cycle.
JuanBorra 0:702e0e56ae11 46
JuanBorra 0:702e0e56ae11 47 //Configure LCD_SEG_AR - Auxiliary Register, controls blinking of LCD
JuanBorra 0:702e0e56ae11 48 LCD->AR = //LCD_AR_BLINK_MASK | //Clear LCD_SEG_AR_BLINK, Disable SLCD blinking. Enable to make LCD Blink.
JuanBorra 0:702e0e56ae11 49 //LCD_AR_ALT_MASK | //Clear LCD_SEG_AR_ALT, if enabled LCD back plane sequencer changes to an alternate display. Only functional if DUTY[2:0] is less than 100(binary). This allows a blink screen that is not blank.
JuanBorra 0:702e0e56ae11 50 //LCD_AR_BLANK_MASK | //Clear LCD_SEG_AR_BLANK, asserting bit clears all segments in LCD.
JuanBorra 0:702e0e56ae11 51 //LCD_AR_BMODE_MASK | //Clear LCD_SEG_AR_BMODE, if enabled displays alternate display during blink period instead of blank.
JuanBorra 0:702e0e56ae11 52 LCD_AR_BRATE(0x00); //Set LCD_SEG_AR_BRATE to 000. Frequency of blink is determined by LCD clock/(2^(12 + BRATE))
JuanBorra 0:702e0e56ae11 53
JuanBorra 0:702e0e56ae11 54 //Configure LCD_SEG_FDCR - Fault Detect Control Register, controls use of Fault Detect features of SLCD.
JuanBorra 0:702e0e56ae11 55 LCD->FDCR = 0x00000000; //Clear all bits in FDCR. As this will not be covering use of fault detect, this register is cleared.
JuanBorra 0:702e0e56ae11 56
JuanBorra 0:702e0e56ae11 57 //Configure LCD_PENn - Pin Enable Register, controls which of the possible LCD pins are used
JuanBorra 0:702e0e56ae11 58 //LCD->PEN[0] contains bits 0-31, while LCD->PEN[1] contains bits 32-63. For pins >= 32, set in LCD->PEN[1] as LCD_PEN_PEN(Pin#-32)
JuanBorra 0:702e0e56ae11 59 LCD->PEN[0] = LCD_PEN_PEN(1u<<7u) | //LCD_P7
JuanBorra 0:702e0e56ae11 60 LCD_PEN_PEN(1u<<8u) | //LCD_P8
JuanBorra 0:702e0e56ae11 61 LCD_PEN_PEN(1u<<10u)| //LCD_P10
JuanBorra 0:702e0e56ae11 62 LCD_PEN_PEN(1u<<11u)| //LCD_P11
JuanBorra 0:702e0e56ae11 63 LCD_PEN_PEN(1u<<17u)| //LCD_P17
JuanBorra 0:702e0e56ae11 64 LCD_PEN_PEN(1u<<18u)| //LCD_P18
JuanBorra 0:702e0e56ae11 65 LCD_PEN_PEN(1u<<19u); //LCD_P19
JuanBorra 0:702e0e56ae11 66 LCD->PEN[1] = LCD_PEN_PEN(1u<<5u) | //LCD_P37
JuanBorra 0:702e0e56ae11 67 LCD_PEN_PEN(1u<<6u) | //LCD_P38
JuanBorra 0:702e0e56ae11 68 LCD_PEN_PEN(1u<<8u) | //LCD_P40
JuanBorra 0:702e0e56ae11 69 LCD_PEN_PEN(1u<<20u)| //LCD_P52
JuanBorra 0:702e0e56ae11 70 LCD_PEN_PEN(1u<<21u); //LCD_P53
JuanBorra 0:702e0e56ae11 71
JuanBorra 0:702e0e56ae11 72 //Configure LCD_SEG_BPENn - Back Plane Enable Register, controls which pins in LCD->PEN are Back Plane (commons)
JuanBorra 0:702e0e56ae11 73 //LCD->BPEN[0] contains bits 0-31, while LCD->BPEN[1] contains bits 32-63. For pins >= 32, set in LCD->BPEN[1] as LCD_BPEN_BPEN(Pin#-32)
JuanBorra 0:702e0e56ae11 74 LCD->BPEN[0] = LCD_BPEN_BPEN(1u<<18u)| //LCD_P18 COM3
JuanBorra 0:702e0e56ae11 75 LCD_BPEN_BPEN(1u<<19u); //LCD_P19, COM2
JuanBorra 0:702e0e56ae11 76 LCD->BPEN[1] = LCD_BPEN_BPEN(1u<<8u) | //LCD_P40, COM0
JuanBorra 0:702e0e56ae11 77 LCD_BPEN_BPEN(1u<<20u); //LCD_P52, COM1
JuanBorra 0:702e0e56ae11 78
JuanBorra 0:702e0e56ae11 79 //Configure LCD_WFyTOx - Configures 4 Waveform signals, LCD_WF[z] is defined such that x = (z*4) and y = 3 | (z*4)
JuanBorra 0:702e0e56ae11 80 //Where x is the n index value of WFn on the least significant byte (bits 7-0) and y is the n index value of WFn on the most significant byte (bits 31-24)
JuanBorra 0:702e0e56ae11 81
JuanBorra 0:702e0e56ae11 82 //Note that "Disabled" is used for pins that are not set as LCD pins, where "Off" is used for pins that are set as LCD, but are just inactive.
JuanBorra 0:702e0e56ae11 83 LCD->WF[0] = LCD_WF_WF0(0x00) | //WF Pin 0 Disabled
JuanBorra 0:702e0e56ae11 84 LCD_WF_WF1(0x00) | //WF Pin 1 Disabled
JuanBorra 0:702e0e56ae11 85 LCD_WF_WF2(0x00) | //WF Pin 2 Disabled
JuanBorra 0:702e0e56ae11 86 LCD_WF_WF3(0x00) ; //WF Pin 3 Disabled
JuanBorra 0:702e0e56ae11 87 LCD->WF[1] = LCD_WF_WF4(0x00) | //WF Pin 4 Disabled
JuanBorra 0:702e0e56ae11 88 LCD_WF_WF5(0x00) | //WF Pin 5 Disabled
JuanBorra 0:702e0e56ae11 89 LCD_WF_WF6(0x00) | //WF Pin 6 Disabled
JuanBorra 0:702e0e56ae11 90 LCD_WF_WF7(0x00) ; //WF Pin 7 Off
JuanBorra 0:702e0e56ae11 91 LCD->WF[2] = LCD_WF_WF8(0x00) | //WF Pin 8 Off
JuanBorra 0:702e0e56ae11 92 LCD_WF_WF9(0x00) | //WF Pin 9 Disabled
JuanBorra 0:702e0e56ae11 93 LCD_WF_WF10(0x00)| //WF Pin 10 Off
JuanBorra 0:702e0e56ae11 94 LCD_WF_WF11(0x00); //WF Pin 11 Off
JuanBorra 0:702e0e56ae11 95 LCD->WF[3] = LCD_WF_WF12(0x00)| //WF Pin 12 Disabled
JuanBorra 0:702e0e56ae11 96 LCD_WF_WF13(0x00)| //WF Pin 13 Disabled
JuanBorra 0:702e0e56ae11 97 LCD_WF_WF14(0x00)| //WF Pin 14 Disabled
JuanBorra 0:702e0e56ae11 98 LCD_WF_WF15(0x00); //WF Pin 15 Disabled
JuanBorra 0:702e0e56ae11 99 LCD->WF[4] = LCD_WF_WF16(0x00)| //WF Pin 16 Disabled
JuanBorra 0:702e0e56ae11 100 LCD_WF_WF17(0x00)| //WF Pin 17 Off
JuanBorra 0:702e0e56ae11 101 LCD_WF_WF18(0x88)| //WF Pin 18 (COM3) is enabled on Phases D and H
JuanBorra 0:702e0e56ae11 102 LCD_WF_WF19(0x44); //WF Pin 19 (COM2) is enabled on Phases C and G
JuanBorra 0:702e0e56ae11 103 LCD->WF[5] = LCD_WF_WF20(0x00)| //WF Pin 20 Disabled
JuanBorra 0:702e0e56ae11 104 LCD_WF_WF21(0x00)| //WF Pin 21 Disabled
JuanBorra 0:702e0e56ae11 105 LCD_WF_WF22(0x00)| //WF Pin 22 Disabled
JuanBorra 0:702e0e56ae11 106 LCD_WF_WF23(0x00); //WF Pin 23 Disabled
JuanBorra 0:702e0e56ae11 107 LCD->WF[6] = LCD_WF_WF24(0x00)| //WF Pin 24 Disabled
JuanBorra 0:702e0e56ae11 108 LCD_WF_WF25(0x00)| //WF Pin 25 Disabled
JuanBorra 0:702e0e56ae11 109 LCD_WF_WF26(0x00)| //WF Pin 26 Disabled
JuanBorra 0:702e0e56ae11 110 LCD_WF_WF27(0x00); //WF Pin 27 Disabled
JuanBorra 0:702e0e56ae11 111 LCD->WF[7] = LCD_WF_WF28(0x00)| //WF Pin 28 Disabled
JuanBorra 0:702e0e56ae11 112 LCD_WF_WF29(0x00)| //WF Pin 29 Disabled
JuanBorra 0:702e0e56ae11 113 LCD_WF_WF30(0x00)| //WF Pin 30 Disabled
JuanBorra 0:702e0e56ae11 114 LCD_WF_WF31(0x00); //WF Pin 31 Disabled
JuanBorra 0:702e0e56ae11 115 LCD->WF[8] = LCD_WF_WF32(0x00)| //WF Pin 32 Disabled
JuanBorra 0:702e0e56ae11 116 LCD_WF_WF33(0x00)| //WF Pin 33 Disabled
JuanBorra 0:702e0e56ae11 117 LCD_WF_WF34(0x00)| //WF Pin 34 Disabled
JuanBorra 0:702e0e56ae11 118 LCD_WF_WF35(0x00); //WF Pin 35 Disabled
JuanBorra 0:702e0e56ae11 119 LCD->WF[9] = LCD_WF_WF36(0x00)| //WF Pin 36 Disabled
JuanBorra 0:702e0e56ae11 120 LCD_WF_WF37(0x00)| //WF Pin 37 Off
JuanBorra 0:702e0e56ae11 121 LCD_WF_WF38(0x00)| //WF Pin 38 Off
JuanBorra 0:702e0e56ae11 122 LCD_WF_WF39(0x00); //WF Pin 39 Disabled
JuanBorra 0:702e0e56ae11 123 LCD->WF[10] = LCD_WF_WF40(0x11)| //WF Pin 40 (COM0) is enabled on Phases A and E
JuanBorra 0:702e0e56ae11 124 LCD_WF_WF41(0x00)| //WF Pin 41 Disabled
JuanBorra 0:702e0e56ae11 125 LCD_WF_WF42(0x00)| //WF Pin 42 Disabled
JuanBorra 0:702e0e56ae11 126 LCD_WF_WF43(0x00); //WF Pin 43 Disabled
JuanBorra 0:702e0e56ae11 127 LCD->WF[11] = LCD_WF_WF44(0x00)| //WF Pin 44 Disabled
JuanBorra 0:702e0e56ae11 128 LCD_WF_WF45(0x00)| //WF Pin 45 Disabled
JuanBorra 0:702e0e56ae11 129 LCD_WF_WF46(0x00)| //WF Pin 46 Disabled
JuanBorra 0:702e0e56ae11 130 LCD_WF_WF47(0x00); //WF Pin 47 Disabled
JuanBorra 0:702e0e56ae11 131 LCD->WF[12] = LCD_WF_WF48(0x00)| //WF Pin 48 Disabled
JuanBorra 0:702e0e56ae11 132 LCD_WF_WF49(0x00)| //WF Pin 49 Disabled
JuanBorra 0:702e0e56ae11 133 LCD_WF_WF50(0x00)| //WF Pin 50 Disabled
JuanBorra 0:702e0e56ae11 134 LCD_WF_WF51(0x00); //WF Pin 51 Disabled
JuanBorra 0:702e0e56ae11 135 LCD->WF[13] = LCD_WF_WF52(0x22)| //WF Pin 52 (COM1) is enabled on Phases B and F
JuanBorra 0:702e0e56ae11 136 LCD_WF_WF53(0x00)| //WF Pin 53 Off
JuanBorra 0:702e0e56ae11 137 LCD_WF_WF54(0x00)| //WF Pin 54 Disabled
JuanBorra 0:702e0e56ae11 138 LCD_WF_WF55(0x00); //WF Pin 55 Disabled
JuanBorra 0:702e0e56ae11 139 LCD->WF[14] = LCD_WF_WF56(0x00)| //WF Pin 56 Disabled
JuanBorra 0:702e0e56ae11 140 LCD_WF_WF57(0x00)| //WF Pin 57 Disabled
JuanBorra 0:702e0e56ae11 141 LCD_WF_WF58(0x00)| //WF Pin 58 Disabled
JuanBorra 0:702e0e56ae11 142 LCD_WF_WF59(0x00); //WF Pin 59 Disabled
JuanBorra 0:702e0e56ae11 143 LCD->WF[15] = LCD_WF_WF60(0x00)| //WF Pin 60 Disabled
JuanBorra 0:702e0e56ae11 144 LCD_WF_WF61(0x00)| //WF Pin 61 Disabled
JuanBorra 0:702e0e56ae11 145 LCD_WF_WF62(0x00)| //WF Pin 62 Disabled
JuanBorra 0:702e0e56ae11 146 LCD_WF_WF63(0x00); //WF Pin 63 Disabled
JuanBorra 0:702e0e56ae11 147
JuanBorra 0:702e0e56ae11 148 //Disable GCR_PADSAFE and Enable GCR_LCDEN
JuanBorra 0:702e0e56ae11 149 LCD->GCR &= ~LCD_GCR_PADSAFE_MASK; //Clear PADSAFE to unlock LCD pins
JuanBorra 0:702e0e56ae11 150 LCD->GCR |= LCD_GCR_LCDEN_MASK; //Set LCDEN to enable operation of LCD
JuanBorra 0:702e0e56ae11 151 }//End SegLCD_Init
JuanBorra 0:702e0e56ae11 152
JuanBorra 0:702e0e56ae11 153 /******************************************************************/
JuanBorra 0:702e0e56ae11 154 // End Function for Initialization of LCD //
JuanBorra 0:702e0e56ae11 155 /******************************************************************/
JuanBorra 0:702e0e56ae11 156
JuanBorra 0:702e0e56ae11 157 /******************************************************************/
JuanBorra 0:702e0e56ae11 158 // Functions for Manipulation of LCD //
JuanBorra 0:702e0e56ae11 159 /******************************************************************/
JuanBorra 0:702e0e56ae11 160
JuanBorra 0:702e0e56ae11 161 void SegLCD_Set(uint8_t Value,uint8_t Digit){//Sets a value from 0-F to a specified Digit, with 1 being the leftmost, 4 being the rightmost. Will not display error is Value is outside of 0-F, but display will not update
JuanBorra 0:702e0e56ae11 162 int k;
JuanBorra 0:702e0e56ae11 163 if(Digit > 4){
JuanBorra 0:702e0e56ae11 164 SegLCD_DisplayError(0x01);
JuanBorra 0:702e0e56ae11 165 } //Display "Err" if trying to access a digit that does not exist
JuanBorra 0:702e0e56ae11 166 else{
JuanBorra 0:702e0e56ae11 167 if(Value==0x00) {LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_E |LCD_SEG_F); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_A | LCD_SEG_B | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 168 else if(Value==0x01){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_CLEAR); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_B | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 169 else if(Value==0x02){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_E | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_A | LCD_SEG_B);}
JuanBorra 0:702e0e56ae11 170 else if(Value==0x03){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_A | LCD_SEG_B | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 171 else if(Value==0x04){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_F | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_B | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 172 else if(Value==0x05){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_F | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_A | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 173 else if(Value==0x06){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_E | LCD_SEG_F | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_A | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 174 else if(Value==0x07){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_CLEAR); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_A | LCD_SEG_B | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 175 else if(Value==0x08){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_E | LCD_SEG_F | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_A | LCD_SEG_B | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 176 else if(Value==0x09){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_F | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_A | LCD_SEG_B | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 177 else if(Value==0x0A){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_E | LCD_SEG_F | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = (LCD_SEG_A | LCD_SEG_B | LCD_SEG_C);}
JuanBorra 0:702e0e56ae11 178 else if(Value==0x0B){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_E | LCD_SEG_F | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = LCD_SEG_C;}
JuanBorra 0:702e0e56ae11 179 else if(Value==0x0C){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_E | LCD_SEG_F); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = LCD_SEG_A;}
JuanBorra 0:702e0e56ae11 180 else if(Value==0x0D){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_E | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = LCD_SEG_B | LCD_SEG_C;}
JuanBorra 0:702e0e56ae11 181 else if(Value==0x0E){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_D | LCD_SEG_E | LCD_SEG_F | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = LCD_SEG_A;}
JuanBorra 0:702e0e56ae11 182 else if(Value==0x0F){LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-2)]] = (LCD_SEG_E | LCD_SEG_F | LCD_SEG_G); LCD->WF8B[LCD_Frontplane_Pin[((2*Digit)-1)]] = LCD_SEG_A;}
JuanBorra 0:702e0e56ae11 183 }
JuanBorra 0:702e0e56ae11 184 }//End SegLCD_Set
JuanBorra 0:702e0e56ae11 185
JuanBorra 0:702e0e56ae11 186 void SegLCD_DisplayDecimal(uint16_t Value){//Displays a 4 Digit number in decimal
JuanBorra 0:702e0e56ae11 187 if(Value > 9999){
JuanBorra 0:702e0e56ae11 188 SegLCD_DisplayError(0x10); //Display "Err" if value is greater than 4 digits
JuanBorra 0:702e0e56ae11 189 }
JuanBorra 0:702e0e56ae11 190 else{
JuanBorra 0:702e0e56ae11 191 SegLCD_Set(Value/1000,1);
JuanBorra 0:702e0e56ae11 192 SegLCD_Set((Value - (Value/1000)*1000)/100,2);
JuanBorra 0:702e0e56ae11 193 SegLCD_Set((Value - (Value/100)*100)/10,3);
JuanBorra 0:702e0e56ae11 194 SegLCD_Set(Value - (Value/10)*10,4);
JuanBorra 0:702e0e56ae11 195 }
JuanBorra 0:702e0e56ae11 196 }//End SegLCD_Display4Digit
JuanBorra 0:702e0e56ae11 197
JuanBorra 0:702e0e56ae11 198 void SegLCD_DisplayHex(uint16_t Value){ //Displays a 16 bit number in Hex Format
JuanBorra 0:702e0e56ae11 199 SegLCD_Set((Value & 0xF000)>>12, 1);
JuanBorra 0:702e0e56ae11 200 SegLCD_Set((Value & 0x0F00)>>8 , 2);
JuanBorra 0:702e0e56ae11 201 SegLCD_Set((Value & 0x00F0)>>4 , 3);
JuanBorra 0:702e0e56ae11 202 SegLCD_Set((Value & 0x000F)>>0 , 4);
JuanBorra 0:702e0e56ae11 203 }//End SegLCD_DisplayHex
JuanBorra 0:702e0e56ae11 204
JuanBorra 0:702e0e56ae11 205 void SegLCD_DisplayTime(uint8_t Value1, uint8_t Value2){//Displays 2 values separated by a colon
JuanBorra 0:702e0e56ae11 206 if((Value1 > 99) | (Value2 > 99)){
JuanBorra 0:702e0e56ae11 207 SegLCD_DisplayError(0x10); //Display "Err" if either value is greater than 2 digits
JuanBorra 0:702e0e56ae11 208 }
JuanBorra 0:702e0e56ae11 209 else{
JuanBorra 0:702e0e56ae11 210 SegLCD_Set(Value1/10, 1);
JuanBorra 0:702e0e56ae11 211 SegLCD_Set(Value1 % 10, 2);
JuanBorra 0:702e0e56ae11 212 SegLCD_Set(Value2/10, 3);
JuanBorra 0:702e0e56ae11 213 SegLCD_Set(Value2 % 10, 4);
JuanBorra 0:702e0e56ae11 214 SegLCD_Col_On();
JuanBorra 0:702e0e56ae11 215 }
JuanBorra 0:702e0e56ae11 216 }//End SegLCD_DisplayTime
JuanBorra 0:702e0e56ae11 217
JuanBorra 0:702e0e56ae11 218 void SegLCD_DisplayError(uint8_t ErrorNum){//Displays Err# on screen, where # is a value 0-F. If ErrorNum is outside of that range, just displays Err
JuanBorra 0:702e0e56ae11 219 LCD->WF8B[LCD_FRONTPLANE0] = (LCD_SEG_D | LCD_SEG_E | LCD_SEG_F | LCD_SEG_G);
JuanBorra 0:702e0e56ae11 220 LCD->WF8B[LCD_FRONTPLANE1] = (LCD_SEG_A);
JuanBorra 0:702e0e56ae11 221 LCD->WF8B[LCD_FRONTPLANE2] = (LCD_SEG_E | LCD_SEG_G);
JuanBorra 0:702e0e56ae11 222 LCD->WF8B[LCD_FRONTPLANE3] = (LCD_CLEAR);
JuanBorra 0:702e0e56ae11 223 LCD->WF8B[LCD_FRONTPLANE4] = (LCD_SEG_E | LCD_SEG_G);
JuanBorra 0:702e0e56ae11 224 LCD->WF8B[LCD_FRONTPLANE5] = (LCD_CLEAR);
JuanBorra 0:702e0e56ae11 225 if(ErrorNum < 0x10){
JuanBorra 0:702e0e56ae11 226 SegLCD_Set(ErrorNum,4); //Display ErrorNum in digit 4 if within valid range. If not, leave blank.
JuanBorra 0:702e0e56ae11 227 }
JuanBorra 0:702e0e56ae11 228 else{
JuanBorra 0:702e0e56ae11 229 LCD->WF8B[LCD_FRONTPLANE6] = (LCD_CLEAR);
JuanBorra 0:702e0e56ae11 230 LCD->WF8B[LCD_FRONTPLANE7] = (LCD_CLEAR);
JuanBorra 0:702e0e56ae11 231 }
JuanBorra 0:702e0e56ae11 232 }//End SegLCD_DisplayError
JuanBorra 0:702e0e56ae11 233
JuanBorra 0:702e0e56ae11 234 //SegLCD_DP1_On() defined as macro in Seg_LCD.h, Turns on leftmost decimal without disturbing rest of display
JuanBorra 0:702e0e56ae11 235 //SegLCD_DP1_Off() defined as macro in Seg_LCD.h, Turns off leftmost decimal without disturbing rest of display
JuanBorra 0:702e0e56ae11 236 //SegLCD_DP2_On() defined as macro in Seg_LCD.h, Turns on center decimal without disturbing rest of display
JuanBorra 0:702e0e56ae11 237 //SegLCD_DP2_Off() defined as macro in Seg_LCD.h, Turns off center decimal without disturbing rest of display
JuanBorra 0:702e0e56ae11 238 //SegLCD_DP3_On() defined as macro in Seg_LCD.h, Turns on rightmost decimal without disturbing rest of display
JuanBorra 0:702e0e56ae11 239 //SegLCD_DP3_Off() defined as macro in Seg_LCD.h, Turns off rightmost decimal without disturbing rest of display
JuanBorra 0:702e0e56ae11 240 //SegLCD_Col_On() defined as macro in Seg_LCD.h, Turns on colon without disturbing rest of display
JuanBorra 0:702e0e56ae11 241 //SegLCD_Col_Off() defined as macro in Seg_LCD.h, Turns off colon without disturbing rest of display
JuanBorra 0:702e0e56ae11 242
JuanBorra 0:702e0e56ae11 243 /******************************************************************/
JuanBorra 0:702e0e56ae11 244 // End Functions for Manipulation of LCD //
JuanBorra 0:702e0e56ae11 245 /******************************************************************/