witekio
Fork of TCS3200 by
Diff: TCS3200.cpp
- Revision:
- 1:e1c8062f2970
- Parent:
- 0:b98e768bc655
--- a/TCS3200.cpp Tue May 03 20:45:40 2016 +0000 +++ b/TCS3200.cpp Thu Jan 11 09:28:04 2018 +0000 @@ -10,48 +10,57 @@ signal.fall(this,&TCS3200::LowTrigger); } -long TCS3200::ReadRed() { +long TCS3200::ReadRed() +{ mS2=0; mS3=0; wait(0.1); //Delay to allow frequency to change for the set color return(pulsewidth); } -long TCS3200::ReadGreen() { +long TCS3200::ReadGreen() +{ mS2=1; mS3=1; wait(0.1); //Delay to allow frequency to change for the set color return(pulsewidth); } -long TCS3200::ReadBlue() { +long TCS3200::ReadBlue() +{ mS2=0; mS3=1; wait(0.1); //Delay to allow frequency to change for the set color return(pulsewidth); } -long TCS3200::ReadClear() { +long TCS3200::ReadClear() +{ mS2=1; mS3=0; wait(0.1); //Delay to allow frequency to change for the set color return(pulsewidth); } -void TCS3200::SetMode(TCS3200Mode mode) { - if(mode == POWERDOWN) { //TCS3200 in power down +void TCS3200::SetMode(TCS3200Mode mode) + { + if(mode == POWERDOWN) + { //TCS3200 in power down mS0 = 0; mS1 = 0; } - else if(mode == SCALE_2) { //Output frequency at 2% scaling + else if(mode == SCALE_2) + { //Output frequency at 2% scaling mS0 = 0; mS1 = 1; } - else if(mode == SCALE_20) { //Output frequency at 20% scaling + else if(mode == SCALE_20) + { //Output frequency at 20% scaling mS0 = 1; mS1 = 0; } - else if(mode == SCALE_100) { //Output frequency at 100% scaling + else if(mode == SCALE_100) + { //Output frequency at 100% scaling mS0 = 1; mS1 = 1; } @@ -61,11 +70,13 @@ } } -void TCS3200::HighTrigger() { +void TCS3200::HighTrigger() +{ timer.start(); } -void TCS3200::LowTrigger() { +void TCS3200::LowTrigger() +{ timer.stop(); pulsewidth = timer.read_us(); timer.reset();