Simple single-color 8x8x8 LED Cube with AVRs
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

AFrame.java 2.3KB

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