Renamed NewYear -> CountDown + CountDownBars
This commit is contained in:
parent
01dd357009
commit
07a41a34cf
@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project header files.
|
|
||||||
|
|
||||||
A header file is a file containing C declarations and macro definitions
|
|
||||||
to be shared between several project source files. You request the use of a
|
|
||||||
header file in your project source file (C, C++, etc) located in `src` folder
|
|
||||||
by including it, with the C preprocessing directive `#include'.
|
|
||||||
|
|
||||||
```src/main.c
|
|
||||||
|
|
||||||
#include "header.h"
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Including a header file produces the same results as copying the header file
|
|
||||||
into each source file that needs it. Such copying would be time-consuming
|
|
||||||
and error-prone. With a header file, the related declarations appear
|
|
||||||
in only one place. If they need to be changed, they can be changed in one
|
|
||||||
place, and programs that include the header file will automatically use the
|
|
||||||
new version when next recompiled. The header file eliminates the labor of
|
|
||||||
finding and changing all the copies as well as the risk that a failure to
|
|
||||||
find one copy will result in inconsistencies within a program.
|
|
||||||
|
|
||||||
In C, the usual convention is to give header files names that end with `.h'.
|
|
||||||
It is most portable to use only letters, digits, dashes, and underscores in
|
|
||||||
header file names, and at most one dot.
|
|
||||||
|
|
||||||
Read more about using header files in official GCC documentation:
|
|
||||||
|
|
||||||
* Include Syntax
|
|
||||||
* Include Operation
|
|
||||||
* Once-Only Headers
|
|
||||||
* Computed Includes
|
|
||||||
|
|
||||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
|
||||||
46
lib/README
46
lib/README
@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
|
||||||
PlatformIO will compile them to static libraries and link into executable file.
|
|
||||||
|
|
||||||
The source code of each library should be placed in a an own separate directory
|
|
||||||
("lib/your_library_name/[here are source files]").
|
|
||||||
|
|
||||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
|
||||||
|
|
||||||
|--lib
|
|
||||||
| |
|
|
||||||
| |--Bar
|
|
||||||
| | |--docs
|
|
||||||
| | |--examples
|
|
||||||
| | |--src
|
|
||||||
| | |- Bar.c
|
|
||||||
| | |- Bar.h
|
|
||||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
|
||||||
| |
|
|
||||||
| |--Foo
|
|
||||||
| | |- Foo.c
|
|
||||||
| | |- Foo.h
|
|
||||||
| |
|
|
||||||
| |- README --> THIS FILE
|
|
||||||
|
|
|
||||||
|- platformio.ini
|
|
||||||
|--src
|
|
||||||
|- main.c
|
|
||||||
|
|
||||||
and a contents of `src/main.c`:
|
|
||||||
```
|
|
||||||
#include <Foo.h>
|
|
||||||
#include <Bar.h>
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
PlatformIO Library Dependency Finder will find automatically dependent
|
|
||||||
libraries scanning project source files.
|
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
|
||||||
@ -14,10 +14,10 @@ board = esp32dev
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = https://github.com/adafruit/Adafruit_NeoPixel
|
lib_deps = https://github.com/adafruit/Adafruit_NeoPixel
|
||||||
build_flags =
|
build_flags =
|
||||||
;upload_port = 10.0.0.153
|
upload_port = 10.0.0.142
|
||||||
;upload_protocol = espota
|
upload_protocol = espota
|
||||||
upload_port = /dev/ttyUSB0
|
;upload_port = /dev/ttyUSB0
|
||||||
upload_speed = 921600
|
;upload_speed = 921600
|
||||||
monitor_port = /dev/ttyUSB0
|
monitor_port = /dev/ttyUSB0
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
#include "mode/GameOfLife/GameOfLife.h"
|
#include "mode/GameOfLife/GameOfLife.h"
|
||||||
#include "mode/Pong/Pong.h"
|
#include "mode/Pong/Pong.h"
|
||||||
#include "mode/SpaceInvaders/SpaceInvaders.h"
|
#include "mode/SpaceInvaders/SpaceInvaders.h"
|
||||||
#include "mode/NewYear/NewYear.h"
|
#include "mode/CountDown/CountDown.h"
|
||||||
#include "mode/Starfield/Starfield.h"
|
#include "mode/Starfield/Starfield.h"
|
||||||
#include "mode/Matrix/Matrix.h"
|
#include "mode/Matrix/Matrix.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
@ -84,8 +84,11 @@ void loadNewMode() {
|
|||||||
case SPACE_INVADERS:
|
case SPACE_INVADERS:
|
||||||
mode = new SpaceInvaders(display);
|
mode = new SpaceInvaders(display);
|
||||||
break;
|
break;
|
||||||
case NEW_YEAR:
|
case COUNT_DOWN:
|
||||||
mode = new NewYear(display);
|
mode = new CountDown(display, false);
|
||||||
|
break;
|
||||||
|
case COUNT_DOWN_BARS:
|
||||||
|
mode = new CountDown(display, true);
|
||||||
break;
|
break;
|
||||||
case STARFIELD:
|
case STARFIELD:
|
||||||
mode = new Starfield(display);
|
mode = new Starfield(display);
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
#ifndef MODE_NEW_YEAR_H
|
#ifndef MODE_COUNT_DOWN_H
|
||||||
#define MODE_NEW_YEAR_H
|
#define MODE_COUNT_DOWN_H
|
||||||
|
|
||||||
#define MAX_FIREWORKS 5
|
#define MAX_FIREWORKS 5
|
||||||
|
|
||||||
#include "mode/Mode.h"
|
#include "mode/Mode.h"
|
||||||
#include "Firework.h"
|
#include "CountDownFirework.h"
|
||||||
|
|
||||||
class NewYear : public Mode {
|
class CountDown : public Mode {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -16,17 +16,23 @@ private:
|
|||||||
|
|
||||||
uint8_t level = 0;
|
uint8_t level = 0;
|
||||||
|
|
||||||
|
bool bars;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit NewYear(Display &display) :
|
CountDown(Display &display, bool bars) :
|
||||||
Mode(display) {
|
Mode(display), bars(bars) {
|
||||||
for (auto &firework: fireworks) {
|
for (auto &firework: fireworks) {
|
||||||
firework.init(display);
|
firework.init(display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getName() override {
|
const char *getName() override {
|
||||||
return "NewYear";
|
if (bars) {
|
||||||
|
return "CountDown (Bars)";
|
||||||
|
} else {
|
||||||
|
return "CountDown (Numbers)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -100,7 +106,33 @@ private:
|
|||||||
uint8_t hours = (24 - now.tm_hour - (now.tm_min > 0 || now.tm_sec > 0 ? 1 : 0));
|
uint8_t hours = (24 - now.tm_hour - (now.tm_min > 0 || now.tm_sec > 0 ? 1 : 0));
|
||||||
uint8_t minutes = (60 - now.tm_min - (now.tm_sec > 0 ? 1 : 0)) % 60;
|
uint8_t minutes = (60 - now.tm_min - (now.tm_sec > 0 ? 1 : 0)) % 60;
|
||||||
uint8_t seconds = (60 - now.tm_sec) % 60;
|
uint8_t seconds = (60 - now.tm_sec) % 60;
|
||||||
|
if (days <= 0 && bars) {
|
||||||
|
drawCountdownBars(display, hours, minutes, seconds);
|
||||||
|
} else {
|
||||||
|
drawCountdownNumbers(display, hours, minutes, seconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawCountdownBars(Display &display, uint8_t hours, uint8_t minutes, uint8_t seconds) {
|
||||||
|
drawBar(display, 0, 0, 24, 1, 0, 24, hours, RED);
|
||||||
|
drawBar(display, 0, 2, 30, 2, 0, 60, minutes, BLUE);
|
||||||
|
drawBar(display, 0, 5, 30, 2, 0, 60, seconds, GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawBar(Display &display, uint8_t _x, uint8_t _y, uint8_t _w, uint8_t _h, uint8_t min, uint8_t max, uint8_t value, const Color &color) {
|
||||||
|
auto onCount = (uint8_t) round(((double) value - min) / (max - min) * _w * _h);
|
||||||
|
for (uint8_t y = 0; y < _h; y++) {
|
||||||
|
for (uint8_t x = 0; x < _w; x++) {
|
||||||
|
if (onCount <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onCount--;
|
||||||
|
display.set(_x + x, _y + y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawCountdownNumbers(Display &display, uint8_t hours, uint8_t minutes, uint8_t seconds) const {
|
||||||
uint8_t x = 0;
|
uint8_t x = 0;
|
||||||
if (days > 0) {
|
if (days > 0) {
|
||||||
drawDay(display, days, &x);
|
drawDay(display, days, &x);
|
||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef NEW_YEAR_FIREWORK_H
|
#ifndef COUNT_DOWN_FIREWORK_H
|
||||||
#define NEW_YEAR_FIREWORK_H
|
#define COUNT_DOWN_FIREWORK_H
|
||||||
|
|
||||||
#include "BASICS.h"
|
#include "BASICS.h"
|
||||||
#include "display/Vector.h"
|
#include "display/Vector.h"
|
||||||
@ -19,7 +19,8 @@ enum ModeId {
|
|||||||
GAME_OF_LIFE_RANDOM_COLOR,
|
GAME_OF_LIFE_RANDOM_COLOR,
|
||||||
PONG,
|
PONG,
|
||||||
SPACE_INVADERS,
|
SPACE_INVADERS,
|
||||||
NEW_YEAR,
|
COUNT_DOWN,
|
||||||
|
COUNT_DOWN_BARS,
|
||||||
STARFIELD,
|
STARFIELD,
|
||||||
MATRIX,
|
MATRIX,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -58,9 +58,10 @@ void web_index() {
|
|||||||
server.sendContent(R"(<a href="/mode?mode=6">GAME_OF_LIFE_RANDOM_COLOR</a><br>)");
|
server.sendContent(R"(<a href="/mode?mode=6">GAME_OF_LIFE_RANDOM_COLOR</a><br>)");
|
||||||
server.sendContent(R"(<a href="/mode?mode=7">PONG</a><br>)");
|
server.sendContent(R"(<a href="/mode?mode=7">PONG</a><br>)");
|
||||||
server.sendContent(R"(<a href="/mode?mode=8">SPACE_INVADERS</a><br>)");
|
server.sendContent(R"(<a href="/mode?mode=8">SPACE_INVADERS</a><br>)");
|
||||||
server.sendContent(R"(<a href="/mode?mode=9">NEW_YEAR</a><br>)");
|
server.sendContent(R"(<a href="/mode?mode=9">COUNT_DOWN</a><br>)");
|
||||||
server.sendContent(R"(<a href="/mode?mode=10">STARFIELD</a><br>)");
|
server.sendContent(R"(<a href="/mode?mode=10">COUNT_DOWN_BARS</a><br>)");
|
||||||
server.sendContent(R"(<a href="/mode?mode=11">MATRIX</a><br>)");
|
server.sendContent(R"(<a href="/mode?mode=11">STARFIELD</a><br>)");
|
||||||
|
server.sendContent(R"(<a href="/mode?mode=12">MATRIX</a><br>)");
|
||||||
|
|
||||||
server.sendContent(R"(Helligkeit: <a href="/brighter">+</a> / <a href="/darker">-</a><br>)");
|
server.sendContent(R"(Helligkeit: <a href="/brighter">+</a> / <a href="/darker">-</a><br>)");
|
||||||
server.sendContent(R"(Geschwindigkeit: <a href="/faster">+</a> / <a href="/slower">-</a><br>)");
|
server.sendContent(R"(Geschwindigkeit: <a href="/faster">+</a> / <a href="/slower">-</a><br>)");
|
||||||
|
|||||||
11
test/README
11
test/README
@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Unit Testing and project tests.
|
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
|
||||||
source code, sets of one or more MCU program modules together with associated
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
|
||||||
Loading…
Reference in New Issue
Block a user