Implement API check when pin tied hi
This commit is contained in:
parent
035446eb34
commit
5667ecc83c
2 changed files with 20 additions and 3 deletions
|
|
@ -6,4 +6,18 @@ Wippersnapper_Manager::~Wippersnapper_Manager() {
|
|||
if (ws_instance) {
|
||||
delete ws_instance;
|
||||
}
|
||||
if (ws_instance_v2) {
|
||||
delete ws_instance_v2;
|
||||
}
|
||||
}
|
||||
|
||||
void Wippersnapper_Manager::checkAPIVersion() {
|
||||
// Check if pin D12 is high
|
||||
pinMode(12, INPUT_PULLUP);
|
||||
_api_version = digitalRead(12);
|
||||
if (_api_version) { // API version 2 if D12 is high
|
||||
ws_instance_v2 = new Wippersnapper_V2();
|
||||
} else { // API version 1 if D12 is low
|
||||
ws_instance = new Wippersnapper();
|
||||
}
|
||||
}
|
||||
|
|
@ -10,16 +10,19 @@ public:
|
|||
Wippersnapper_Manager();
|
||||
~Wippersnapper_Manager();
|
||||
|
||||
// API version check
|
||||
void checkAPIVersion();
|
||||
|
||||
// TODO: Do we need this within the manager?
|
||||
// void provision();
|
||||
// TODO: Implement
|
||||
|
||||
protected:
|
||||
Wippersnapper
|
||||
*ws_instance; // Pointer to either Wippersnapper or Wippersnapper_V2
|
||||
Wippersnapper *ws_instance;
|
||||
Wippersnapper_V2 *ws_instance_v2;
|
||||
|
||||
private:
|
||||
int getProvisionResult();
|
||||
bool _api_version; // True if API version 2, False otherwise
|
||||
};
|
||||
extern Wippersnapper WS; ///< Global member variable for callbacks
|
||||
#endif // WIPPERSNAPPER_MANAGER_H
|
||||
|
|
|
|||
Loading…
Reference in a new issue