Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #ifndef __DCSBIOS_LEDS_74HC595_H
  2. #define __DCSBIOS_LEDS_74HC595_H
  3.  
  4. #include "Arduino.h"
  5. #include "ExportStreamListener.h"
  6. #include <ShiftRegister74HC595.h>
  7.  
  8. namespace DcsBios {
  9.  
  10.     class LED74HC595 : public Int16Buffer {
  11.         private:
  12.             ShiftRegister74HC595<1> &sr;
  13.             unsigned int            mask;
  14.             unsigned char           pin;
  15.         public:
  16.             LED74HC595(unsigned int address, unsigned int mask, unsigned char pin, ShiftRegister74HC595<1> &sr) : Int16Buffer(address), mask(mask), pin(pin), sr(sr) {
  17.                 sr.setNoUpdate(pin, LOW);
  18.             }
  19.             virtual void loop() {
  20.                 if (hasUpdatedData()) {
  21.                     if (getData() & mask) {
  22.                         sr.setNoUpdate(pin, HIGH);
  23.                     } else {
  24.                         sr.setNoUpdate(pin, LOW);
  25.                     }
  26.                 }
  27.             }
  28.     };
  29.  
  30. }
  31.  
  32. #endif