Add function to shiftout n size numbers instead of just bytes

This commit is contained in:
Daniel Løvbrøtte Olsen 2018-04-05 14:15:52 +02:00 committed by GitHub
parent f771f86e7f
commit fd76bd7de9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@
int toDice(int n);
unsigned long int shift(int* numbers);
void ShiftNOut(unsigned long int value, byte n)
uint8_t dicerolls[DICEN];
@ -53,9 +54,7 @@ void loop() {
dicerolls[4] = random(1, 7);
}
unsigned long int result = shift(dicerolls)
/*shiftOut(result >> 16);
shiftOut(result >> 8);
shiftOut(result);*/
ShiftNOut(result, sizeof(long))
}
}
@ -104,3 +103,10 @@ unsigned long int shift(int* numbers) {
return shiftn; /* End result is a number representing your data outputs for all DICEN */
}
void ShiftNOut(unsigned long int value, byte n) {
n = n/sizeof(byte);
for (byte i = 0; i < n; i++) {
ShiftOut(value >> sizeof(byte)*i)
}
}