summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/widgets/sevensegment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clients/tde/src/widgets/sevensegment.cpp')
-rwxr-xr-x[-rw-r--r--]clients/tde/src/widgets/sevensegment.cpp78
1 files changed, 53 insertions, 25 deletions
diff --git a/clients/tde/src/widgets/sevensegment.cpp b/clients/tde/src/widgets/sevensegment.cpp
index d7e7a07..f6d8469 100644..100755
--- a/clients/tde/src/widgets/sevensegment.cpp
+++ b/clients/tde/src/widgets/sevensegment.cpp
@@ -77,16 +77,23 @@ void Display7Segment::setLitSegments(unsigned char segs) {
unsigned char Display7Segment::segmentsForNumericDigit(unsigned char val, bool dp) {
unsigned char ret = 0;
- if (val == 0) { ret = 0x7e; }
- else if (val == 1) { ret = 0x30; }
- else if (val == 2) { ret = 0x6d; }
- else if (val == 3) { ret = 0x79; }
- else if (val == 4) { ret = 0x33; }
- else if (val == 5) { ret = 0x5b; }
- else if (val == 6) { ret = 0x5f; }
- else if (val == 7) { ret = 0x70; }
- else if (val == 8) { ret = 0x7f; }
- else if (val == 9) { ret = 0x73; }
+ if (val == 0x0) { ret = 0x7e; }
+ else if (val == 0x1) { ret = 0x30; }
+ else if (val == 0x2) { ret = 0x6d; }
+ else if (val == 0x3) { ret = 0x79; }
+ else if (val == 0x4) { ret = 0x33; }
+ else if (val == 0x5) { ret = 0x5b; }
+ else if (val == 0x6) { ret = 0x5f; }
+ else if (val == 0x7) { ret = 0x70; }
+ else if (val == 0x8) { ret = 0x7f; }
+ else if (val == 0x9) { ret = 0x73; }
+ else if (val == 0xa) { ret = 0x7d; }
+ else if (val == 0xb) { ret = 0x1f; }
+ else if (val == 0xc) { ret = 0x0d; }
+ else if (val == 0xd) { ret = 0x3d; }
+ else if (val == 0xe) { ret = 0x4f; }
+ else if (val == 0xf) { ret = 0x67; }
+ else if (val == 0x10) { ret = 0x01; } // "-"
if (dp) {
ret |= 0x80;
@@ -496,7 +503,9 @@ void Display7SegmentArray::init() {
unsigned int i;
// Set up grid layout
- m_layout = new TQGridLayout(this, 1, m_numberOfDigits);
+ m_layout = new TQGridLayout(this, 1, m_numberOfDigits + 1);
+ TQSpacerItem *spacerItem = new TQSpacerItem(0, 0, TQSizePolicy::Expanding, TQSizePolicy::Fixed);
+ m_layout->addItem(spacerItem);
m_layout->setAutoAdd(true);
// Allocate display array
@@ -528,7 +537,7 @@ void Display7SegmentArray::init() {
m_displayArray[i]->setFrameStyle(TQFrame::NoFrame);
}
setBackgroundColor(TQt::black);
- setFrameStyle(TQFrame::Box | TQFrame::Raised);
+ setFrameStyle(TQFrame::Box);
#endif
}
@@ -575,6 +584,9 @@ void Display7SegmentArray::setValue(double value, int maxDecimalLength, bool for
bool dp;
unsigned int i;
TQString displayString = TQString("%1").arg(value);
+ if (displayString.contains("e")) {
+ maxDecimalLength = -1;
+ }
if (maxDecimalLength >= 0) {
int decPos = displayString.find(".");
if (decPos >= 0) {
@@ -598,23 +610,39 @@ void Display7SegmentArray::setValue(double value, int maxDecimalLength, bool for
if (displayString.contains(".")) {
current_char--;
}
- for (i=0; i < m_numberOfDigits; i++) {
- if (current_char < 0) {
- m_displayArray[i]->setLitSegments(0x0);
+ if (displayString.length() > m_numberOfDigits) {
+ // String is too large to display on the specified number of 7-segment digits
+ for (i=0; i < m_numberOfDigits; i++) {
+ m_displayArray[i]->setLitSegments(Display7Segment::segmentsForNumericDigit(0x10, false));
}
- else {
- dp = false;
- if (current_char < (displayString.length() - 1)) {
- if (displayString[current_char + 1] == '.') {
- dp = true;
- }
+ }
+ else {
+ for (i=0; i < m_numberOfDigits; i++) {
+ if (current_char < 0) {
+ m_displayArray[i]->setLitSegments(0x0);
}
- if (displayString[current_char] == '.') {
- current_char++;
+ else {
+ dp = false;
+ if (current_char < (displayString.length() - 1)) {
+ if (displayString[current_char + 1] == '.') {
+ dp = true;
+ }
+ }
+ if (displayString[current_char] == '.') {
+ current_char++;
+ }
+ if (displayString[current_char] == '-') {
+ m_displayArray[i]->setLitSegments(Display7Segment::segmentsForNumericDigit(0x10, dp));
+ }
+ else if (displayString[current_char] == 'e') {
+ m_displayArray[i]->setLitSegments(Display7Segment::segmentsForNumericDigit(0xe, dp));
+ }
+ else {
+ m_displayArray[i]->setLitSegments(Display7Segment::segmentsForNumericDigit(TQString(displayString[current_char]).toInt(NULL, 10), dp));
+ }
}
- m_displayArray[i]->setLitSegments(Display7Segment::segmentsForNumericDigit(TQString(displayString[current_char]).toInt(NULL, 10), dp));
+ current_char++;
}
- current_char++;
}
}