Skip to content

Commit

Permalink
Merge pull request Simsso#4 from alecamaracm
Browse files Browse the repository at this point in the history
Setting register pin without updating & updating method
  • Loading branch information
Simsso authored Jan 17, 2018
2 parents 0bfaaad + ef4092c commit cd8903b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ShiftRegister74HC595.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,20 @@ uint8_t * ShiftRegister74HC595::getAll() {


void ShiftRegister74HC595::set(int pin, uint8_t value) {
setNoUpdate(pin, value);
updateRegisters();
}

void ShiftRegister74HC595::updateRegisters()
{
setAll(_digitalValues);
}

void ShiftRegister74HC595::setNoUpdate(int pin, uint8_t value) {
if (value == 1)
_digitalValues[pin / 8] |= 1 << (pin % 8);
else
_digitalValues[pin / 8] &= ~(1 << (pin % 8));

setAll(_digitalValues);
}


Expand Down
2 changes: 2 additions & 0 deletions ShiftRegister74HC595.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class ShiftRegister74HC595
void setAll(uint8_t * digitalValues);
uint8_t * getAll();
void set(int pin, uint8_t value);
void setNoUpdate(int pin, uint8_t value);
void updateRegisters();
void setAllLow();
void setAllHigh();
uint8_t get(int pin);
Expand Down

0 comments on commit cd8903b

Please sign in to comment.