Simple single-color 8x8x8 LED Cube with AVRs
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

cubeWorker.java 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * cubeWorker.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. /*
  24. * This class handles one animation file. This file can contain
  25. * many animations, but has to be only 1Mbit in size (128*1024 Byte).
  26. */
  27. public class cubeWorker {
  28. // --------------------
  29. // Definitions
  30. // --------------------
  31. final int UP = 0;
  32. final int DOWN = 1;
  33. // --------------------
  34. // Fields
  35. // --------------------
  36. // --------------------
  37. cubeWorker() {
  38. }
  39. // --------------------
  40. // Misc. Methods
  41. // --------------------
  42. // Returns how many animations are defined
  43. public int numOfAnimations() {
  44. return 3;
  45. }
  46. // Returns how many frames are in the current animation
  47. public int numOfFrames() {
  48. return 3;
  49. }
  50. // Tells how many Frames you can add until you reached 1 Mbit...
  51. public int framesRemaining() {
  52. return 0;
  53. }
  54. // --------------------
  55. // Animation Specific
  56. // --------------------
  57. // Selects an animation on wich the animation specific functions operate
  58. // Returns -1 if it does not exist, else its index
  59. public int selectAnimation(int index) {
  60. System.out.println("Animation " + index + " selected.");
  61. return index;
  62. }
  63. // Adds a new Animation
  64. // Returns id if ok, -1 if error or not enough space for
  65. // another animation
  66. public int addAnimation() {
  67. return -1;
  68. }
  69. // Removes an animation
  70. public void removeAnimation() {
  71. }
  72. public String getAnimationName() {
  73. return "TestAnim";
  74. }
  75. public void setAnimationName(String s) {
  76. }
  77. public void moveAnimation(int dir) {
  78. if (dir == UP){
  79. //animation moved up
  80. } else if (dir == DOWN){
  81. //animation moved down
  82. }
  83. }
  84. // --------------------
  85. // Frame Specific
  86. // --------------------
  87. // Selects an animation on wich the frame specific functions operate
  88. // Returns -1 if it does not exist, else its index
  89. public int selectFrame(int index) {
  90. System.out.println("Frame " + index + " selected.");
  91. return index;
  92. }
  93. public String getFrameName() {
  94. return "Test";
  95. }
  96. public void setFrameName(String s) {
  97. }
  98. // Adds a Frame to the current animation.
  99. // Returns id if okay, -1 if error
  100. public int addFrame() {
  101. return -1;
  102. }
  103. // Remove the frame
  104. public void removeFrame() {
  105. }
  106. // Returns array with 64 bytes with led values
  107. public byte[] getFrame() {
  108. return null;
  109. }
  110. public void setFrame(byte[] data) {
  111. }
  112. public void moveFrame(int dir){
  113. if (dir == UP){
  114. // frame moved up
  115. } else if (dir == DOWN){
  116. // frame moved down
  117. }
  118. }
  119. // --------------------
  120. // File Specific
  121. // --------------------
  122. // Loads an animation file into this object
  123. public int loadState(String path) {
  124. return 0;
  125. }
  126. // Saves the state of this object in an animation file
  127. public int saveState(String path) {
  128. System.out.println("Saving to " + path);
  129. return 0;
  130. }
  131. // Returns true if last saved state != current state
  132. public boolean changedStateSinceSave() {
  133. return true;
  134. }
  135. // --------------------
  136. // File Specific
  137. // --------------------
  138. public byte[] getLayer(int index){
  139. return null;
  140. }
  141. // --------------------
  142. // Serial Port Specific
  143. // --------------------
  144. // sends state of object to led cube
  145. public int uploadState(String port) {
  146. return 0;
  147. }
  148. // loads all state from the cube into this object
  149. public int downloadState(String port) {
  150. return 0;
  151. }
  152. public String[] getSerialPorts() {
  153. String[] sPorts = { "Select serial port..." }; // Has to be the first entry
  154. return sPorts;
  155. }
  156. // --------------------
  157. }