summaryrefslogtreecommitdiffstats
path: root/clients/tde/src
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-10-14 13:44:56 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-10-14 13:44:56 -0500
commit7997af3f4f6d8ca680e381cb1bee4ebe3b82e175 (patch)
treef88cd6c4fa54fdf8c9d76506b9cf03cfa0142763 /clients/tde/src
parente9bed7d3af54c11f1174b73daa8d8b838448b27f (diff)
downloadulab-7997af3f4f6d8ca680e381cb1bee4ebe3b82e175.tar.gz
ulab-7997af3f4f6d8ca680e381cb1bee4ebe3b82e175.zip
Fix 7-segment LED display and add sample driver for the same
Diffstat (limited to 'clients/tde/src')
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp51
-rw-r--r--clients/tde/src/part/fpgaview/part.h11
2 files changed, 33 insertions, 29 deletions
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp
index c312c66..dc5c9d9 100644
--- a/clients/tde/src/part/fpgaview/part.cpp
+++ b/clients/tde/src/part/fpgaview/part.cpp
@@ -140,6 +140,7 @@ FPGA7Segment::~FPGA7Segment() {
void FPGA7Segment::init() {
setFrameStyle(TQFrame::Box | TQFrame::Raised);
+ prevSegments = 0;
val = 0;
smallPoint = TRUE;
setSegmentStyle(Flat);
@@ -147,34 +148,32 @@ void FPGA7Segment::init() {
m_currentSegments = (char*)malloc(sizeof(char)*9);
m_prevSegments[0] = 99;
m_currentSegments[0] = 99;
- d = 0;
setSizePolicy(TQSizePolicy(TQSizePolicy::Minimum, TQSizePolicy::Minimum));
}
-void FPGA7Segment::setLitSegments(unsigned int segs) {
+void FPGA7Segment::setLitSegments(unsigned char segs) {
// This produces an array of up to 10 chars, with each char being the number of a lit segment, and the list being terminated with the number 99
// The bit input in segs is active high
// The bit sequence, MSB to LSB, is dp a b c d e f g
// Segment letters are taken from ug130.pdf
- // 0: a
- // 1: f
- // 2: d
- // 3: g
- // 4: e
- // 5: c
- // 6: b
- // 7: dp
-
- int i = 0;
- if (segs & 0x80) { m_currentSegments[i] = 7; i++; }
- if (segs & 0x40) { m_currentSegments[i] = 0; i++; }
- if (segs & 0x20) { m_currentSegments[i] = 6; i++; }
- if (segs & 0x10) { m_currentSegments[i] = 5; i++; }
- if (segs & 0x08) { m_currentSegments[i] = 2; i++; }
- if (segs & 0x04) { m_currentSegments[i] = 4; i++; }
- if (segs & 0x02) { m_currentSegments[i] = 1; i++; }
- if (segs & 0x01) { m_currentSegments[i] = 3; i++; }
- m_currentSegments[i] = 99;
+
+ if (prevSegments != segs) {
+ int i = 0;
+ if (segs & 0x80) { m_currentSegments[i] = 7; i++; }
+ if (segs & 0x40) { m_currentSegments[i] = 0; i++; }
+ if (segs & 0x20) { m_currentSegments[i] = 2; i++; }
+ if (segs & 0x10) { m_currentSegments[i] = 5; i++; }
+ if (segs & 0x08) { m_currentSegments[i] = 6; i++; }
+ if (segs & 0x04) { m_currentSegments[i] = 4; i++; }
+ if (segs & 0x02) { m_currentSegments[i] = 1; i++; }
+ if (segs & 0x01) { m_currentSegments[i] = 3; i++; }
+
+ m_currentSegments[i] = 99;
+
+ update();
+ }
+
+ prevSegments = segs;
}
void FPGA7Segment::drawContents( TQPainter *p )
@@ -230,7 +229,7 @@ void FPGA7Segment::drawDigit(const TQPoint &pos, TQPainter &p, int segLen, const
const char erase = 0;
const char draw = 1;
- const char leaveAlone = 2;
+// const char leaveAlone = 2;
segs = m_prevSegments;
for ( nErases=0; segs[nErases] != 99; nErases++ ) {
@@ -242,8 +241,12 @@ void FPGA7Segment::drawDigit(const TQPoint &pos, TQPainter &p, int segLen, const
for(i = 0 ; segs[i] != 99 ; i++) {
for ( j=0; j<nErases; j++ ) {
if ( segs[i] == updates[j][1] ) { // Same segment ?
+// FIXME
+// Always redraw segments for now, as dragging windows in front of the LED display currently erases the occluded portion(s) of the display!
+#if 0
updates[j][0] = leaveAlone; // yes, already on screen
break;
+#endif
}
}
if ( j == nErases ) { // If not already on screen
@@ -584,8 +587,8 @@ K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaviewer, RemoteLab::Factory)
FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&)
: RemoteInstrumentPart( parent, name ), m_base(NULL), m_interfaceMode(BasicInterfaceMode),
m_commHandlerState(0), m_commHandlerMode(0), m_commHandlerNextState(0), m_commHandlerNextMode(0), m_connectionActiveAndValid(false), m_tickerState(0), m_remoteInputModeEnabled(false), m_4bitInputValue(0), m_4bitOutputValue(0),
- m_8bitInputValue(0), m_8bitOutputValue(0), m_16bitInputValue(0), m_16bitOutputValue(0), m_7segDigit3OutputValue(0xffffffff),
- m_7segDigit2OutputValue(0xffffffff), m_7segDigit1OutputValue(0xffffffff), m_7segDigit0OutputValue(0xffffffff),
+ m_8bitInputValue(0), m_8bitOutputValue(0), m_16bitInputValue(0), m_16bitOutputValue(0), m_7segDigit3OutputValue(0xff),
+ m_7segDigit2OutputValue(0xff), m_7segDigit1OutputValue(0xff), m_7segDigit0OutputValue(0xff),
m_batchOutputFile(NULL), m_dataOutputFile(NULL),
m_inputImageViewer(NULL), m_outputImageViewer(NULL)
{
diff --git a/clients/tde/src/part/fpgaview/part.h b/clients/tde/src/part/fpgaview/part.h
index 26e70ec..b49ace2 100644
--- a/clients/tde/src/part/fpgaview/part.h
+++ b/clients/tde/src/part/fpgaview/part.h
@@ -105,7 +105,7 @@ class TQ_EXPORT FPGA7Segment : public TQFrame
SegmentStyle segmentStyle() const;
virtual void setSegmentStyle(SegmentStyle);
- void setLitSegments(unsigned int);
+ void setLitSegments(unsigned char);
TQSize sizeHint() const;
@@ -120,6 +120,7 @@ class TQ_EXPORT FPGA7Segment : public TQFrame
char* m_prevSegments;
char* m_currentSegments;
+ unsigned int prevSegments;
double val;
uint smallPoint : 1;
uint fill : 1;
@@ -231,10 +232,10 @@ namespace RemoteLab
unsigned int m_16bitInputValue;
unsigned int m_16bitOutputValue;
TQCString m_LCDOutputValue;
- unsigned int m_7segDigit3OutputValue;
- unsigned int m_7segDigit2OutputValue;
- unsigned int m_7segDigit1OutputValue;
- unsigned int m_7segDigit0OutputValue;
+ unsigned char m_7segDigit3OutputValue;
+ unsigned char m_7segDigit2OutputValue;
+ unsigned char m_7segDigit1OutputValue;
+ unsigned char m_7segDigit0OutputValue;
UnsignedIntegerList m_batchInputValueList;
UnsignedIntegerList m_batchOutputValueList;