blob: b15762d54e1ece98c5cd46bba20056aa881f9db5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/***************************************************************************
* Copyright (C) 2003-2005 by David Saxton *
* david@bluehaze.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef EC4BITCOUNTER_H
#define EC4BITCOUNTER_H
#include "component.h"
#include "logic.h"
/**
Simple logic counter. 4 Inputs, 4 Outputs.
Outputs (A-D) represent the stored value (0-15).
The inputs are:
@li en - Enable incrementing of value
@li in - Input (trigger high)
@li r - Reset stored value to 0
@li ud - Up/Down increment
@short 4 Bit Binary Counter
@author David Saxton
*/
class BinaryCounter : public CallbackClass, public Component
{
public:
BinaryCounter( ICNDocument *icnDocument, bool newItem, const char *id = 0L );
~BinaryCounter();
virtual bool canFlip() const { return true; }
static Item* construct( ItemDocument *itemDocument, bool newItem, const char *id );
static LibraryItem *libraryItem();
protected:
void inStateChanged( bool state ); // Input
void rStateChanged( bool state ); // Reset
void enStateChanged( bool state ); // Enable
void udStateChanged( bool state ); // Up/Down
void outputValue();
void dataChanged();
void initPins( unsigned numBits );
LogicIn *enLogic, *inLogic, *rLogic, *udLogic;
LogicOut * m_pLogicOut[26];
unsigned m_numBits;
bool b_triggerHigh;
bool b_en; // Enable
bool b_ud; // Up/Down
bool b_oldIn;
bool b_reset;
long m_value;
long m_maxValue;
bool m_bDoneLogicIn;
};
#endif
|