lib for realtimeMM funcs
Fork of realtimeMMLib by
sensor_base.h@1:13301255d95a, 2018-02-15 (annotated)
- Committer:
- GTNicholson
- Date:
- Thu Feb 15 16:35:50 2018 +0000
- Revision:
- 1:13301255d95a
- Parent:
- 0:9f82ee1feae7
v4 lib
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 | 1:13301255d95a | 110 | class sensor_max6675 //: public sensor_base |
GTNicholson | 1:13301255d95a | 111 | { |
GTNicholson | 1:13301255d95a | 112 | SPI spi; |
GTNicholson | 1:13301255d95a | 113 | DigitalOut ncs; |
GTNicholson | 1:13301255d95a | 114 | |
GTNicholson | 1:13301255d95a | 115 | public: |
GTNicholson | 1:13301255d95a | 116 | |
GTNicholson | 1:13301255d95a | 117 | int sensor_id; |
GTNicholson | 1:13301255d95a | 118 | int sensor_type; |
GTNicholson | 1:13301255d95a | 119 | bool enabled; |
GTNicholson | 1:13301255d95a | 120 | |
GTNicholson | 1:13301255d95a | 121 | //sensor_max6675(); |
GTNicholson | 1:13301255d95a | 122 | //sensor_max6675(PinName _cs, PinName _so, PinName _sck, PinName _ncs); |
GTNicholson | 1:13301255d95a | 123 | sensor_max6675(SPI _spi, PinName _ncs); |
GTNicholson | 1:13301255d95a | 124 | ~sensor_max6675(); |
GTNicholson | 1:13301255d95a | 125 | void select(); |
GTNicholson | 1:13301255d95a | 126 | void deselect(); |
GTNicholson | 1:13301255d95a | 127 | float read_temp(); |
GTNicholson | 1:13301255d95a | 128 | |
GTNicholson | 1:13301255d95a | 129 | virtual char * read_data(); |
GTNicholson | 1:13301255d95a | 130 | char data_sample[50]; |
GTNicholson | 1:13301255d95a | 131 | |
GTNicholson | 1:13301255d95a | 132 | private: |
GTNicholson | 1:13301255d95a | 133 | //PinName _CS_pin; |
GTNicholson | 1:13301255d95a | 134 | //PinName _SO_pin; |
GTNicholson | 1:13301255d95a | 135 | //PinName _SCK_pin; |
GTNicholson | 1:13301255d95a | 136 | int _units; |
GTNicholson | 1:13301255d95a | 137 | float _error; |
GTNicholson | 1:13301255d95a | 138 | |
GTNicholson | 1:13301255d95a | 139 | }; |
GTNicholson | 0:9f82ee1feae7 | 140 | |
GTNicholson | 0:9f82ee1feae7 | 141 | /* |
GTNicholson | 0:9f82ee1feae7 | 142 | class Counter { |
GTNicholson | 0:9f82ee1feae7 | 143 | public: |
GTNicholson | 0:9f82ee1feae7 | 144 | Counter(PinName pin); |
GTNicholson | 0:9f82ee1feae7 | 145 | void increment(); |
GTNicholson | 0:9f82ee1feae7 | 146 | int read(); |
GTNicholson | 0:9f82ee1feae7 | 147 | private: |
GTNicholson | 0:9f82ee1feae7 | 148 | InterruptIn _interrupt; |
GTNicholson | 0:9f82ee1feae7 | 149 | volatile int _count; |
GTNicholson | 0:9f82ee1feae7 | 150 | }; |
GTNicholson | 0:9f82ee1feae7 | 151 | |
GTNicholson | 0:9f82ee1feae7 | 152 | */ |