Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Average.h>
- #define WAIT_FOR_KEYBOARD 1
- int xMax = 16;
- int yMax = 16;
- int spread = 1;
- int startX = 0;
- int startY = 0;
- int stopX = (yMax * spread) - 1;
- int stopY = (yMax * spread) - 1;
- int A = (stopX - startX);
- int B = (stopY - startY);
- int C1 = 0;
- int C2 = 450;
- const int refArraySize = 32;
- const int refArray[refArraySize] = { 285, 285, 285, 270, 240, 210, 180, 165, 165, 165, 165, 180, 210, 240, 270, 285, 150, 165, 165, 165, 165, 150, 120, 90, 60, 45, 45, 45, 45, 60, 90, 120 };
- int C = 0;
- int start_color = 0;
- int end_color = 255;
- int color = 0;
- int previousAveHeading = 0;
- int previousHeading = 0;
- int shiftX = 0;
- int shiftY = 0;
- void setup()
- {
- if (WAIT_FOR_KEYBOARD) {
- Serial.begin(9600);
- // Wait for serial to initalize.
- while (!Serial) {}
- Serial.println("Strike any key to start...");
- // Wait for the next keystroke.
- while (!Serial.available()) {}
- // Clear the serial buffer.
- Serial.read();
- }
- }
- Average<float> ave(100);
- long totalTime = 0;
- boolean benchLoop = true;
- int j = 0;
- void loop()
- {
- while(benchLoop){
- long startTime = micros();
- ShowGradient();
- long endTime = micros();
- totalTime = endTime - startTime;
- ave.push(totalTime);
- j++;
- if(j >= 100){
- benchLoop = false;
- }
- }
- Serial.println(ave.mean());
- delay(5000000);
- }
- void ShowGradient() {
- for(int shiftX = 0; shiftX < (stopX * 4 * spread) ; shiftX++){
- for (int i = 0; i < refArraySize; i++){
- C = refArray[i] + (15 * shiftX);
- if (C > C2){
- C = C2 - (C - C2);
- }
- if (C < C1){
- C = C1 - (C - C1);
- }
- color = map(C,C1,C2,start_color,end_color);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement