Advertisement
Guest User

Untitled

a guest
Feb 19th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. /* Example code for Peggy 2.0, using the Peggy2 library
  2.  
  3. Designed to be automatically generated!
  4.  
  5. Copyright (c) 2011 Windell H Oskay. All right reserved.
  6.  
  7. This example wrapper is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Lesser General Public
  9. License as published by the Free Software Foundation; either
  10. version 2.1 of the License, or (at your option) any later version.
  11.  
  12. This software is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Lesser General Public License for more details.
  16.  
  17. You should have received a copy of the GNU Lesser General Public
  18. License along with this software; if not, write to the Free Software
  19. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21.  
  22. #include <Peggy2.h>
  23. #include <avr/pgmspace.h>
  24.  
  25.  
  26. Peggy2 frame; // Make a frame buffer object, called frame
  27. unsigned long timeLast;
  28. int frameNumber;
  29. unsigned int ai; // array Index
  30. unsigned int frameDuration;
  31.  
  32. uint8_t salt = 0;
  33. int8_t refreshSalt[] = {
  34. 0,-1,2,0,1,-2};
  35.  
  36. unsigned int frames = 12;
  37.  
  38. prog_uint32_t datastore[] PROGMEM = {
  39. 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 ,
  40. 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 ,
  41. 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 0 , 0 , 0 , 0 , 0 ,
  42. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  43. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  44. 0 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 ,
  45. 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 ,
  46. 16777214 , 16777214 , 16777214 , 16777214 , 0 , 0 , 0 , 0 , 0 , 0 ,
  47. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  48. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  49. 4 , 14 , 31 , 62 , 124 , 248 , 496 , 992 , 1984 , 3968 ,
  50. 7936 , 15872 , 31744 , 63488 , 126976 , 253952 , 507904 , 1015808 , 2031616 , 4063232 ,
  51. 8126464 , 16252928 , 32505856 , 14680064 , 4194304 , 0 , 0 , 0 , 0 , 0 ,
  52. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  53. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  54. 33554431 , 33554431 , 33554431 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 ,
  55. 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 ,
  56. 29360135 , 29360135 , 33554431 , 33554431 , 33554431 , 0 , 0 , 0 , 0 , 0 ,
  57. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  58. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  59. 4194308 , 14680078 , 32505887 , 16252990 , 8126588 , 4063480 , 2032112 , 1016800 , 509888 , 257920 ,
  60. 130816 , 65024 , 31744 , 65024 , 130816 , 257920 , 509888 , 1016800 , 2032112 , 4063480 ,
  61. 8126588 , 16252990 , 32505887 , 14680078 , 4194308 , 0 , 0 , 0 , 0 , 0 ,
  62. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  63. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  64. 4194308 , 14680078 , 32505887 , 16252990 , 8126588 , 4063480 , 2032112 , 1016800 , 509888 , 257920 ,
  65. 130816 , 65024 , 31744 , 31744 , 31744 , 31744 , 31744 , 31744 , 31744 , 31744 ,
  66. 31744 , 31744 , 31744 , 31744 , 31744 , 0 , 0 , 0 , 0 , 0 ,
  67. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
  68. 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
  69. };
  70. prog_uint16_t timestore[] PROGMEM = {
  71. 700, 700, 700, 700, 700, 700, 700, 700, 700, 700,
  72. 700, 700
  73. };
  74.  
  75.  
  76.  
  77. void setup() // run once, when the sketch starts
  78. {
  79.  
  80. // Serial.begin(9600); // For Optional time reporting
  81.  
  82. frame.HardwareInit(); // Call this once to init the hardware.
  83. // (Only needed once, even if you've got lots of frames.)
  84.  
  85. timeLast = 0;
  86. frameNumber = -1;
  87. ai = 0;
  88. frameDuration = 0;
  89. }
  90.  
  91. void loop() // run over and over again
  92. {
  93.  
  94. if (( millis() - timeLast) > frameDuration)
  95. {
  96. timeLast = timeLast + frameDuration ;
  97. frameNumber++; // Go to next frame
  98.  
  99. if (frameNumber == frames)
  100. {
  101. frameNumber = 0;
  102. ai = 0;
  103. }
  104. frameDuration = pgm_read_word(&timestore[frameNumber]); // Find new duration
  105.  
  106. uint8_t y = 0;
  107.  
  108. while (y < 25) {
  109. frame.WriteRow( y, pgm_read_dword(&datastore[ai]));
  110. y++;
  111. ai++;
  112. }
  113.  
  114. }
  115.  
  116.  
  117. // unsigned long timetemp = millis(); // Optional time reporting
  118.  
  119. frame.RefreshAll(12 + refreshSalt[salt]); //Draw frame buffer n times
  120.  
  121. // Serial.println(millis() - timetemp); // Optional time reporting
  122.  
  123. salt++;
  124. if (salt > 5)
  125. salt = 0;
  126.  
  127. // Typical refresh timing: 100 cycles: 84 ms
  128. // Typical refresh timing: 23 cycles: 19-21 ms
  129. // Typical refresh timing: 20 cycles: 16-18 ms
  130. // Typical refresh timing: 12 cycles: 10 ms
  131.  
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement