Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
mur4ik18 committed Aug 4, 2023
1 parent aa8da34 commit a5caa59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
30 changes: 14 additions & 16 deletions examples/1dig_7seg_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,22 @@ int main(void) {
_delay_ms(1000);
}

uint8_t infinity[] = {
0b00000001,
0b00000011,
0b10000010,
0b10100000,
0b00110000,
0b00010100,
0b10000100,
0b11000000,
}
// show infinity
while (1) {
setByte(dataPin, clockPin, latchPin, 0b00000001);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b00000011);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b10000010);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b10100000);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b00110000);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b00010100);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b10000100);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b11000000);
_delay_ms(50);
for (uint8_t j = 0; j <= len(infinity); j++) {
setByte(dataPin, clockPin, latchPin, infinity[j]);
_delay_ms(50);
}
}
}
return 1;
Expand Down
2 changes: 0 additions & 2 deletions lib/dig_7seg_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

void setNumber(uint8_t dataPin, uint8_t clockPin, uint8_t latchPin, uint8_t figure) {
turn(latchPin, OFF);
//shiftOut(dataPin, clockPin, digitToByte + figure);
shiftOut(dataPin, clockPin, digitToByte[figure]);
turn(latchPin, ON);
}

void setByte(uint8_t dataPin, uint8_t clockPin, uint8_t latchPin, uint8_t byte) {
turn(latchPin, OFF);
//shiftOut(dataPin, clockPin, digitToByte + figure);
shiftOut(dataPin, clockPin, byte);
turn(latchPin, ON);
}

0 comments on commit a5caa59

Please sign in to comment.