so, my game time in millis is 10,000 (10 seconds) this is changeable, and id like a tension creator, so something will happen at intervalgame/4
the following simple code works, but is an over riding constant.
is there a way of manually starting the counter for EVERY_N_MILLISECONDS, or will i have to resort back to the millis() computation?
EVERY_N_MILLISECONDS( intervalGame/4 ) {do something}
matt_p
(matt p)
April 15, 2016, 6:39pm
2
A while back, there was a post about passing a variable to the EVERY function:
https://plus.google.com/106461657512143768817/posts/AyRzBp77g4h
If the link fails, search for “EVERY_N_MILLIS_I” . The “_I” at the end is important.
marmil
(Marc Miller)
April 16, 2016, 4:45am
3
@Kelvin_Mead Even though I’m not exactly sure what you were asking, your post did peak my interest to investigate the EVERY_N* stuff some more. Here’s a wacky test I made that tests out manually creating the timers, checking timers with if statement, and using setPeriod(), getPeriod(), getRemaining(), and reset().
// Experiments with EVERY_N timer stuff.
// Testing: manually creating timer, checking with if statement,
// and using setPeriod(), getPeriod(), getRemaining(), and reset()
//
// Open serial monitor to follow some output.
//
// Marc Miller, Apr. 2016
//
//------------------------------------------------------------------
#include "FastLED.h"
#define LED_TYPE LPD8806
#define DATA_PIN 11
#define CLOCK_PIN 13
#define NUM_LEDS 32
CRGB leds[NUM_LEDS];
uint16_t tTime = 10; // seconds to next trigger. Get's randomized.
uint16_t cTime = 10; // Count after trigger for n seconds
uint16_t rTime = 3; // Reset after n seconds
This file has been truncated. show original
@marmil thats really useful! thanks!