Conversions for the LCD display in FRDM-KL46Z
Dependents: eem202a_display eem202a_resolutedreamer_1
Diff: convert.cpp
- Revision:
- 1:cf83568dc17a
- Parent:
- 0:ca69bce3284f
- Child:
- 2:9467805cb02b
diff -r ca69bce3284f -r cf83568dc17a convert.cpp --- a/convert.cpp Sat Apr 19 08:20:12 2014 +0000 +++ b/convert.cpp Sat Apr 19 17:42:24 2014 +0000 @@ -1,13 +1,13 @@ #include "convert.h" -convert::convert() +Convert::Convert() { this->prepare(); return; } -void convert::prepare(void) +void Convert::prepare(void) { this->blink(-1); this->clear(); @@ -20,7 +20,7 @@ return; } -bool convert::display_digits(unsigned int number, bool negate) +bool Convert::display_digits(unsigned int number, bool negate) { register unsigned short int c1 = ((unsigned int) number / 1000); register unsigned short int c2 = ((unsigned int) number / 100) - (c1 * 10); @@ -40,7 +40,7 @@ return false; } -bool convert::display(unsigned int number) +bool Convert::display(unsigned int number) { if (number > 9999) { @@ -59,7 +59,7 @@ return false; } -bool convert::display(int number) +bool Convert::display(int number) { bool negate = (number < 0); if (negate) @@ -85,7 +85,7 @@ } } -bool convert::display(double number) +bool Convert::display(double number) { // >=10000 OVL // >=1000 1234 @@ -94,7 +94,7 @@ this->DP1(false); this->DP2(false); this->DP3(false); - this->display((unsigned int) (number)); + return this->display((unsigned int) (number)); } // >=100 123.4 else if (number >= 100.) @@ -102,7 +102,7 @@ this->DP1(false); this->DP2(false); this->DP3(true); - this->display((unsigned int) (number*10.)); + return this->display((unsigned int) (number*10.)); } // >=10 12.34 else if (number >= 10.) @@ -110,7 +110,7 @@ this->DP1(false); this->DP2(true); this->DP3(false); - this->display((unsigned int) (number*100.)); + return this->display((unsigned int) (number*100.)); } // >=0 1.234 else if (number >= 0.) @@ -118,7 +118,7 @@ this->DP1(true); this->DP2(false); this->DP3(false); - this->display((int) (number*1000.)); + return this->display((int) (number*1000.)); } // <0 // <=-1 -1.23 @@ -128,7 +128,7 @@ this->DP1(false); this->DP2(true); this->DP3(false); - this->display((int) (number*100.)); + return this->display((int) (number*100.)); } // <=-100 -123 else if (number >= -100.) @@ -136,21 +136,33 @@ this->DP1(false); this->DP2(false); this->DP3(true); - this->display((int) (number*10.)); + return this->display((int) (number*10.)); } else { this->DP1(false); this->DP2(false); this->DP3(false); - this->display((int) (number*1.)); + return this->display((int) (number*1.)); }; // <=-1000 -OVL return true; } -bool convert::display(float number) +bool Convert::display(float number) { return display((double) number); } + +bool Convert::display(char text[4]) +{ + this->DP1(false); + this->DP2(false); + this->DP3(false); + this->putc(text[0]); + this->putc(text[1]); + this->putc(text[2]); + this->putc(text[3]); + return false; +}