Simple single-color 8x8x8 LED Cube with AVRs
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

AFrame.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 given time.
  26. * @author Thomas Buck
  27. * @author Max Nuding
  28. * @author Felix Bäder
  29. * @version 1.0
  30. */
  31. public class AFrame {
  32. private short[] data = new short[64];
  33. private short duration = 1;
  34. private String name = "Frame";
  35. /**
  36. * Gets the Name of this Frame
  37. * @return Name of the Frame
  38. */
  39. public String getName() {
  40. return name;
  41. }
  42. /**
  43. * Sets the Name of this Frame
  44. * @param s New Name
  45. */
  46. public void setName(String s) {
  47. name = s;
  48. }
  49. /**
  50. * Sets the Data of this Frame
  51. * @param d 64 bytes that contain data (8 bit per byte, so 8 LEDs)
  52. */
  53. public void setData(short[] d) {
  54. data = d;
  55. }
  56. /**
  57. * Gets tha Data of this Frame
  58. * @return 64 bytes that contain data (8 bits / LEDs per byte)
  59. */
  60. public short[] getData() {
  61. return data;
  62. }
  63. /**
  64. * Sets the Duration of this Frame
  65. * @param t Duration of frame in (( t * (1/24) ) + (1/24)) seconds
  66. */
  67. public void setTime(short t) {
  68. duration = t;
  69. }
  70. /**
  71. * Gets the Duration of this Frame
  72. * @return Duration of frame.
  73. * @see AFrame#setTime(short) setTime()
  74. */
  75. public short getTime() {
  76. return duration;
  77. }
  78. /**
  79. * Gets the Data of the Layer you want
  80. * @param i Number of Layer you want
  81. * @return 8 byte array with data of selected layer
  82. */
  83. public short[] getLayer(int i) {
  84. return Arrays.copyOfRange(data, (i * 8), (i * 8) + 8);
  85. }
  86. }