Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue_215: New optional Feature: Support BT Modul #216

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ Eine Anleitung dafür findet man [hier](https://discourse.voss.earth/t/tonuino-s

# Installation

Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.9 geändert. Hier kann man die Dateien downloaden: [tonuino.github.io/TonUINO-TNG/sd-card.zip](https://tonuino.github.io/TonUINO-TNG/sd-card.zip)
Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.10 geändert. Hier kann man die Dateien downloaden: [tonuino.github.io/TonUINO-TNG/sd-card.zip](https://tonuino.github.io/TonUINO-TNG/sd-card.zip)

# Change Log

## Version 3.1.11 (04.07.2024)
## Version 3.1.11 (30.07.2024)
- [Issue 212](https://github.com/tonuino/TonUINO-TNG/issues/212): Sleep Timer Modification card doesn't work properly with NeoPixel Ring
- [Issue 215](https://github.com/tonuino/TonUINO-TNG/issues/215): New optional Feature: Support BT Modul

## Version 3.1.10 (27.06.2024)
- [Issue 210](https://github.com/tonuino/TonUINO-TNG/issues/210): Make text in the admin menu for switching volume button more clearer
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.11 04.07.24\n"));
LOG(init_log, s_error, F("V3.1.11 30.07.24\n"));

#ifdef TonUINO_Classic
LOG(init_log, s_error, F("C "), lf_no);
Expand Down
4 changes: 4 additions & 0 deletions audio_messages_de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ advert/0305_kindergarden.mp3|KiTa-Modus aktiviert.
advert/0306_fire.mp3|Feuer....10s....und weiter geht's
advert/0307_water.mp3|Wasser....10s....und weiter geht's
advert/0308_air.mp3|Luft....10s....und weiter geht's
advert/0320_bt_on.mp3|Bluetooth wird eingeschaltet
advert/0320_bt_off.mp3|Bluetooth wird ausgeschaltet
advert/0320_bt_pairing.mp3|Bluetooth wird verbunden
mp3/0300_new_tag.mp3|Oh, eine neue Karte!
mp3/0301_select_folder.mp3|Ok, verwende nun die Lautstärketasten um einen Ordner für die Karte auszuwählen.
mp3/0310.mp3|Wähle mit den Lautstärketasten den Wiedergabemodus aus. Drücke die Pausetaste um fortzufahren.
Expand Down Expand Up @@ -112,6 +115,7 @@ mp3/0973_modifier_FiWaAi.mp3|Feuer, Wasser und Luft Spiel.
mp3/0974_modifier_Toddler.mp3|Krabbler-Modus - Alle Tasten vom TonUINO werden für die ganz Kleinen gesperrt. Karten funktionieren weiterhin.
mp3/0975_modifier_KinderGarden.mp3|KiTa-Modus - Damit es keinen Streit mehr gibt werden neue Karten nicht sofort gespielt sondern erst nachdem das aktuelle Lied vorbei ist. Die Vor- und Zurücktasten sind gesperrt.
mp3/0976_modifier_repeat1.mp3|Titel wiederholen - den aktuellen Titel endlos wiederholen.
mp3/0977_modifier_bluetooth.mp3|Bluetoothkarte - Mit der Bluetoothkarte kannst du Bluetooth ein- oder ausschalten.
mp3/0980_admin_lock_intro.mp3|Wähle bitte aus ob und wie das Adminmenü geschützt werden soll.
mp3/0981_admin_lock_disabled.mp3|Kein Schutz - das Adminmenü kann jederzeit durch drücken von allen drei Tasten aktiviert werden.
mp3/0982_admin_lock_card.mp3|Nur Adminkarte - das Adminmenü kann nur mit einer Adminkarte geöffnet werden. Eine neue Adminkarte kann jederzeit angelernt werden.
Expand Down
Binary file added sd-card/advert/0320_bt_on.mp3
Binary file not shown.
Binary file added sd-card/advert/0321_bt_off.mp3
Binary file not shown.
Binary file added sd-card/advert/0322_pairing.mp3
Binary file not shown.
Binary file added sd-card/mp3/0977_modifier_bluetooth.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions src/chip_card.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum class pmode_t: uint8_t {
toddler = 4,
kindergarden = 5,
repeat_single = 6,
bt_module = 7,

admin_card = 0xff,
};
Expand Down
12 changes: 12 additions & 0 deletions src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ inline constexpr uint8_t specialStartShortcutTrack = 1;

// ######################################################################

/* uncomment the below line to enable support for BT module
* um die Unterstützung des BT Modules zu aktivieren, in der nächste Zeile den Kommentar entfernen
*/
//#define BT_MODULE
inline constexpr uint8_t btModuleOnPin = 2; // D2
inline constexpr levelType btModuleOnPinType = levelType::activeHigh;
inline constexpr uint8_t btModulePairingPin = 3; // D3
inline constexpr levelType btModulePairingPinType = levelType::activeHigh;
inline constexpr unsigned long btModulePairingPulse = 500;

// ######################################################################

/* uncomment the below line to enable battery voltage measurement (not for ALLinONE, not recommended for TonUINO_Classic)
* um die Batterie Spannungsmessung zu aktivieren, in der nächste Zeile den Kommentar entfernen
* (nicht für ALLinONE, nicht empfohlen für TonUINO_Classic)
Expand Down
4 changes: 4 additions & 0 deletions src/mp3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ enum class mp3Tracks: uint16_t {
t_974_modifier_Toddler = 974,
t_975_modifier_KinderGarden = 975,
t_976_modifier_repeat1 = 976,
t_977_modifier_bluetooth = 977,
t_980_admin_lock_intro = 980,
t_981_admin_lock_disabled = 981,
t_982_admin_lock_card = 982,
Expand Down Expand Up @@ -169,6 +170,9 @@ enum class advertTracks: uint16_t {
t_306_fire = 306,
t_307_water = 307,
t_308_air = 308,
t_320_bt_on = 320,
t_321_bt_off = 321,
t_322_bt_pairing = 322,
};

// implement a notification class,
Expand Down
7 changes: 6 additions & 1 deletion src/state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,11 @@ void Play::react(command_e const &cmd_e) {
transit<Pause>();
return;
case command::track:
#ifdef BT_MODULE
if (tonuino.isBtModuleOn())
tonuino.btModulePairing();
else
#endif
tonuino.playTrackNumber();
break;
case command::volume_up:
Expand Down Expand Up @@ -1616,7 +1621,7 @@ void Admin_SimpleSetting::react(command_e const &cmd_e) {
void Admin_ModCard::entry() {
LOG(state_log, s_info, str_enter(), str_Admin_ModCard());

numberOfOptions = 6;
numberOfOptions = 7;
startMessage = mp3Tracks::t_970_modifier_Intro;
messageOffset = mp3Tracks::t_970_modifier_Intro;
preview = false;
Expand Down
33 changes: 33 additions & 0 deletions src/tonuino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ void Tonuino::setup() {
pinMode(specialStartShortcutPin, INPUT);
#endif

#ifdef BT_MODULE
pinMode(btModuleOnPin , OUTPUT);
pinMode(btModulePairingPin , OUTPUT);
digitalWrite(btModuleOnPin , getLevel(btModuleOnPinType , level::inactive));
digitalWrite(btModulePairingPin, getLevel(btModulePairingPinType, level::inactive));
#endif // BT_MODULE

#ifdef NEO_RING
ring.init();
Expand Down Expand Up @@ -175,6 +181,12 @@ void Tonuino::loop() {
ring.call_on_admin();
#endif // NEO_RING

#ifdef BT_MODULE
if (btModulePairingTimer.isActive() && btModulePairingTimer.isExpired())
digitalWrite(btModulePairingPin, getLevel(btModulePairingPinType, level::inactive));
#endif // BT_MODULE


unsigned long stop_cycle = millis();

if (stop_cycle-start_cycle < cycleTime)
Expand Down Expand Up @@ -341,6 +353,16 @@ void Tonuino::shutdown() {
sleep_mode();
}

#ifdef BT_MODULE
void Tonuino::btModulePairing() {
if (not btModulePairingTimer.isActive()) {
mp3.playAdvertisement(advertTracks::t_322_bt_pairing, false/*olnyIfIsPlaying*/);
btModulePairingTimer.start(btModulePairingPulse);
digitalWrite(btModulePairingPin, getLevel(btModulePairingPinType, level::active));
}
}
#endif // BT_MODULE

bool Tonuino::specialCard(const folderSettings &nfcTag) {
LOG(card_log, s_debug, F("special card, mode = "), static_cast<uint8_t>(nfcTag.mode));
if (activeModifier->getActive() == nfcTag.mode) {
Expand Down Expand Up @@ -381,6 +403,17 @@ bool Tonuino::specialCard(const folderSettings &nfcTag) {
activeModifier = &repeatSingleModifier;
break;

#ifdef BT_MODULE
case pmode_t::bt_module: LOG(card_log, s_info, F("toggle bt module from "), btModuleOn);
btModuleOn = not btModuleOn;
if (btModuleOn)
mp3.playAdvertisement(advertTracks::t_320_bt_on , false/*olnyIfIsPlaying*/);
else
mp3.playAdvertisement(advertTracks::t_321_bt_off, false/*olnyIfIsPlaying*/);
digitalWrite(btModuleOnPin, getLevel(btModuleOnPinType, btModuleOn ? level::active : level::inactive));
break;
#endif // BT_MODULE

default: return false;
}
activeModifier->init(nfcTag.mode, nfcTag.special);
Expand Down
10 changes: 10 additions & 0 deletions src/tonuino.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class Tonuino {

uint16_t getNumTracksInFolder() const {return numTracksInFolder; }

#ifdef BT_MODULE
bool isBtModuleOn() { return btModuleOn; }
void btModulePairing();
#endif

private:

void checkStandby();
Expand Down Expand Up @@ -128,6 +133,11 @@ class Tonuino {
folderSettings myFolder {};
bool myFolderIsCard {};
uint16_t numTracksInFolder {};

#ifdef BT_MODULE
bool btModuleOn {};
Timer btModulePairingTimer{};
#endif
};

#endif /* SRC_TONUINO_HPP_ */