Skip to content

Commit

Permalink
+ 2x ScreenSaver (#1)
Browse files Browse the repository at this point in the history
* added Instruction to use own ScreenSaver
* New ScreenSavers
  • Loading branch information
chess9876543210 authored and drayde committed Feb 26, 2018
1 parent 0f0e58b commit 70e2fb9
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 29 deletions.
21 changes: 0 additions & 21 deletions .gitignore

This file was deleted.

28 changes: 28 additions & 0 deletions ScrSvrDotInBowl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "ScreenSaver.h"
#include "iSin.h"

class ScrSvrDotInBowl: public ScreenSaver
{
public:
virtual void Tick(long millis);

private:
iSin isin = iSin();
};
void ScrSvrDotInBowl::Tick(long millis)
{
int pos = map(isin.convert(millis/10),-128,128,1,NUM_LEDS-1);


for (int i = 0; i < NUM_LEDS; i ++)
{
if (i == pos || i + 1 == pos || i - 1 == pos)
{
leds[i] = CRGB::White;
}
else
{
leds[i] = CRGB::Black;
}
}
}
4 changes: 2 additions & 2 deletions ScrSvrPulseFlashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

class ScrSvrPulseFlashes: public ScreenSaver
{
public:
virtual void Tick(long millis);
public:
virtual void Tick(long millis);
};

void ScrSvrPulseFlashes::Tick(long millis)
Expand Down
23 changes: 23 additions & 0 deletions ScrSvrWhiteFlow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "ScreenSaver.h"

class ScrSvrWhiteFlow: public ScreenSaver
{
public:
virtual void Tick(long millis);
};
void ScrSvrWhiteFlow::Tick(long millis)
{
int i;

for (i = 0; i < NUM_LEDS; i ++)
{
if (((i+(int)(millis/100))%5)==0)
{
leds[i] = CRGB::White;
}
else
{
leds[i] = CRGB::Black;
}
}
}
13 changes: 9 additions & 4 deletions ScreenSaverMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,29 @@ extern CRGB leds[NUM_LEDS];
#include "ScrSvrPulseFlashes.h"
#include "ScrSvrMarchingGreenOrange.h"
#include "ScrSvrRandomFlashes.h"
#include "ScrSvrWhiteFlow.h"
#include "ScrSvrDotInBowl.h"
//Include your new Screensaver here

ScreenSaverMgr::ScreenSaverMgr()
{
_screenSaverCount = 3;
_screenSaverCount = 5; //Number of Screensavers
_screenSavers = new ScreenSaver*[_screenSaverCount]
{
new ScrSvrDotInBowl(),
new ScrSvrWhiteFlow(),
new ScrSvrPulseFlashes(),
new ScrSvrMarchingGreenOrange(),
new ScrSvrRandomFlashes(),
//Add your new Screensaver here
};
}

void ScreenSaverMgr::Tick()
{
long mm = millis();
long modeDuration = 10000;
int mode = (mm/modeDuration)%_screenSaverCount;
long modeTime = mm%modeDuration;
int mode = (mm/SCREEN_SAVER_DURATION)%_screenSaverCount;
long modeTime = mm%SCREEN_SAVER_DURATION;

_mode = mode;
_screenSavers[_mode]->Tick(modeTime);
Expand Down
2 changes: 0 additions & 2 deletions TWANG.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "MPU6050.h"
#include "Wire.h"
#include "toneAC.h"
#include "iSin.h"
#include "RunningMedian.h"

// Included libs
Expand All @@ -28,7 +27,6 @@ int16_t gx, gy, gz;
long previousMillis = 0; // Time of the last redraw
int levelNumber = 0;
long lastInputTime = 0;
iSin isin = iSin();

int lifeLEDs[3] = {52, 50, 48};
int startLed = 53;
Expand Down
2 changes: 2 additions & 0 deletions defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
// PLAYER
#define MAX_PLAYER_SPEED 10 // Max move speed of the player

//SCREEN SAVER
#define SCREEN_SAVER_DURATION 10000 // Duration every screen saver will run (ms)

0 comments on commit 70e2fb9

Please sign in to comment.