Skip to content

Commit

Permalink
Merge pull request #632 from MartinMueller2003/main
Browse files Browse the repository at this point in the history
Added Marquee and Random Flash support.
  • Loading branch information
forkineye authored May 18, 2023
2 parents 98f1626 + 4030966 commit ae3e177
Show file tree
Hide file tree
Showing 22 changed files with 717 additions and 129 deletions.
2 changes: 2 additions & 0 deletions ESPixelStick/src/ConstNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const CN_PROGMEM char CN_baudrate [] = "baudrate";
const CN_PROGMEM char CN_blanktime [] = "blanktime";
const CN_PROGMEM char CN_bridge [] = "bridge";
const CN_PROGMEM char CN_brightness [] = "brightness";
const CN_PROGMEM char CN_brightnessEnd [] = "brightnessEnd";
const CN_PROGMEM char CN_cfgver [] = "cfgver";
const CN_PROGMEM char CN_channels [] = "channels";
const CN_PROGMEM char CN_clean [] = "clean";
Expand Down Expand Up @@ -116,6 +117,7 @@ const CN_PROGMEM char CN_input_config [] = "input_config";
const CN_PROGMEM char CN_last_clientIP [] = "last_clientIP";
const CN_PROGMEM char CN_lwt [] = "lwt";
const CN_PROGMEM char CN_mac [] = "mac";
const CN_PROGMEM char CN_MarqueeGroups [] = "MarqueeGroups";
const CN_PROGMEM char CN_mdc_pin [] = "mdc_pin";
const CN_PROGMEM char CN_mdio_pin [] = "mdio_pin";
const CN_PROGMEM char CN_Max [] = "Max";
Expand Down
2 changes: 2 additions & 0 deletions ESPixelStick/src/ConstNames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ extern const CN_PROGMEM char CN_baudrate[];
extern const CN_PROGMEM char CN_blanktime[];
extern const CN_PROGMEM char CN_bridge[];
extern const CN_PROGMEM char CN_brightness[];
extern const CN_PROGMEM char CN_brightnessEnd[];
extern const CN_PROGMEM char CN_cfgver[];
extern const CN_PROGMEM char CN_channels[];
extern const CN_PROGMEM char CN_clean[];
Expand Down Expand Up @@ -125,6 +126,7 @@ extern const CN_PROGMEM char CN_input_config[];
extern const CN_PROGMEM char CN_last_clientIP[];
extern const CN_PROGMEM char CN_lwt[];
extern const CN_PROGMEM char CN_mac[];
extern const CN_PROGMEM char CN_MarqueeGroups[];
extern const CN_PROGMEM char CN_mdc_pin[];
extern const CN_PROGMEM char CN_mdio_pin[];
extern const CN_PROGMEM char CN_Max[];
Expand Down
2 changes: 2 additions & 0 deletions ESPixelStick/src/ESPixelStick.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
#endif

#define ARDUINOJSON_USE_LONG_LONG 1
#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 15

#include <Ticker.h>
#include <ArduinoJson.h>

#include "memdebug.h"
#include "ConstNames.hpp"
#include "GPIO_Defs.hpp"
#include "FastTimer.hpp"

#define REBOOT_DELAY 100 ///< Delay for rebooting once reboot flag is set
#define LOG_PORT Serial ///< Serial port for console logging
Expand Down
74 changes: 74 additions & 0 deletions ESPixelStick/src/FastTimer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* FastTimer.cpp - Output Management class
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2021, 2022 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
* subject to the laws and regulations where you are using it. Due diligence
* is strongly suggested before using this code. Please give credit where due.
*
* The Author makes no warranty of any kind, express or implied, with regard
* to this program or the documentation contained in this document. The
* Author shall not be liable in any event for incidental or consequential
* damages in connection with, or arising out of, the furnishing, performance
* or use of these programs.
*
*/

#include "FastTimer.hpp"

//-----------------------------------------------------------------------------
///< Start up the driver and put it into a safe mode
FastTimer::FastTimer ()
{
CancelTimer();
} // FastTimer

//-----------------------------------------------------------------------------
///< deallocate any resources and put the output channels into a safe state
FastTimer::~FastTimer ()
{
// DEBUG_START;

// DEBUG_END;

} // ~FastTimer

//-----------------------------------------------------------------------------
///< Start the module
void FastTimer::StartTimer (uint32_t DurationMS)
{
// DEBUG_START;

uint64_t now = uint64_t(millis());

EndTimeMS = now + uint64_t(DurationMS);
offsetMS = uint64_t((EndTimeMS > uint32_t(-1)) ? uint32_t(-1) : uint32_t(0));

// DEBUG_END;
} // StartTimer

//-----------------------------------------------------------------------------
bool FastTimer::IsExpired ()
{
return ((uint64_t(millis ()) + uint64_t(offsetMS)) >= EndTimeMS);

} // IsExpired

//-----------------------------------------------------------------------------
void FastTimer::CancelTimer()
{
EndTimeMS = millis();
offsetMS = 0;

} // CancelTimer

//-----------------------------------------------------------------------------
uint32_t FastTimer::GetTimeRemaining()
{

return (IsExpired()) ? 0 : uint32_t(EndTimeMS - (uint64_t(millis()) + uint64_t(offsetMS)));

} // GetTimeRemaining
41 changes: 41 additions & 0 deletions ESPixelStick/src/FastTimer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once
/*
* FastTimer.hpp
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2021, 2022 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
* subject to the laws and regulations where you are using it. Due diligence
* is strongly suggested before using this code. Please give credit where due.
*
* The Author makes no warranty of any kind, express or implied, with regard
* to this program or the documentation contained in this document. The
* Author shall not be liable in any event for incidental or consequential
* damages in connection with, or arising out of, the furnishing, performance
* or use of these programs.
*
*/

#include "ESPixelStick.h"

class FastTimer
{
public:
FastTimer ();
virtual ~FastTimer ();

void StartTimer (uint32_t durationMS);
bool IsExpired();
void CancelTimer();
uint32_t GetTimeRemaining();

private:

uint64_t EndTimeMS = 0;
uint32_t offsetMS = 0;

protected:

}; // FastTimer
Loading

0 comments on commit ae3e177

Please sign in to comment.