Skip to content

Commit

Permalink
Guard for HAS_SCREEN
Browse files Browse the repository at this point in the history
  • Loading branch information
todd-herbert committed Aug 6, 2024
1 parent b0c44cf commit ec5f473
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/input/ScanAndSelect.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#include "configuration.h"

// Normally these input methods are protected by guarding in setupModules
// In order to have the user button dismiss the canned message frame, this class lightly interacts with the Screen class
#if HAS_SCREEN

#include "ScanAndSelect.h"
#include "modules/CannedMessageModule.h"

Expand Down Expand Up @@ -193,4 +199,6 @@ void ScanAndSelectInput::handleChangeInterrupt()
scanAndSelectInput->enableThread();
}

ScanAndSelectInput *scanAndSelectInput = nullptr; // Instantiated in setupModules method. Deleted if unused, or init() fails
ScanAndSelectInput *scanAndSelectInput = nullptr; // Instantiated in setupModules method. Deleted if unused, or init() fails

#endif
8 changes: 7 additions & 1 deletion src/input/ScanAndSelect.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include "concurrency/OSThread.h"
#include "main.h"

// Normally these input methods are protected by guarding in setupModules
// In order to have the user button dismiss the canned message frame, this class lightly interacts with the Screen class
#if HAS_SCREEN

class ScanAndSelectInput : public Observable<const InputEvent *>, public concurrency::OSThread
{
public:
Expand All @@ -41,4 +45,6 @@ class ScanAndSelectInput : public Observable<const InputEvent *>, public concurr
uint32_t alertingSinceMs = 0; // Used to dismiss the "no canned message" alert several seconds
};

extern ScanAndSelectInput *scanAndSelectInput; // Instantiated in setupModules method. Deleted if unused, or init() fails
extern ScanAndSelectInput *scanAndSelectInput; // Instantiated in setupModules method. Deleted if unused, or init() fails

#endif
4 changes: 4 additions & 0 deletions src/modules/Modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ void setupModules()
delete upDownInterruptImpl1;
upDownInterruptImpl1 = nullptr;
}

#if HAS_SCREEN
// In order to have the user button dismiss the canned message frame, this class lightly interacts with the Screen class
scanAndSelectInput = new ScanAndSelectInput();
if (!scanAndSelectInput->init()) {
delete scanAndSelectInput;
scanAndSelectInput = nullptr;
}
#endif

cardKbI2cImpl = new CardKbI2cImpl();
cardKbI2cImpl->init();
Expand Down

0 comments on commit ec5f473

Please sign in to comment.