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_220: New shortcut for switching BT on/off #221

Merged
merged 2 commits into from
Aug 22, 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: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +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.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)
Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.11 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.12 (15.08.2024)
- [Issue 220](https://github.com/tonuino/TonUINO-TNG/issues/220): New shortcut for switching BT on/off

## Version 3.1.11 (31.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
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 31.07.24\n"));
LOG(init_log, s_error, F("V3.1.12 15.08.24\n"));

#ifdef TonUINO_Classic
LOG(init_log, s_error, F("C "), lf_no);
Expand Down
1 change: 1 addition & 0 deletions audio_messages_de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mp3/0320_mode_audio_book_single.mp3|Hörbuch Modus einzeln: Den nächsten Titel
mp3/0321_mode_repeat_last_card.mp3|Wiederhole Karte Modus: Die letzte Karte oder der letzte Shortcut wird wiederholt.
mp3/0322_mode_quiz_game.mp3|Quiz Spiel Modus: Spiele ein Quiz.
mp3/0323_mode_memory_game.mp3|Memory Spiel Modus: Spiele ein Memory.
mp3/0324_mode_switch_bt.mp3|Switch Bluetooth: Schalte Bluetooth an oder aus.
mp3/0327_select_file.mp3|OK, wähle nun bitte die Datei mit den Lautstärketasten aus.
mp3/0328_select_first_file.mp3|OK, wähle nun bitte die Startdatei mit den Lautstärketasten aus.
mp3/0329_select_last_file.mp3|Wähle nun bitte die Enddatei mit den Lautstärketasten aus.
Expand Down
Binary file added sd-card/mp3/0324_mode_switch_bt.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 @@ -24,6 +24,7 @@ enum class pmode_t: uint8_t {
repeat_last = 11,
quiz_game = 12,
memory_game = 13,
switch_bt = 14,

// modifier modes
sleep_timer = 1,
Expand Down
1 change: 1 addition & 0 deletions src/mp3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum class mp3Tracks: uint16_t {
t_321_mode_repeat_last_card = 321,
t_322_mode_quiz_game = 322,
t_323_mode_memory_game = 323,
t_324_mode_switch_bt = 324,
t_327_select_file = 327,
t_328_select_first_file = 328,
t_329_select_last_file = 329,
Expand Down
16 changes: 14 additions & 2 deletions src/state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void ChMode::entry() {

folder = folderSettings{};

numberOfOptions = 13;
numberOfOptions = 14;
startMessage = mp3Tracks::t_310_select_mode;
messageOffset = mp3Tracks::t_310_select_mode;
preview = false;
Expand Down Expand Up @@ -169,7 +169,7 @@ void ChMode::react(command_e const &cmd_e) {
transit<finished>();
return;
}
if (folder.mode == pmode_t::repeat_last) {
if (folder.mode == pmode_t::repeat_last || folder.mode == pmode_t::switch_bt) {
folder.folder = 0xff; // dummy value > 0 to make readCard() returning true
transit<finished>();
return;
Expand Down Expand Up @@ -480,6 +480,12 @@ bool Base::readCard() {
case Chip_card::readCardEvent::none : return false;

case Chip_card::readCardEvent::known:
#ifdef BT_MODULE
if (lastCardRead.mode == pmode_t::switch_bt) {
tonuino.switchBtModuleOnOff();
return false;
}
#endif
if (lastCardRead.folder == 0) {
if (lastCardRead.mode == pmode_t::admin_card) {
LOG(state_log, s_debug, str_Base(), str_to(), str_Admin_Entry());
Expand Down Expand Up @@ -515,6 +521,12 @@ bool Base::readCard() {
bool Base::handleShortcut(uint8_t shortCut) {
folderSettings sc_folderSettings = settings.getShortCut(shortCut);
if (sc_folderSettings.folder != 0) {
#ifdef BT_MODULE
if (sc_folderSettings.mode == pmode_t::switch_bt) {
tonuino.switchBtModuleOnOff();
return false; // do not end the current play
}
#endif // BT_MODULE
if (sc_folderSettings.mode != pmode_t::repeat_last)
tonuino.setMyFolder(sc_folderSettings, false /*myFolderIsCard*/);
if (tonuino.getFolder() != 0) {
Expand Down
16 changes: 10 additions & 6 deletions src/tonuino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,15 @@ void Tonuino::shutdown() {
}

#ifdef BT_MODULE
void Tonuino::switchBtModuleOnOff() {
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));
}

void Tonuino::btModulePairing() {
if (not btModulePairingTimer.isActive()) {
mp3.playAdvertisement(advertTracks::t_322_bt_pairing, false/*olnyIfIsPlaying*/);
Expand Down Expand Up @@ -405,12 +414,7 @@ bool Tonuino::specialCard(const folderSettings &nfcTag) {

#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));
switchBtModuleOnOff();
break;
#endif // BT_MODULE

Expand Down
1 change: 1 addition & 0 deletions src/tonuino.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Tonuino {

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

Expand Down