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.
Dependencies: EthernetInterfacePlusHostname RdWebServer mbed-rtos mbed
Diff: EffectSnake.h
- Revision:
- 0:887096209439
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/EffectSnake.h Tue Aug 18 16:03:29 2015 +0000
@@ -0,0 +1,68 @@
+// Snake transition effect
+#include "Effect.h"
+#include "colourconverters.h"
+
+class EffectSnake : public virtual Effect
+{
+ private:
+ int snakeLen;
+ int snakeHead;
+ int snakeDir;
+ ledstrip* pLedStrip;
+ RgbColor curColour;
+
+ public:
+ EffectSnake(ledstrip* pleds) : Effect(), curColour(0,0,0)
+ {
+ snakeLen = 10;
+ snakeHead = 0;
+ snakeDir = 0;
+ pLedStrip = pleds;
+ }
+
+ virtual char* GetName()
+ {
+ return "snake";
+ }
+
+ virtual void Init(char* argStr)
+ {
+ return;
+ snakeLen = 0;
+ snakeHead = 0;
+ snakeDir = 0;
+ pLedStrip->Clear();
+ pLedStrip->ShowLeds();
+ curColour = RgbColor(60,60,0);
+ }
+
+ virtual void NextGen()
+ {
+ return;
+ pLedStrip->Clear();
+ pLedStrip->Fill(snakeHead,snakeLen,curColour.r, curColour.g, curColour.b);
+ pLedStrip->ShowLeds();
+ if (snakeDir == 0)
+ {
+ snakeHead++;
+ if (snakeHead > pLedStrip->GetNumLeds() - snakeLen)
+ snakeDir = 1;
+ }
+ else
+ {
+ snakeHead--;
+ if (snakeHead <= 0)
+ {
+ snakeHead = 0;
+ snakeDir = 0;
+ }
+ }
+ }
+
+ virtual void Stop()
+ {
+ return;
+ pLedStrip->Clear();
+ pLedStrip->ShowLeds();
+ }
+};