Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //*************** .H **************
- class LEDSR2 : ExportStreamListener {
- private:
- void onDcsBiosWrite(unsigned int address, unsigned int value);
- unsigned char pin_;
- unsigned int address_;
- unsigned int mask_;
- unsigned int * SRleds_;
- public:
- LEDSR2(unsigned int address, unsigned int mask, char pin, unsigned int * SRleds);
- };
- //************ .CPP ***********
- LEDSR2::LEDSR2(unsigned int address, unsigned int mask, char pin, unsigned int * SRleds) {
- address_ = address;
- mask_ = mask;
- pin_ = pin;
- SRleds_ = SRleds;
- }
- void LEDSR2::onDcsBiosWrite(unsigned int address, unsigned int value) {
- if (address_ == address) {
- if (value & mask_) {
- bitSet(*SRleds_, pin_);
- } else {
- bitClear(*SRleds_, pin_);
- }
- }
- }
- //*************** .INO SKETCH**************
- [...]
- unsigned int leds =0;
- unsigned int leds2 =0;
- unsigned int leds3 =0;
- /**** Make your changes after this line ****/
- DcsBios::LEDSR2 gunReady(0x1026, 0x8000, 2, &leds);
- DcsBios::LEDSR2 canopyUnlocked(0x10da, 0x0004, 2, &leds2);
- DcsBios::LEDSR2 handleGearWarning(0x1026, 0x4000, 2, &leds3 );
- [...]
- void onDcsBiosWrite(unsigned int address, unsigned int value) {
- if (address == 0xfffe) {
- updateShiftRegister();
- }
- }
- void updateShiftRegister()
- {
- digitalWrite(latchPin, LOW);
- shiftOut(dataPin, clockPin, MSBFIRST, leds);
- shiftOut(dataPin, clockPin, MSBFIRST, leds2);
- shiftOut(dataPin, clockPin, MSBFIRST, leds3);
- digitalWrite(latchPin, HIGH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement