Fixed problem in DeviceSettings::strParam, returned wrong string
[avr-sim.git] / src / CircuitNode.h
blob09e399fe8fe9d45d69abd069ab86bb2585ae3bb6
1 #ifndef AVR_CIRCUITNODE_H
2 #define AVR_CIRCUITNODE_H
4 namespace avr {
6 class CircuitNode {
7 public:
8 CircuitNode(float V = 5.0f, float Z = 1e3f) : V(V), Z(Z) {}
9 virtual ~CircuitNode() {}
11 public:
12 float getVoltage() const { return V; }
13 float getImpendace() const { return Z; }
14 bool getDigital() const { return V > 0.25f; }
16 public:
17 // Digital
18 void toggle();
19 void high();
20 void low();
22 public:
23 // Analog
24 void setVoltage(float V);
25 void setImpedance(float Z);
27 private:
28 float V; // Voltage
29 float Z; // Impedance
32 inline void CircuitNode::toggle() {
33 V = getDigital() ? 0.0f : 5.0f;
36 inline void CircuitNode::high() {
37 V = 5.0f;
40 inline void CircuitNode::low() {
41 V = 0.0f;
46 #endif /*AVR_CIRCUITNODE_H*/