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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. data = d;
  60. }
  61. /**
  62. * Gets tha Data of this Frame
  63. *
  64. * @return 64 bytes that contain data (8 bits / LEDs per byte)
  65. */
  66. public short[] getData() {
  67. return data;
  68. }
  69. /**
  70. * Sets the Duration of this Frame
  71. *
  72. * @param t Duration of frame in (( t * (1/24) ) + (1/24)) seconds
  73. */
  74. public void setTime(short t) {
  75. duration = t;
  76. }
  77. /**
  78. * Gets the Duration of this Frame
  79. *
  80. * @return Duration of frame.
  81. * @see AFrame#setTime(short) setTime()
  82. */
  83. public short getTime() {
  84. return duration;
  85. }
  86. /**
  87. * Gets the Data of the Layer you want
  88. *
  89. * @param i Number of Layer you want
  90. * @return 8 byte array with data of selected layer
  91. */
  92. public short[] getLayer(int i) {
  93. return Arrays.copyOfRange(data, (i * 8), (i * 8) + 8);
  94. }
  95. }