readpin implementation
Some checks failed
Build and deploy Docs site to GitHub Pages / github-pages (push) Has been cancelled
PR Build Check / build (Heltec_v3_companion_radio_ble) (push) Has been cancelled
PR Build Check / build (Heltec_v3_repeater) (push) Has been cancelled
PR Build Check / build (Heltec_v3_room_server) (push) Has been cancelled
PR Build Check / build (LilyGo_Tlora_C6_repeater_) (push) Has been cancelled
PR Build Check / build (PicoW_repeater) (push) Has been cancelled
PR Build Check / build (RAK_4631_companion_radio_ble) (push) Has been cancelled
PR Build Check / build (RAK_4631_repeater) (push) Has been cancelled
PR Build Check / build (RAK_4631_room_server) (push) Has been cancelled
PR Build Check / build (wio-e5-mini_repeater) (push) Has been cancelled
Some checks failed
Build and deploy Docs site to GitHub Pages / github-pages (push) Has been cancelled
PR Build Check / build (Heltec_v3_companion_radio_ble) (push) Has been cancelled
PR Build Check / build (Heltec_v3_repeater) (push) Has been cancelled
PR Build Check / build (Heltec_v3_room_server) (push) Has been cancelled
PR Build Check / build (LilyGo_Tlora_C6_repeater_) (push) Has been cancelled
PR Build Check / build (PicoW_repeater) (push) Has been cancelled
PR Build Check / build (RAK_4631_companion_radio_ble) (push) Has been cancelled
PR Build Check / build (RAK_4631_repeater) (push) Has been cancelled
PR Build Check / build (RAK_4631_room_server) (push) Has been cancelled
PR Build Check / build (wio-e5-mini_repeater) (push) Has been cancelled
This commit is contained in:
@@ -3,16 +3,16 @@
|
|||||||
/* ------------------------------ Config -------------------------------- */
|
/* ------------------------------ Config -------------------------------- */
|
||||||
|
|
||||||
#ifndef LORA_FREQ
|
#ifndef LORA_FREQ
|
||||||
#define LORA_FREQ 915.0
|
#define LORA_FREQ 869.618
|
||||||
#endif
|
#endif
|
||||||
#ifndef LORA_BW
|
#ifndef LORA_BW
|
||||||
#define LORA_BW 250
|
#define LORA_BW 62.5
|
||||||
#endif
|
#endif
|
||||||
#ifndef LORA_SF
|
#ifndef LORA_SF
|
||||||
#define LORA_SF 10
|
#define LORA_SF 8
|
||||||
#endif
|
#endif
|
||||||
#ifndef LORA_CR
|
#ifndef LORA_CR
|
||||||
#define LORA_CR 5
|
#define LORA_CR 8
|
||||||
#endif
|
#endif
|
||||||
#ifndef LORA_TX_POWER
|
#ifndef LORA_TX_POWER
|
||||||
#define LORA_TX_POWER 20
|
#define LORA_TX_POWER 20
|
||||||
@@ -443,6 +443,14 @@ void SensorMesh::handleCommand(uint32_t sender_timestamp, char* command, char* r
|
|||||||
board.setGpio(val);
|
board.setGpio(val);
|
||||||
}
|
}
|
||||||
sprintf(reply, "%x", board.getGpio());
|
sprintf(reply, "%x", board.getGpio());
|
||||||
|
} else if (memcmp(command, "readpin ", 8) == 0) {
|
||||||
|
uint8_t pin = atoi(&command[8]); // Pin-Nummer extrahieren
|
||||||
|
if (pin < 32) {
|
||||||
|
bool pin_state = board.readPin(pin); // Zustand des Pins auslesen
|
||||||
|
sprintf(reply, "%s", pin_state ? "ON" : "OFF");
|
||||||
|
} else {
|
||||||
|
strcpy(reply, "Err - invalid pin");
|
||||||
|
}
|
||||||
} else{
|
} else{
|
||||||
_cli.handleCommand(sender_timestamp, command, reply); // common CLI commands
|
_cli.handleCommand(sender_timestamp, command, reply); // common CLI commands
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,9 @@ void setup() {
|
|||||||
|
|
||||||
command[0] = 0;
|
command[0] = 0;
|
||||||
|
|
||||||
|
// Konfiguriere GPIO 2 als Eingang mit Pull-Up
|
||||||
|
pinMode(2, INPUT_PULLUP);
|
||||||
|
|
||||||
sensors.begin();
|
sensors.begin();
|
||||||
|
|
||||||
the_mesh.begin(fs);
|
the_mesh.begin(fs);
|
||||||
|
|||||||
@@ -48,6 +48,25 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implement an actual getGpio for ESP32 boards
|
||||||
|
uint32_t getGpio() override {
|
||||||
|
uint32_t state = 0;
|
||||||
|
for (int pin = 0; pin < 32; pin++) {
|
||||||
|
if (digitalRead(pin) == HIGH) {
|
||||||
|
state |= (1 << pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the state of a single pin
|
||||||
|
public:
|
||||||
|
// Liest den Zustand eines einzelnen Pins (0-31)
|
||||||
|
bool readPin(uint8_t pin) {
|
||||||
|
if (pin >= 32) return false; // Ungültiger Pin
|
||||||
|
return digitalRead(pin) == HIGH;
|
||||||
|
}
|
||||||
|
|
||||||
// Temperature from ESP32 MCU
|
// Temperature from ESP32 MCU
|
||||||
float getMCUTemperature() override {
|
float getMCUTemperature() override {
|
||||||
uint32_t raw = 0;
|
uint32_t raw = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user