Skip to content

Commit

Permalink
Merge pull request #179: Issue_178: Use Nano Every optional with HW S…
Browse files Browse the repository at this point in the history
…erial connection to the
  • Loading branch information
boerge1 authored Mar 27, 2024
2 parents 91e3a5a + 59f4e08 commit 77609f5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 31 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ Allgemeine Anleitungen zum Einrichten der IDE findet man hier [www.tonuino.de/TN

- Es ist unbedingt darauf zu achten, das das Verzeichnis in das das Repository gecloned oder heruntergeladen wird (also das Verzeichnis, in dem schließlich auch die TonUINO-TNG.ino zu finden ist, genau so heißt, wie die ino Datei, also in diesem Fall "TonUINO-TNG"!

- Bei der classic und AiO HW Variante muss die Datei 'platform.local.txt' in den avr HW Ordner kopiert werden. Dieser Ordner ist gewöhnlich folgender:
- Bei der classic (Nano und Every) und AiO HW Variante muss die Datei 'platform.local.txt' in den avr HW Ordner kopiert werden. Dieser Ordner ist gewöhnlich folgender:

```
Windows:
Classic: C:\Users\<Benutzer>\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Every: C:\Users\<Benutzer>\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8
AiO: C:\Users\<Benutzer>\AppData\Local\Arduino15\packages\LGT8fx Boards\hardware\avr\1.0.7
Linux:
Classic: ~/.arduino15/packages/arduino/hardware/avr/1.8.6
Every: ~/.arduino15/packages/arduino/hardware/megaavr/1.8.8
Aio: ~/.arduino15/packages/LGT8fx Boards/hardware/avr/1.0.7
MacOS 13.x:
Classic: ~/Library/Arduino15/packages/arduino/hardware/avr/1.8.6
Every: ~/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.8
AiO: ~/Library/Arduino15/packages/LGT8fx Boards/hardware/avr/1.0.7
```

Expand All @@ -46,17 +49,12 @@ Allgemeine Anleitungen zum Einrichten der IDE findet man hier [www.tonuino.de/TN
- Es werden die gleichen HW Varianten angeboten wie beim Online Upload ohne die Datei constants.hpp editieren zu müssen

```
Classic
Classic, Every, AiO und AiOplus
3 Buttons
5 Buttons
3x3 Button Board
AiO und AiOplus
5 Buttons
3x3 Button Board
```

- wenn man die AiO oder AiOplus mit 3 Buttons hat, muss man in der Datei constants.hpp den Kommentar bei `#define THREEBUTTONS` entfernen.

**Verwendung zusammen mit Visual Code**

Eine Anleitung dafür findet man [hier](https://discourse.voss.earth/t/tonuino-software-mit-platformio-aufspielen/13468)
Expand Down Expand Up @@ -92,10 +90,11 @@ Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.6 geän

# Change Log

## Version 3.1.7 (26.03.2024)
- [Issue 178](https://github.com/tonuino/TonUINO-TNG/issues/178): Use Nano Every optional with HW Serial connection to the DfPlayer

## Version 3.1.7 (25.03.2024)
- [Issue 182](https://github.com/tonuino/TonUINO-TNG/issues/182): Quiz game: do not repeat a question until no question remains

## Version 3.1.7 (01.03.2024)
- [Issue 176](https://github.com/tonuino/TonUINO-TNG/issues/176): Implement the memory game

## Version 3.1.6 (18.02.2024)
Expand Down
2 changes: 1 addition & 1 deletion TonUINO-TNG.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void setup()
LOG(init_log, s_error, F("TonUINO Version 3.1 - refactored by Boerge1\n"));
LOG(init_log, s_error, F("created by Thorsten Voß and licensed under GNU/GPL."));
LOG(init_log, s_error, F("Information and contribution at https://tonuino.de.\n"));
LOG(init_log, s_error, F("V3.1.7 25.03.24\n"));
LOG(init_log, s_error, F("V3.1.7 26.03.24\n"));

Tonuino::getTonuino().setup();
}
Expand Down
26 changes: 16 additions & 10 deletions src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
//#define ALLinONE
//#define ALLinONE_Plus

/* If using Nano Every with connected DfPlayer Rx/Tx to D0/D1 uncomment the following lines
* Wenn der Nano Every verwendet wird und Rx/Tx vom DfPlayer mit D0/D1 verbunden ist, den Kommentare der folgenden Zeile entfernen
*/
//#define DFPlayerUsesHardwareSerial

/* uncomment one of the below lines to enable special button support
* um die Tasten zu konfigurieren, bitte eine der nächsten Zeilen auskommentieren
* default: THREEBUTTONS for classic/every
Expand Down Expand Up @@ -212,19 +217,22 @@ inline constexpr uint8_t cardRemoveDelay = 3;

// ####### mp3 #########################################

#define DFPlayerUsesSoftwareSerial

inline constexpr uint8_t maxTracksInFolder = 255;
#ifdef DFPlayerUsesHardwareSerial
inline constexpr HardwareSerial &dfPlayer_serial = Serial1;
#else
inline constexpr uint8_t dfPlayer_receivePin = 2;
inline constexpr uint8_t dfPlayer_transmitPin = 3;
#endif

inline constexpr uint8_t maxTracksInFolder = 255;
inline constexpr uint8_t dfPlayer_busyPin = 4;
inline constexpr levelType dfPlayer_busyPinType = levelType::activeHigh;
inline constexpr unsigned long dfPlayer_timeUntilStarts = 1000;

// ####### tonuino #####################################

inline constexpr uint8_t shutdownPin = 7;
inline constexpr levelType shutdownPinType = levelType::activeHigh;
inline constexpr levelType shutdownPinType = levelType::activeLow;
inline constexpr uint8_t ampEnablePin = 6;
inline constexpr levelType ampEnablePinType = levelType::activeHigh;
inline constexpr uint8_t openAnalogPin = A7;
Expand Down Expand Up @@ -273,14 +281,13 @@ inline constexpr uint8_t cardRemoveDelay = 3;
// ####### mp3 #########################################

#define DFPlayerUsesHardwareSerial
inline constexpr HardwareSerial &dfPlayer_serial = Serial3;

inline constexpr uint8_t maxTracksInFolder = 255;
// inline constexpr uint8_t dfPlayer_receivePin = 2;
// inline constexpr uint8_t dfPlayer_transmitPin = 3;
inline constexpr uint8_t dfPlayer_busyPin = 13;
inline constexpr levelType dfPlayer_busyPinType = levelType::activeHigh;
inline constexpr unsigned long dfPlayer_timeUntilStarts = 1000;
inline constexpr HardwareSerial &dfPlayer_serial = Serial3;

// ####### tonuino #####################################

inline constexpr uint8_t shutdownPin = 27;
Expand Down Expand Up @@ -334,11 +341,10 @@ inline constexpr uint8_t cardRemoveDelay = 3;

// ####### mp3 #########################################

#define DFPlayerUsesSoftwareSerial

inline constexpr uint8_t maxTracksInFolder = 255;
inline constexpr uint8_t dfPlayer_receivePin = 2;
inline constexpr uint8_t dfPlayer_transmitPin = 3;

inline constexpr uint8_t maxTracksInFolder = 255;
inline constexpr uint8_t dfPlayer_busyPin = 4;
inline constexpr levelType dfPlayer_busyPinType = levelType::activeHigh;
inline constexpr unsigned long dfPlayer_timeUntilStarts = 1000;
Expand Down
5 changes: 2 additions & 3 deletions src/mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ void Mp3Notify::OnPlayFinished(DfMp3&, DfMp3_PlaySources /*source*/, uint16_t tr
Tonuino::getTonuino().nextTrack(1/*tracks*/, true/*fromOnPlayFinished*/);
}

#ifdef DFPlayerUsesSoftwareSerial
#ifndef DFPlayerUsesHardwareSerial
Mp3::Mp3(const Settings& settings)
: Base{softwareSerial}
, softwareSerial{dfPlayer_receivePin, dfPlayer_transmitPin}
, settings{settings}
#endif /* DFPlayerUsesSoftwareSerial */
#ifdef DFPlayerUsesHardwareSerial
#else
Mp3::Mp3(const Settings &settings)
: Base{dfPlayer_serial}
, settings{settings}
Expand Down
9 changes: 4 additions & 5 deletions src/mp3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#include "queue.hpp"
#include "timer.hpp"

#ifdef DFPlayerUsesSoftwareSerial // make sure to include "constants.hpp" before this line!
#ifndef DFPlayerUsesHardwareSerial // make sure to include "constants.hpp" before this line!
#include <SoftwareSerial.h>
using SerialType = SoftwareSerial;
#endif // DFPlayerUsesSoftwareSerial
#ifdef DFPlayerUsesHardwareSerial
#else
using SerialType = HardwareSerial;
#endif // DFPlayerUsesHardwareSerial

Expand Down Expand Up @@ -235,9 +234,9 @@ class Mp3: public DfMp3 {

typedef queue<uint8_t, maxTracksInFolder> track_queue;

#ifdef DFPlayerUsesSoftwareSerial
#ifndef DFPlayerUsesHardwareSerial
SoftwareSerial softwareSerial;
#endif /* DFPlayerUsesSoftwareSerial */
#endif /* not DFPlayerUsesHardwareSerial */
const Settings& settings;

uint8_t volume{};
Expand Down
6 changes: 3 additions & 3 deletions test/src/tonuino_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TEST_F(tonuino_test_fixture, initial_state) {
EXPECT_EQ(pin_mode[shutdownPin], OUTPUT);

#ifdef TonUINO_Classic
EXPECT_EQ(pin_value[shutdownPin], LOW);
EXPECT_EQ(pin_value[shutdownPin], HIGH);
#endif

#if defined ALLinONE || defined ALLinONE_Plus
Expand Down Expand Up @@ -210,7 +210,7 @@ TEST_F(tonuino_test_fixture, shutdown_in_idle) {
EXPECT_EQ(pin_value[shutdownPin], LOW);
#endif
#ifdef TonUINO_Classic
EXPECT_EQ(pin_value[shutdownPin], HIGH);
EXPECT_EQ(pin_value[shutdownPin], LOW);
#endif
EXPECT_TRUE(getMp3() .called_sleep );
EXPECT_TRUE(getMFRC522().called_AntennaOff );
Expand Down Expand Up @@ -241,7 +241,7 @@ TEST_F(tonuino_test_fixture, shutdown_in_pause) {
EXPECT_EQ(pin_value[shutdownPin], LOW);
#endif
#ifdef TonUINO_Classic
EXPECT_EQ(pin_value[shutdownPin], HIGH);
EXPECT_EQ(pin_value[shutdownPin], LOW);
#endif
EXPECT_TRUE(getMp3() .called_sleep );
EXPECT_TRUE(getMFRC522().called_AntennaOff );
Expand Down

0 comments on commit 77609f5

Please sign in to comment.