daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Apr 17th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * ColourSensorTCS34725.h
  3. *
  4. * Created: 08/10/2017 12:15:44
  5. * Author: SoftwareEngineer
  6. */
  7.  
  8.  
  9. #ifndef __COLOUR_SENSOR_TCS34725_H__
  10. #define __COLOUR_SENSOR_TCS34725_H__
  11.  
  12. #include "Exception.h"
  13. #include "Exceptions.h"
  14. #include "IGetMessages.h"
  15. #include "TCS34725.h"
  16. #include "ISendRGBC.h"
  17. #include "IColourSensor.h"
  18. #include "ISubscriptionRunner.h"
  19. #include "ILed.h"
  20. class  ColourSensorTCS34725:public IColourSensor, public ISubscriptionRunnable
  21. {
  22.     //variables
  23.     public:
  24.     typedef enum State{LightingUp, Running, Stopping};
  25.     protected:
  26.     private:
  27.     State state;
  28.     bool fast;
  29.     TCS34725* tcs34725;
  30.     ISendRGBC* iSendRGBC;
  31.     ILed* iLedSource;
  32.     ISubscriptionRunner* iSubscriptionRunner;
  33.     //functions
  34.     public:
  35.     ColourSensorTCS34725(TCS34725* tcs34725, ISendRGBC* iSendRGBC, ISubscriptionRunner* iSubscriptionRunner, ILed* iLedSource);
  36.     ~ColourSensorTCS34725();
  37.     void Run();
  38.     void SetFastMode(bool fast, bool& successful, Exceptions&exceptions);
  39.     RGBC GetRGBC(bool& successful , Exceptions& exceptions);
  40.     protected:
  41.     private:
  42.     void _Run();
  43. }; //Outputs
  44.  
  45. #endif
  46.  
  47.  
  48.  
  49.  
  50.  
  51. /*
  52. * Endpoint.cpp
  53. *
  54. * Created: 08/10/2017 12:15:44
  55. * Author: SoftwareEngineer
  56. */
  57.  
  58.  
  59. #include "ColourSensorTCS34725.h"
  60. #include "Exceptions.h"
  61. #include "RGBC.h"
  62. #include "UART.h"
  63. #include <string.h>
  64. ColourSensorTCS34725::ColourSensorTCS34725(TCS34725* tcs34725, ISendRGBC* iSendRGBC, ISubscriptionRunner* iSubscriptionRunner, ILed* iLedSource): tcs34725(tcs34725), iSendRGBC(iSendRGBC), iSubscriptionRunner(iSubscriptionRunner), iLedSource(iLedSource), state(Running){
  65.    
  66. }
  67. void ColourSensorTCS34725::SetFastMode (bool fast, bool& successful, Exceptions& exceptions){
  68.     this->fast=fast;
  69.     if(fast)
  70.     {
  71.         iSubscriptionRunner->Subscribe(this);
  72.     }
  73.     else
  74.     {
  75.         iSubscriptionRunner->Unsubscribe(this);
  76.     }
  77. }
  78.  
  79. void ColourSensorTCS34725::Run(){
  80.  
  81. }
  82. void ColourSensorTCS34725::_Run(){
  83.     bool successful = true;
  84.     Exceptions exceptions;
  85.     RGBC rgbc = tcs34725->GetRGBC(successful, exceptions);
  86.     if(successful)
  87.     {
  88.         iSendRGBC->SendRGBC(rgbc);
  89.     }
  90. }
  91. RGBC ColourSensorTCS34725::GetRGBC(bool& successful , Exceptions& exceptions){
  92.     return tcs34725->GetRGBC(successful, exceptions);
  93. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top