Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LedStrip_test by
Diff: main.cpp
- Revision:
- 9:01eb82c2a01b
- Parent:
- 8:77fd54b4864c
diff -r 77fd54b4864c -r 01eb82c2a01b main.cpp --- a/main.cpp Sat Sep 21 20:49:33 2013 +0000 +++ b/main.cpp Sat Sep 21 22:14:57 2013 +0000 @@ -353,6 +353,52 @@ } g_watchdog_impl; + +const int CycleColorsRegions[][2] = { + {5, 10}, + {15, 10}, + {35, 5}, + {40, 50} +}; + +class CycleColors : public Schedulable +{ +public: + CycleColors(bool fast, int cycle_count) : fast_(fast), cycle_count_(cycle_count), current_cycle_(0) { + fade_out_time_ = fast_ ? 256 : 512; + supervisor.RegisterProgram(this); + } + + virtual void Run() { + strip[100] = RED; + strip_changed = true; + + int next_cycle_start_time = global_tick; + for (int region = 0; region < sizeof(CycleColorsRegions) / sizeof(CycleColorsRegions[0]); ++region) { + int region_start_led = CycleColorsRegions[region][0]; + int region_length = CycleColorsRegions[region][1]; + int region_from_color = google_colors[(current_cycle_ + region) % sizeof(google_colors)]; + int region_to_color = google_colors[(region_from_color + 1) % sizeof(google_colors)]; + new FadeFillRegion(next_cycle_start_time, region_start_led, region_length, region_from_color, region_to_color, fast_, NULL); + } + + ++current_cycle_; + if (current_cycle_ < cycle_count_) { + time_ += fade_out_time_; + Schedule(this); + } else { + supervisor.CurrentProgramDone(); + } + } + +private: + bool fast_; + int fade_out_time_; + int cycle_count_; + int current_cycle_; +}; + + class MultiDropBucketFillProgram : public Schedulable { public: @@ -440,7 +486,8 @@ init_board(); g_watchdog = &g_watchdog_impl; - MultiDropBucketFillProgram multi_drop; + // MultiDropBucketFillProgram multi_drop; + CycleColors cycle_colors(false, 5); supervisor.ScheduleProgram();