Dependents: nhk2018_throwing02 nhk_2018_undercarry_test08 nhk_2018_undercarry_test09 nhk_2018_undercarry_test10 ... more
Fork of TCS3200 by
TCS3200.h@3:62492ac23077, 2018-03-28 (annotated)
- Committer:
- kenken0721
- Date:
- Wed Mar 28 06:49:19 2018 +0000
- Revision:
- 3:62492ac23077
- Parent:
- 2:78984c66a877
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
grantphillips | 0:b98e768bc655 | 1 | |
grantphillips | 0:b98e768bc655 | 2 | #ifndef TCS3200_H |
grantphillips | 0:b98e768bc655 | 3 | #define TCS3200_H |
grantphillips | 0:b98e768bc655 | 4 | |
grantphillips | 0:b98e768bc655 | 5 | #include "mbed.h" |
grantphillips | 0:b98e768bc655 | 6 | |
kenken0721 | 3:62492ac23077 | 7 | #define RED 40 |
kenken0721 | 3:62492ac23077 | 8 | #define GREEN 41 |
kenken0721 | 3:62492ac23077 | 9 | #define BLUE 42 |
kenken0721 | 3:62492ac23077 | 10 | #define CLEAR 43 |
kenken0721 | 2:78984c66a877 | 11 | |
grantphillips | 0:b98e768bc655 | 12 | class TCS3200 { |
kenken0721 | 1:40b638b93be8 | 13 | public: |
grantphillips | 0:b98e768bc655 | 14 | /** Create a TCS3200 object connected to the specified pins. |
grantphillips | 0:b98e768bc655 | 15 | * @param S0 Frequency scaling output pin S0 |
grantphillips | 0:b98e768bc655 | 16 | * @param S1 Frequency scaling output pin S1 |
grantphillips | 0:b98e768bc655 | 17 | * @param S2 Photo diode selection output pin S2 |
grantphillips | 0:b98e768bc655 | 18 | * @param S3 Photo diode selection output pin S3 |
grantphillips | 0:b98e768bc655 | 19 | * @param OUT Frequency input pin |
grantphillips | 0:b98e768bc655 | 20 | */ |
kenken0721 | 1:40b638b93be8 | 21 | TCS3200(PinName S2, PinName S3, PinName OUT); |
grantphillips | 0:b98e768bc655 | 22 | |
grantphillips | 0:b98e768bc655 | 23 | /** Reads the output signal's HIGH pulse for RED. |
grantphillips | 0:b98e768bc655 | 24 | * @param |
grantphillips | 0:b98e768bc655 | 25 | * None |
grantphillips | 0:b98e768bc655 | 26 | * @return |
grantphillips | 0:b98e768bc655 | 27 | * Duration as nanoseconds (ns). |
grantphillips | 0:b98e768bc655 | 28 | */ |
grantphillips | 0:b98e768bc655 | 29 | long ReadRed(); |
grantphillips | 0:b98e768bc655 | 30 | |
grantphillips | 0:b98e768bc655 | 31 | /** Reads the output signal's HIGH pulse for GREEN. |
grantphillips | 0:b98e768bc655 | 32 | * @param |
grantphillips | 0:b98e768bc655 | 33 | * None |
grantphillips | 0:b98e768bc655 | 34 | * @return |
grantphillips | 0:b98e768bc655 | 35 | * Duration as nanoseconds (ns). |
grantphillips | 0:b98e768bc655 | 36 | */ |
grantphillips | 0:b98e768bc655 | 37 | long ReadGreen(); |
grantphillips | 0:b98e768bc655 | 38 | |
grantphillips | 0:b98e768bc655 | 39 | /** Reads the output signal's HIGH pulse for BLUE. |
grantphillips | 0:b98e768bc655 | 40 | * @param |
grantphillips | 0:b98e768bc655 | 41 | * None |
grantphillips | 0:b98e768bc655 | 42 | * @return |
grantphillips | 0:b98e768bc655 | 43 | * Duration as nanoseconds (ns). |
grantphillips | 0:b98e768bc655 | 44 | */ |
grantphillips | 0:b98e768bc655 | 45 | long ReadBlue(); |
grantphillips | 0:b98e768bc655 | 46 | |
grantphillips | 0:b98e768bc655 | 47 | /** Reads the output signal's HIGH pulse for CLEAR. |
grantphillips | 0:b98e768bc655 | 48 | * @param |
grantphillips | 0:b98e768bc655 | 49 | * None |
grantphillips | 0:b98e768bc655 | 50 | * @return |
grantphillips | 0:b98e768bc655 | 51 | * Duration as nanoseconds (ns). |
grantphillips | 0:b98e768bc655 | 52 | */ |
grantphillips | 0:b98e768bc655 | 53 | long ReadClear(); |
grantphillips | 0:b98e768bc655 | 54 | |
grantphillips | 0:b98e768bc655 | 55 | /** Sets the mode of operation. |
grantphillips | 0:b98e768bc655 | 56 | * @param |
grantphillips | 0:b98e768bc655 | 57 | * mode POWERDOWN, SCALE_2 (2% scaling), SCALE_20 (20% scaling), SCALE_100 (100% scaling). |
grantphillips | 0:b98e768bc655 | 58 | * @return |
grantphillips | 0:b98e768bc655 | 59 | * None |
grantphillips | 0:b98e768bc655 | 60 | */ |
grantphillips | 0:b98e768bc655 | 61 | |
grantphillips | 0:b98e768bc655 | 62 | private: |
grantphillips | 0:b98e768bc655 | 63 | DigitalOut mS2; |
grantphillips | 0:b98e768bc655 | 64 | DigitalOut mS3; |
grantphillips | 0:b98e768bc655 | 65 | InterruptIn signal; |
grantphillips | 0:b98e768bc655 | 66 | Timer timer; |
kenken0721 | 2:78984c66a877 | 67 | Ticker ticker; |
kenken0721 | 2:78984c66a877 | 68 | int coler; |
grantphillips | 0:b98e768bc655 | 69 | long pulsewidth; |
kenken0721 | 2:78984c66a877 | 70 | long red_pulsewidth; |
kenken0721 | 2:78984c66a877 | 71 | long green_pulsewidth; |
kenken0721 | 2:78984c66a877 | 72 | long blue_pulsewidth; |
kenken0721 | 2:78984c66a877 | 73 | long clear_pulsewidth; |
grantphillips | 0:b98e768bc655 | 74 | void HighTrigger(); |
grantphillips | 0:b98e768bc655 | 75 | void LowTrigger(); |
kenken0721 | 2:78984c66a877 | 76 | void fliper(); |
grantphillips | 0:b98e768bc655 | 77 | }; |
grantphillips | 0:b98e768bc655 | 78 | |
grantphillips | 0:b98e768bc655 | 79 | #endif |