Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Example code for Peggy 2.0, using the Peggy2 library
- Designed to be automatically generated!
- Copyright (c) 2011 Windell H Oskay. All right reserved.
- This example wrapper is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
- #include <Peggy2.h>
- #include <avr/pgmspace.h>
- Peggy2 frame; // Make a frame buffer object, called frame
- unsigned long timeLast;
- int frameNumber;
- unsigned int ai; // array Index
- unsigned int frameDuration;
- uint8_t salt = 0;
- int8_t refreshSalt[] = {
- 0,-1,2,0,1,-2};
- unsigned int frames = 12;
- prog_uint32_t datastore[] PROGMEM = {
- 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 ,
- 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 15978300 ,
- 15978300 , 15978300 , 15978300 , 15978300 , 15978300 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 ,
- 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 , 16777214 ,
- 16777214 , 16777214 , 16777214 , 16777214 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 4 , 14 , 31 , 62 , 124 , 248 , 496 , 992 , 1984 , 3968 ,
- 7936 , 15872 , 31744 , 63488 , 126976 , 253952 , 507904 , 1015808 , 2031616 , 4063232 ,
- 8126464 , 16252928 , 32505856 , 14680064 , 4194304 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 33554431 , 33554431 , 33554431 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 ,
- 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 , 29360135 ,
- 29360135 , 29360135 , 33554431 , 33554431 , 33554431 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 4194308 , 14680078 , 32505887 , 16252990 , 8126588 , 4063480 , 2032112 , 1016800 , 509888 , 257920 ,
- 130816 , 65024 , 31744 , 65024 , 130816 , 257920 , 509888 , 1016800 , 2032112 , 4063480 ,
- 8126588 , 16252990 , 32505887 , 14680078 , 4194308 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 4194308 , 14680078 , 32505887 , 16252990 , 8126588 , 4063480 , 2032112 , 1016800 , 509888 , 257920 ,
- 130816 , 65024 , 31744 , 31744 , 31744 , 31744 , 31744 , 31744 , 31744 , 31744 ,
- 31744 , 31744 , 31744 , 31744 , 31744 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
- };
- prog_uint16_t timestore[] PROGMEM = {
- 700, 700, 700, 700, 700, 700, 700, 700, 700, 700,
- 700, 700
- };
- void setup() // run once, when the sketch starts
- {
- // Serial.begin(9600); // For Optional time reporting
- frame.HardwareInit(); // Call this once to init the hardware.
- // (Only needed once, even if you've got lots of frames.)
- timeLast = 0;
- frameNumber = -1;
- ai = 0;
- frameDuration = 0;
- }
- void loop() // run over and over again
- {
- if (( millis() - timeLast) > frameDuration)
- {
- timeLast = timeLast + frameDuration ;
- frameNumber++; // Go to next frame
- if (frameNumber == frames)
- {
- frameNumber = 0;
- ai = 0;
- }
- frameDuration = pgm_read_word(×tore[frameNumber]); // Find new duration
- uint8_t y = 0;
- while (y < 25) {
- frame.WriteRow( y, pgm_read_dword(&datastore[ai]));
- y++;
- ai++;
- }
- }
- // unsigned long timetemp = millis(); // Optional time reporting
- frame.RefreshAll(12 + refreshSalt[salt]); //Draw frame buffer n times
- // Serial.println(millis() - timetemp); // Optional time reporting
- salt++;
- if (salt > 5)
- salt = 0;
- // Typical refresh timing: 100 cycles: 84 ms
- // Typical refresh timing: 23 cycles: 19-21 ms
- // Typical refresh timing: 20 cycles: 16-18 ms
- // Typical refresh timing: 12 cycles: 10 ms
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement