File indexing completed on 2024-05-05 05:46:05

0001 /***************************************************************************
0002  *   Copyright (C) 2003-2005 by David Saxton                               *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #ifndef ECSEVENSEGMENT_H
0012 #define ECSEVENSEGMENT_H
0013 
0014 #include "component.h"
0015 
0016 class Diode;
0017 class ECNode;
0018 
0019 /**
0020 @short Seven segment display component
0021 @author David Saxton
0022 */
0023 class ECSevenSegment : public Component
0024 {
0025 public:
0026     ECSevenSegment(ICNDocument *icnDocument, bool newItem, const char *id = nullptr);
0027     ~ECSevenSegment() override;
0028 
0029     static Item *construct(ItemDocument *itemDocument, bool newItem, const char *id);
0030     static LibraryItem *libraryItem();
0031 
0032     void stepNonLogic() override;
0033     bool doesStepNonLogic() const override
0034     {
0035         return true;
0036     }
0037     void dataChanged() override;
0038 
0039 private:
0040     void drawShape(QPainter &p) override;
0041 
0042     bool m_bCommonCathode;
0043     double lastUpdatePeriod;
0044     double avg_brightness[8];
0045     uint last_brightness[8];
0046     Diode *m_diodes[8];
0047     ECNode *m_nodes[8];
0048     ECNode *m_nNode;
0049     double r, g, b;
0050 };
0051 
0052 #endif