lib for realtimeMM funcs
Fork of realtimeMMLib by
sensor_base.h@0:9f82ee1feae7, 2017-10-02 (annotated)
- Committer:
- GTNicholson
- Date:
- Mon Oct 02 11:18:47 2017 +0000
- Revision:
- 0:9f82ee1feae7
- Child:
- 1:13301255d95a
Initial Publish Version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GTNicholson | 0:9f82ee1feae7 | 1 | #pragma once |
GTNicholson | 0:9f82ee1feae7 | 2 | #include "mbed.h" |
GTNicholson | 0:9f82ee1feae7 | 3 | #include "qeihw.h" |
GTNicholson | 0:9f82ee1feae7 | 4 | #include "QEIx4.h" |
GTNicholson | 0:9f82ee1feae7 | 5 | #include <cstdint> |
GTNicholson | 0:9f82ee1feae7 | 6 | |
GTNicholson | 0:9f82ee1feae7 | 7 | |
GTNicholson | 0:9f82ee1feae7 | 8 | |
GTNicholson | 0:9f82ee1feae7 | 9 | class sensor_base |
GTNicholson | 0:9f82ee1feae7 | 10 | { |
GTNicholson | 0:9f82ee1feae7 | 11 | public: |
GTNicholson | 0:9f82ee1feae7 | 12 | sensor_base(); |
GTNicholson | 0:9f82ee1feae7 | 13 | ~sensor_base(); |
GTNicholson | 0:9f82ee1feae7 | 14 | int sensor_id; |
GTNicholson | 0:9f82ee1feae7 | 15 | int sensor_type; |
GTNicholson | 0:9f82ee1feae7 | 16 | char data_sample[50]; |
GTNicholson | 0:9f82ee1feae7 | 17 | virtual char * read_data(); |
GTNicholson | 0:9f82ee1feae7 | 18 | bool enabled; |
GTNicholson | 0:9f82ee1feae7 | 19 | }; |
GTNicholson | 0:9f82ee1feae7 | 20 | |
GTNicholson | 0:9f82ee1feae7 | 21 | |
GTNicholson | 0:9f82ee1feae7 | 22 | class sensor_onoff : public sensor_base |
GTNicholson | 0:9f82ee1feae7 | 23 | { |
GTNicholson | 0:9f82ee1feae7 | 24 | public: |
GTNicholson | 0:9f82ee1feae7 | 25 | //sensor_base(); |
GTNicholson | 0:9f82ee1feae7 | 26 | sensor_onoff(); |
GTNicholson | 0:9f82ee1feae7 | 27 | sensor_onoff(PinName); |
GTNicholson | 0:9f82ee1feae7 | 28 | ~sensor_onoff(); |
GTNicholson | 0:9f82ee1feae7 | 29 | DigitalIn din; |
GTNicholson | 0:9f82ee1feae7 | 30 | virtual char * read_data(); |
GTNicholson | 0:9f82ee1feae7 | 31 | char data_sample[50]; |
GTNicholson | 0:9f82ee1feae7 | 32 | }; |
GTNicholson | 0:9f82ee1feae7 | 33 | |
GTNicholson | 0:9f82ee1feae7 | 34 | |
GTNicholson | 0:9f82ee1feae7 | 35 | class sensor_vin : public sensor_base |
GTNicholson | 0:9f82ee1feae7 | 36 | { |
GTNicholson | 0:9f82ee1feae7 | 37 | public: |
GTNicholson | 0:9f82ee1feae7 | 38 | sensor_vin(); |
GTNicholson | 0:9f82ee1feae7 | 39 | sensor_vin(PinName); |
GTNicholson | 0:9f82ee1feae7 | 40 | ~sensor_vin(); |
GTNicholson | 0:9f82ee1feae7 | 41 | AnalogIn ain; |
GTNicholson | 0:9f82ee1feae7 | 42 | virtual char * read_data(); |
GTNicholson | 0:9f82ee1feae7 | 43 | char data_sample[50]; |
GTNicholson | 0:9f82ee1feae7 | 44 | }; |
GTNicholson | 0:9f82ee1feae7 | 45 | |
GTNicholson | 0:9f82ee1feae7 | 46 | class sensor_pulse : public sensor_base |
GTNicholson | 0:9f82ee1feae7 | 47 | { |
GTNicholson | 0:9f82ee1feae7 | 48 | public: |
GTNicholson | 0:9f82ee1feae7 | 49 | sensor_pulse(); |
GTNicholson | 0:9f82ee1feae7 | 50 | sensor_pulse(PinName); |
GTNicholson | 0:9f82ee1feae7 | 51 | ~sensor_pulse(); |
GTNicholson | 0:9f82ee1feae7 | 52 | void ISR1(); |
GTNicholson | 0:9f82ee1feae7 | 53 | void reset(); |
GTNicholson | 0:9f82ee1feae7 | 54 | float frequency; |
GTNicholson | 0:9f82ee1feae7 | 55 | float uptime; |
GTNicholson | 0:9f82ee1feae7 | 56 | float firstpulsetime; |
GTNicholson | 0:9f82ee1feae7 | 57 | float lastpulsetime; |
GTNicholson | 0:9f82ee1feae7 | 58 | float elapsedtime; |
GTNicholson | 0:9f82ee1feae7 | 59 | virtual char * read_data(); |
GTNicholson | 0:9f82ee1feae7 | 60 | char data_sample[50]; |
GTNicholson | 0:9f82ee1feae7 | 61 | InterruptIn IntIn; |
GTNicholson | 0:9f82ee1feae7 | 62 | int pulsecount; |
GTNicholson | 0:9f82ee1feae7 | 63 | private: |
GTNicholson | 0:9f82ee1feae7 | 64 | Timer t; |
GTNicholson | 0:9f82ee1feae7 | 65 | float period; |
GTNicholson | 0:9f82ee1feae7 | 66 | }; |
GTNicholson | 0:9f82ee1feae7 | 67 | |
GTNicholson | 0:9f82ee1feae7 | 68 | /* |
GTNicholson | 0:9f82ee1feae7 | 69 | class sensor_pulse : public sensor_base |
GTNicholson | 0:9f82ee1feae7 | 70 | { |
GTNicholson | 0:9f82ee1feae7 | 71 | public: |
GTNicholson | 0:9f82ee1feae7 | 72 | sensor_pulse(); |
GTNicholson | 0:9f82ee1feae7 | 73 | sensor_pulse(PinName); |
GTNicholson | 0:9f82ee1feae7 | 74 | ~sensor_pulse(); |
GTNicholson | 0:9f82ee1feae7 | 75 | AnalogIn IntIn; |
GTNicholson | 0:9f82ee1feae7 | 76 | //void ISR1(); |
GTNicholson | 0:9f82ee1feae7 | 77 | //int pulsecount; |
GTNicholson | 0:9f82ee1feae7 | 78 | //float uptime; |
GTNicholson | 0:9f82ee1feae7 | 79 | //float firstpulsetime; |
GTNicholson | 0:9f82ee1feae7 | 80 | //float lastpulsetime; |
GTNicholson | 0:9f82ee1feae7 | 81 | virtual char * read_data(); |
GTNicholson | 0:9f82ee1feae7 | 82 | char data_sample[50]; |
GTNicholson | 0:9f82ee1feae7 | 83 | //private: |
GTNicholson | 0:9f82ee1feae7 | 84 | //InterruptIn IntIn; |
GTNicholson | 0:9f82ee1feae7 | 85 | }; |
GTNicholson | 0:9f82ee1feae7 | 86 | |
GTNicholson | 0:9f82ee1feae7 | 87 | */ |
GTNicholson | 0:9f82ee1feae7 | 88 | |
GTNicholson | 0:9f82ee1feae7 | 89 | class sensor_qeihw : public sensor_base |
GTNicholson | 0:9f82ee1feae7 | 90 | { |
GTNicholson | 0:9f82ee1feae7 | 91 | public: |
GTNicholson | 0:9f82ee1feae7 | 92 | sensor_qeihw(); |
GTNicholson | 0:9f82ee1feae7 | 93 | ~sensor_qeihw(); |
GTNicholson | 0:9f82ee1feae7 | 94 | QEIHW qei; |
GTNicholson | 0:9f82ee1feae7 | 95 | virtual char * read_data(); |
GTNicholson | 0:9f82ee1feae7 | 96 | char data_sample[50]; |
GTNicholson | 0:9f82ee1feae7 | 97 | }; |
GTNicholson | 0:9f82ee1feae7 | 98 | |
GTNicholson | 0:9f82ee1feae7 | 99 | class sensor_qeix4 : public sensor_base |
GTNicholson | 0:9f82ee1feae7 | 100 | { |
GTNicholson | 0:9f82ee1feae7 | 101 | public: |
GTNicholson | 0:9f82ee1feae7 | 102 | sensor_qeix4(); |
GTNicholson | 0:9f82ee1feae7 | 103 | ~sensor_qeix4(); |
GTNicholson | 0:9f82ee1feae7 | 104 | QEIx4 qei; |
GTNicholson | 0:9f82ee1feae7 | 105 | void poll(); |
GTNicholson | 0:9f82ee1feae7 | 106 | virtual char * read_data(); |
GTNicholson | 0:9f82ee1feae7 | 107 | char data_sample[50]; |
GTNicholson | 0:9f82ee1feae7 | 108 | }; |
GTNicholson | 0:9f82ee1feae7 | 109 | |
GTNicholson | 0:9f82ee1feae7 | 110 | |
GTNicholson | 0:9f82ee1feae7 | 111 | /* |
GTNicholson | 0:9f82ee1feae7 | 112 | class Counter { |
GTNicholson | 0:9f82ee1feae7 | 113 | public: |
GTNicholson | 0:9f82ee1feae7 | 114 | Counter(PinName pin); |
GTNicholson | 0:9f82ee1feae7 | 115 | void increment(); |
GTNicholson | 0:9f82ee1feae7 | 116 | int read(); |
GTNicholson | 0:9f82ee1feae7 | 117 | private: |
GTNicholson | 0:9f82ee1feae7 | 118 | InterruptIn _interrupt; |
GTNicholson | 0:9f82ee1feae7 | 119 | volatile int _count; |
GTNicholson | 0:9f82ee1feae7 | 120 | }; |
GTNicholson | 0:9f82ee1feae7 | 121 | |
GTNicholson | 0:9f82ee1feae7 | 122 | */ |