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.

AFrame.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * AFrame.java
  3. *
  4. * Copyright 2011 Thomas Buck <xythobuz@me.com>
  5. * Copyright 2011 Max Nuding <max.nuding@gmail.com>
  6. * Copyright 2011 Felix Bäder <baeder.felix@gmail.com>
  7. *
  8. * This file is part of LED-Cube.
  9. *
  10. * LED-Cube is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * LED-Cube is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with LED-Cube. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. import java.util.Arrays;
  24. /**
  25. * The representation of a single frame. Contains the data of all 512 LEDs in a
  26. * given time.
  27. *
  28. * @author Thomas Buck
  29. * @author Max Nuding
  30. * @author Felix Bäder
  31. * @version 1.0
  32. */
  33. public class AFrame {
  34. private short[] data = new short[64];
  35. private short duration = 1;
  36. private String name = "Frame";
  37. /**
  38. * Gets the Name of this Frame
  39. *
  40. * @return Name of the Frame
  41. */
  42. public String getName() {
  43. return name;
  44. }
  45. /**
  46. * Sets the Name of this Frame
  47. *
  48. * @param s New Name
  49. */
  50. public void setName(String s) {
  51. name = s;
  52. }
  53. /**
  54. * Sets the Data of this Frame
  55. *
  56. * @param d 64 bytes that contain data (8 bit per byte, so 8 LEDs)
  57. */
  58. public void setData(short[] d) {
  59. for (int i = 0; i < 64; i++) {
  60. data[i] = d[i];
  61. }
  62. }
  63. /**
  64. * Gets tha Data of this Frame
  65. *
  66. * @return 64 bytes that contain data (8 bits / LEDs per byte)
  67. */
  68. public short[] getData() {
  69. return data;
  70. }
  71. /**
  72. * Sets the Duration of this Frame
  73. *
  74. * @param t Duration of frame in (( t * (1/24) ) + (1/24)) seconds
  75. */
  76. public void setTime(short t) {
  77. duration = t;
  78. }
  79. /**
  80. * Gets the Duration of this Frame
  81. *
  82. * @return Duration of frame.
  83. * @see AFrame#setTime(short) setTime()
  84. */
  85. public short getTime() {
  86. return duration;
  87. }
  88. /**
  89. * Gets the Data of the Layer you want
  90. *
  91. * @param i Number of Layer you want
  92. * @return 8 byte array with data of selected layer
  93. */
  94. public short[] getLayer(int i) {
  95. return Arrays.copyOfRange(data, (i * 8), (i * 8) + 8);
  96. }
  97. }