Homework 1.1 turn off decimal on display
Fork of SLCD by
Diff: SLCD.cpp
- Revision:
- 7:0e084b33d730
- Parent:
- 6:f4773221794b
- Child:
- 10:ef2b3b7f1b01
--- a/SLCD.cpp Fri Mar 14 15:13:15 2014 +0000 +++ b/SLCD.cpp Fri Mar 14 15:22:09 2014 +0000 @@ -153,6 +153,15 @@ void SLCD::Write_Char (char lbValue) { + if (CharPosition >= _CHARNUM) + CharPosition = 0; + + if (lbValue == '.') { + // Use built-in dot + DP(CharPosition-1, true); + return; + } + uint8_t char_val; uint8_t temp; uint8_t *lbpLCDWF; @@ -160,8 +169,6 @@ uint16_t arrayOffset; uint8_t position; - if (CharPosition >= _CHARNUM) - CharPosition = 0; lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; /* only ascii character if value not writeable write as @ */ if (lbValue>='a' && lbValue<='z') { @@ -199,6 +206,11 @@ LCD->GCR |= LCD_GCR_RVTRIM(lbContrast); } +void SLCD::clear() +{ + All_Segments(0); +} + void SLCD::All_Segments (int mode) { uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE; @@ -215,37 +227,44 @@ } } -void SLCD::DP1 (int mode) +void SLCD::DP(int pos, bool on) { uint8_t *lbpLCDWF; + int tableLoc; + switch (pos) { + case 0: + tableLoc = 1; + break; + case 1: + tableLoc = 3; + break; + case 2: + tableLoc = 5; + break; + default: + return; // Bad position + } lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; - if (mode==1) { - lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]|=1; + if (on) { + lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[tableLoc]]|=1; } else { - lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]&=~1; + lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[tableLoc]]&=~1; } } +void SLCD::DP1 (int mode) +{ + DP(0, mode==1); +} + void SLCD::DP2 (int mode) { - uint8_t *lbpLCDWF; - lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; - if (mode==1) { - lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]|=1; - } else { - lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]&=~1; - } + DP(1, mode==1); } void SLCD::DP3 (int mode) { - uint8_t *lbpLCDWF; - lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; - if (mode==1) { - lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]|=1; - } else { - lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]&=~1; - } + DP(2, mode==1); } void SLCD::Colon (int mode)