![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
coursework
Dependencies: USBDevice mbed-rtos mbed
function_generator/signal.h@0:c059d38d6074, 2016-11-28 (annotated)
- Committer:
- riyood
- Date:
- Mon Nov 28 10:32:43 2016 +0000
- Revision:
- 0:c059d38d6074
the coursework;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
riyood | 0:c059d38d6074 | 1 | #ifndef _SIGNAL_H |
riyood | 0:c059d38d6074 | 2 | #define _SIGNAL_H |
riyood | 0:c059d38d6074 | 3 | |
riyood | 0:c059d38d6074 | 4 | enum SIGNAL_TYPE { |
riyood | 0:c059d38d6074 | 5 | NONE, |
riyood | 0:c059d38d6074 | 6 | CONSTANT, |
riyood | 0:c059d38d6074 | 7 | SINE, |
riyood | 0:c059d38d6074 | 8 | SQUARE |
riyood | 0:c059d38d6074 | 9 | }; |
riyood | 0:c059d38d6074 | 10 | |
riyood | 0:c059d38d6074 | 11 | class Signal { |
riyood | 0:c059d38d6074 | 12 | public: |
riyood | 0:c059d38d6074 | 13 | enum SIGNAL_TYPE type; |
riyood | 0:c059d38d6074 | 14 | float amplitude; |
riyood | 0:c059d38d6074 | 15 | float frequency; |
riyood | 0:c059d38d6074 | 16 | |
riyood | 0:c059d38d6074 | 17 | Signal(enum SIGNAL_TYPE type = NONE, |
riyood | 0:c059d38d6074 | 18 | float amplitude = 2, |
riyood | 0:c059d38d6074 | 19 | float frequency = 10) : |
riyood | 0:c059d38d6074 | 20 | type(type), amplitude(amplitude), frequency(frequency) {} |
riyood | 0:c059d38d6074 | 21 | |
riyood | 0:c059d38d6074 | 22 | void set(enum SIGNAL_TYPE _type, float _amplitude, float _frequency) { |
riyood | 0:c059d38d6074 | 23 | type=_type; amplitude=_amplitude; frequency=_frequency; } |
riyood | 0:c059d38d6074 | 24 | |
riyood | 0:c059d38d6074 | 25 | bool operator== (const Signal & s) { |
riyood | 0:c059d38d6074 | 26 | return type==s.type && amplitude==s.amplitude && frequency==s.frequency; } |
riyood | 0:c059d38d6074 | 27 | |
riyood | 0:c059d38d6074 | 28 | const char* c_str (char* str); |
riyood | 0:c059d38d6074 | 29 | }; |
riyood | 0:c059d38d6074 | 30 | |
riyood | 0:c059d38d6074 | 31 | #endif |
riyood | 0:c059d38d6074 | 32 |