-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fixed bug in API request options parsing - new BluetoothManager class supporting device configuration via LE - added `DISABLE_MQTT`, `DISABLE_BLUETOOTH`, `DISABLE_BLUETOOTH_LE`, `CONFIG_ENABLE_POWER_MANAGER` flags - implemented *HomeGenie API* method `Config/Modules.ParameterSet` - added smart sensor with touch display example for generic *ESP32* and *ESP32-S3* - added configuration to target *ESP32-C3* for playground example - updated Shutter control example - added minimal UI system with touch and gestures support - added PowerManager class with deep-sleep support
- Loading branch information
Showing
42 changed files
with
1,924 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* HomeGenie-Mini (c) 2018-2024 G-Labs | ||
* | ||
* | ||
* This file is part of HomeGenie-Mini (HGM). | ||
* | ||
* HomeGenie-Mini is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* HomeGenie-Mini is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with HomeGenie-Mini. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* | ||
* Authors: | ||
* - Generoso Martello <[email protected]> | ||
* | ||
*/ | ||
|
||
#include "BatterySensor.h" | ||
|
||
namespace IO { namespace Env { | ||
|
||
void BatterySensor::begin() { | ||
pinMode(sensorPin, INPUT); | ||
} | ||
void BatterySensor::loop() { | ||
float gpioMax = 4096; | ||
float gpioV = 3.3f; | ||
float batteryVMax = 3.7f; | ||
const float conversionFactor = gpioV / gpioMax * 3.0f; | ||
float adv = analogReadMilliVolts(sensorPin); | ||
float v = adv * conversionFactor; //adv * (gpioV / gpioMax) * batteryV; | ||
float batteryLevel = v / batteryVMax * 100; | ||
if (lastBatteryLevel != batteryLevel) { | ||
Logger::info("@%s [%s %.2f]", BATTERY_SENSOR_NS_PREFIX, (IOEventPaths::Status_Battery), batteryLevel); | ||
sendEvent((const uint8_t*)(IOEventPaths::Status_Battery), (float*)&batteryLevel, IOEventDataType::Float); | ||
lastBatteryLevel = batteryLevel; | ||
} | ||
|
||
if (batteryLevel > 100) { | ||
// Charging | ||
Service::PowerManager::setActive(); | ||
} | ||
} | ||
|
||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* HomeGenie-Mini (c) 2018-2024 G-Labs | ||
* | ||
* | ||
* This file is part of HomeGenie-Mini (HGM). | ||
* | ||
* HomeGenie-Mini is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* HomeGenie-Mini is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with HomeGenie-Mini. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* | ||
* Authors: | ||
* - Generoso Martello <[email protected]> | ||
* | ||
*/ | ||
|
||
#ifndef HOMEGENIE_MINI_BATTERYSENSOR_H | ||
#define HOMEGENIE_MINI_BATTERYSENSOR_H | ||
|
||
#include <HomeGenie.h> | ||
|
||
#include "../configuration.h" | ||
|
||
#define BATTERY_SENSOR_NS_PREFIX "IO::Env::BatterySensor" | ||
|
||
namespace IO { namespace Env { | ||
|
||
class BatterySensor: Task, public IIOEventSender { | ||
public: | ||
BatterySensor(uint8_t analogPin) { | ||
setLoopInterval(5000); // update every 15 seconds | ||
sensorPin = analogPin; | ||
} | ||
void setModule(Module* m) override { | ||
IIOEventSender::setModule(m); | ||
auto statusBattery = new ModuleParameter(IOEventPaths::Status_Battery); | ||
m->properties.add(statusBattery); | ||
} | ||
void begin() override; | ||
void loop() override; | ||
private: | ||
uint8_t sensorPin; | ||
float lastBatteryLevel = 0; | ||
}; | ||
|
||
}} | ||
|
||
#endif //HOMEGENIE_MINI_BATTERYSENSOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Created by gene on 19/02/24. | ||
// | ||
|
||
#include "MotionSensor.h" | ||
|
||
namespace IO { namespace Env { | ||
void MotionSensor::begin() { | ||
pinMode(sensorPin, INPUT_PULLUP); | ||
Logger::info("| ✔ %s (PIN=%d)", MOTION_SENSOR_NS_PREFIX, sensorPin); | ||
} | ||
void MotionSensor::loop() { | ||
int motionValue = digitalRead(sensorPin); | ||
if (motionValue == HIGH && !motionDetected) { | ||
// MOTION DETECTED | ||
motionDetected = true; | ||
Logger::info("@%s [%s %d]", MOTION_SENSOR_NS_PREFIX, (IOEventPaths::Sensor_MotionDetect), motionValue); | ||
sendEvent((const uint8_t*)(IOEventPaths::Sensor_MotionDetect), (int*)&motionValue, IOEventDataType::Number); | ||
PowerManager::setActive(); | ||
} else if (motionValue == LOW && motionDetected) { | ||
// MOTION CLEAR | ||
motionDetected = false; | ||
Logger::info("@%s [%s %d]", MOTION_SENSOR_NS_PREFIX, (IOEventPaths::Sensor_MotionDetect), motionValue); | ||
sendEvent((const uint8_t*)(IOEventPaths::Sensor_MotionDetect), (int*)&motionValue, IOEventDataType::Number); | ||
} else if (motionDetected) { | ||
// MOTION ACTIVE | ||
PowerManager::setActive(); | ||
} | ||
} | ||
}} // Env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Created by gene on 19/02/24. | ||
// | ||
|
||
#ifndef HOMEGENIE_MINI_MOTIONSENSOR_H | ||
#define HOMEGENIE_MINI_MOTIONSENSOR_H | ||
|
||
#include <HomeGenie.h> | ||
|
||
#include "../configuration.h" | ||
|
||
#define MOTION_SENSOR_NS_PREFIX "IO::Env::MotionSensor" | ||
|
||
namespace IO { namespace Env { | ||
|
||
using namespace Service; | ||
|
||
class MotionSensor : Task, public IIOEventSender { | ||
public: | ||
MotionSensor(uint8_t pin) { | ||
setLoopInterval(200); | ||
sensorPin = pin; | ||
} | ||
void setModule(Module* m) override { | ||
IIOEventSender::setModule(m); | ||
auto motionDetect = new ModuleParameter(IOEventPaths::Sensor_MotionDetect); | ||
m->properties.add(motionDetect); | ||
} | ||
void begin() override; | ||
void loop() override; | ||
|
||
private: | ||
uint8_t sensorPin = 0; | ||
bool motionDetected = false; | ||
}; | ||
|
||
}} // Env | ||
|
||
#endif //HOMEGENIE_MINI_MOTIONSENSOR_H |
Oops, something went wrong.