diff --git a/include/README b/include/README deleted file mode 100644 index 194dcd4..0000000 --- a/include/README +++ /dev/null @@ -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 diff --git a/lib/README b/lib/README deleted file mode 100644 index 6debab1..0000000 --- a/lib/README +++ /dev/null @@ -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 -#include - -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 diff --git a/platformio.ini b/platformio.ini index 0c43c40..3505575 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,10 +14,10 @@ board = esp32dev framework = arduino lib_deps = https://github.com/adafruit/Adafruit_NeoPixel build_flags = -;upload_port = 10.0.0.153 -;upload_protocol = espota -upload_port = /dev/ttyUSB0 -upload_speed = 921600 +upload_port = 10.0.0.142 +upload_protocol = espota +;upload_port = /dev/ttyUSB0 +;upload_speed = 921600 monitor_port = /dev/ttyUSB0 monitor_speed = 115200 monitor_filters = esp32_exception_decoder diff --git a/src/mode.cpp b/src/mode.cpp index 3e5945b..0a070b0 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -5,7 +5,7 @@ #include "mode/GameOfLife/GameOfLife.h" #include "mode/Pong/Pong.h" #include "mode/SpaceInvaders/SpaceInvaders.h" -#include "mode/NewYear/NewYear.h" +#include "mode/CountDown/CountDown.h" #include "mode/Starfield/Starfield.h" #include "mode/Matrix/Matrix.h" #include "display.h" @@ -84,8 +84,11 @@ void loadNewMode() { case SPACE_INVADERS: mode = new SpaceInvaders(display); break; - case NEW_YEAR: - mode = new NewYear(display); + case COUNT_DOWN: + mode = new CountDown(display, false); + break; + case COUNT_DOWN_BARS: + mode = new CountDown(display, true); break; case STARFIELD: mode = new Starfield(display); diff --git a/src/mode/NewYear/NewYear.h b/src/mode/CountDown/CountDown.h similarity index 78% rename from src/mode/NewYear/NewYear.h rename to src/mode/CountDown/CountDown.h index 9c221a7..67f2be4 100644 --- a/src/mode/NewYear/NewYear.h +++ b/src/mode/CountDown/CountDown.h @@ -1,12 +1,12 @@ -#ifndef MODE_NEW_YEAR_H -#define MODE_NEW_YEAR_H +#ifndef MODE_COUNT_DOWN_H +#define MODE_COUNT_DOWN_H #define MAX_FIREWORKS 5 #include "mode/Mode.h" -#include "Firework.h" +#include "CountDownFirework.h" -class NewYear : public Mode { +class CountDown : public Mode { private: @@ -16,17 +16,23 @@ private: uint8_t level = 0; + bool bars; + public: - explicit NewYear(Display &display) : - Mode(display) { + CountDown(Display &display, bool bars) : + Mode(display), bars(bars) { for (auto &firework: fireworks) { firework.init(display); } } const char *getName() override { - return "NewYear"; + if (bars) { + return "CountDown (Bars)"; + } else { + return "CountDown (Numbers)"; + } } 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 minutes = (60 - now.tm_min - (now.tm_sec > 0 ? 1 : 0)) % 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; if (days > 0) { drawDay(display, days, &x); diff --git a/src/mode/NewYear/Firework.h b/src/mode/CountDown/CountDownFirework.h similarity index 98% rename from src/mode/NewYear/Firework.h rename to src/mode/CountDown/CountDownFirework.h index b20c55b..5fba7da 100644 --- a/src/mode/NewYear/Firework.h +++ b/src/mode/CountDown/CountDownFirework.h @@ -1,5 +1,5 @@ -#ifndef NEW_YEAR_FIREWORK_H -#define NEW_YEAR_FIREWORK_H +#ifndef COUNT_DOWN_FIREWORK_H +#define COUNT_DOWN_FIREWORK_H #include "BASICS.h" #include "display/Vector.h" diff --git a/src/mode/Mode.h b/src/mode/Mode.h index 6ae9f55..f0b74d4 100644 --- a/src/mode/Mode.h +++ b/src/mode/Mode.h @@ -19,7 +19,8 @@ enum ModeId { GAME_OF_LIFE_RANDOM_COLOR, PONG, SPACE_INVADERS, - NEW_YEAR, + COUNT_DOWN, + COUNT_DOWN_BARS, STARFIELD, MATRIX, }; diff --git a/src/server.cpp b/src/server.cpp index e36773a..d55eaa8 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -58,9 +58,10 @@ void web_index() { server.sendContent(R"(GAME_OF_LIFE_RANDOM_COLOR
)"); server.sendContent(R"(PONG
)"); server.sendContent(R"(SPACE_INVADERS
)"); - server.sendContent(R"(NEW_YEAR
)"); - server.sendContent(R"(STARFIELD
)"); - server.sendContent(R"(MATRIX
)"); + server.sendContent(R"(COUNT_DOWN
)"); + server.sendContent(R"(COUNT_DOWN_BARS
)"); + server.sendContent(R"(STARFIELD
)"); + server.sendContent(R"(MATRIX
)"); server.sendContent(R"(Helligkeit: + / -
)"); server.sendContent(R"(Geschwindigkeit: + / -
)"); diff --git a/test/README b/test/README deleted file mode 100644 index b94d089..0000000 --- a/test/README +++ /dev/null @@ -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