Julio G / Mbed 2 deprecated LedStrip

Dependencies:   mbed

Fork of LedStrip_test by Balazs Racz

Revision:
3:42efa00ffef4
Parent:
2:590e99f4a313
Child:
4:e3b6f5741d9d
Child:
5:5a2af711d510
--- a/main.cpp	Sat Sep 21 19:10:43 2013 +0000
+++ b/main.cpp	Sat Sep 21 19:39:02 2013 +0000
@@ -1,4 +1,5 @@
 #include <queue>
+#include <algorithm>
 
 #include "mbed.h"
 
@@ -164,19 +165,19 @@
             if (repeat_) {
                 led_ %= length_;
             } else {
-                if (led_ > length_) {
-                    if (next_ && led_ == (length_ + stride_)) {
+                if (led_ >= length_) {
+                    /*if (next_ && led_ == (length_ + stride_)) {
                         next_->time_ = global_tick + 1;
                         Schedule(next_);
-                    }
+                    }*/
                     delete this;
                     return;
                 }
             }
         } else {
-            if (led_ == length_ && drop_ && !repeat_) {
+            if (led_ == (length_ - 1) && drop_ && !repeat_) {
                 if (next_) {
-                    next_->time_ = global_tick + 1;
+                    next_->time_ = global_tick + 257;
                     Schedule(next_);
                 }
                 delete this;
@@ -220,10 +221,10 @@
         //strip[start_led_ + length_] = RED;
         if (length_ > 0) {
             // There's still space in the bucket. Drop a new drop.
-            for (int i = 0; i < drop_size_; ++i) {
+            for (int i = 0; i < min(drop_size_, length_); ++i) {
                 Schedulable* next_drop = NULL;
                 next_drop = this;
-                new RegionWalkingFadeInOut(time_ + (256 * i / drop_size_), i, drop_size_, start_led_, length_ - 1, from_color_, to_color_, true, false, true, next_drop);
+                new RegionWalkingFadeInOut(time_ + (256 * i / drop_size_), i, drop_size_, start_led_, length_, from_color_, to_color_, true, false, true, next_drop);
             }
             length_--;
         } else {
@@ -283,5 +284,7 @@
 
     new DropBucketFill(0, 10, 20, 3, BLACK, BLUE);
 
+    new DropBucketFill(0, 30, 20, 11, BLACK, GREEN);
+
     run_loop();
 }
\ No newline at end of file