mirror of https://github.com/arendst/Tasmota.git
Refactor Hall Effect
This commit is contained in:
parent
47fcdd9e8e
commit
e7a851f197
|
@ -217,6 +217,28 @@ void DebugFreeMem(void)
|
|||
|
||||
#endif // ESP8266 - ESP32
|
||||
|
||||
/*******************************************************************************************/
|
||||
/*
|
||||
Usage:
|
||||
|
||||
DebugTimer(1);
|
||||
|
||||
Code snippit to time
|
||||
|
||||
DebugTimer(0);
|
||||
*/
|
||||
|
||||
void DebugTimer(bool start) {
|
||||
static uint32_t timer = 0;
|
||||
|
||||
if (start) {
|
||||
timer = micros();
|
||||
} else {
|
||||
timer = ((int32_t)(micros() - timer));
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: ExecTime %d uS"), timer);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************************/
|
||||
|
||||
void DebugRtcDump(char* parms)
|
||||
|
|
|
@ -37,8 +37,11 @@ struct {
|
|||
|
||||
void HallEffectInit(void) {
|
||||
if (PinUsed(GPIO_HALLEFFECT) && PinUsed(GPIO_HALLEFFECT, 1)) {
|
||||
HEData.present = (((36 == Pin(GPIO_HALLEFFECT)) && (39 == Pin(GPIO_HALLEFFECT, 1))) ||
|
||||
((39 == Pin(GPIO_HALLEFFECT)) && (36 == Pin(GPIO_HALLEFFECT, 1))));
|
||||
if (((36 == Pin(GPIO_HALLEFFECT)) && (39 == Pin(GPIO_HALLEFFECT, 1))) ||
|
||||
((39 == Pin(GPIO_HALLEFFECT)) && (36 == Pin(GPIO_HALLEFFECT, 1)))) {
|
||||
HEData.present = true;
|
||||
hallRead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,17 +51,11 @@ const char HTTP_SNS_HALL_EFFECT[] PROGMEM = "{s}" D_HALL_EFFECT "{m}%d{e}";
|
|||
#endif // USE_WEBSERVER
|
||||
|
||||
void HallEffectShow(bool json) {
|
||||
|
||||
// DebugStartTime();
|
||||
|
||||
int value = 0;
|
||||
for (uint32_t i = 0; i < HALLEFFECT_SAMPLE_COUNT; i++) {
|
||||
value += hallRead();
|
||||
}
|
||||
value /= HALLEFFECT_SAMPLE_COUNT;
|
||||
|
||||
// DebugStopTime();
|
||||
|
||||
if (json) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_HALLEFFECT "\":%d"), value);
|
||||
#ifdef USE_DOMOTICZ
|
||||
|
|
Loading…
Reference in New Issue