Simple single-color 8x8x8 LED Cube with AVRs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lookUp.c 811B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <stdio.h>
  2. int flip(int d) {
  3. int n;
  4. int converted = 0;
  5. for (n = 0; n < 8; n++) {
  6. if (d & (1 << (7 - n))) {
  7. converted |= (1 << n);
  8. }
  9. }
  10. return converted;
  11. }
  12. int flipAdjacent(int d) {
  13. int n;
  14. int converted = 0;
  15. for (n = 0; n < 7; n+= 2) {
  16. if (d & (1 << n)) {
  17. converted |= (1 << (n + 1));
  18. } else {
  19. converted &= ~(1 << (n + 1));
  20. }
  21. if (d & (1 << (n + 1))) {
  22. converted |= (1 << n);
  23. } else {
  24. converted &= ~(1 << n);
  25. }
  26. }
  27. return converted;
  28. }
  29. void main() {
  30. int byte;
  31. int converted;
  32. printf("penis = {");
  33. for (byte = 0; byte < 256; byte++) {
  34. converted = flip(byte);
  35. converted = flipAdjacent(converted);
  36. printf(" %d", converted);
  37. if (((byte % 10) == 0) && (byte > 0)) {
  38. printf(",\n");
  39. } else if (byte < 255) {
  40. printf(", ");
  41. }
  42. }
  43. printf(" }\n");
  44. }