-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependencies and remove unnecessary code
- Loading branch information
Showing
25 changed files
with
647 additions
and
213 deletions.
There are no files selected for viewing
Binary file not shown.
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,4 @@ | ||
upload: | ||
pio run -t upload | ||
file: | ||
pio run -t uploadfs |
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 @@ | ||
# ESP32 Control |
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,28 @@ | ||
{ | ||
"name": "test", | ||
"stops": [ | ||
{ | ||
"stop_id": "test_s1", | ||
"pin": 13 | ||
} | ||
], | ||
"points": [ | ||
{ | ||
"point_id": "test_p1", | ||
"pin": 14 | ||
} | ||
], | ||
"detectors": [ | ||
{ | ||
"block_id": "test_b1", | ||
"target": "OPEN", | ||
"pin": 15 | ||
} | ||
], | ||
"nfcs": [ | ||
{ | ||
"nfc_id": "test_t1", | ||
"pin": 15 | ||
} | ||
] | ||
} |
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,64 @@ | ||
#include "IOManager.h" | ||
|
||
IOManager::IOManager(PubSubClient client) | ||
{ | ||
client = client; | ||
POINT_LIST_INDEX = 0; | ||
STOP_LIST_INDEX = 0; | ||
DETECTOR_LIST_INDEX = 0; | ||
// NFC_LIST_INDEX = 0; | ||
} | ||
|
||
void IOManager::addPoint(uint8_t pin, String point_id) | ||
{ | ||
POINT_LIST[POINT_LIST_INDEX].attach(pin, point_id); | ||
POINT_LIST_INDEX++; | ||
} | ||
|
||
void IOManager::addStop(uint8_t pin, String stop_id) | ||
{ | ||
STOP_LIST[STOP_LIST_INDEX].attach(pin, stop_id); | ||
STOP_LIST_INDEX++; | ||
} | ||
|
||
void IOManager::addDetector(uint8_t pin, String block_id, String target) | ||
{ | ||
DETECTOR_LIST[DETECTOR_LIST_INDEX].init(block_id, target, pin, client); | ||
DETECTOR_LIST_INDEX++; | ||
} | ||
|
||
void IOManager::setPointState(String point_id, POINT_STATE state) | ||
{ | ||
for (int i = 0; i < POINT_LIST_INDEX; i++) | ||
{ | ||
if (POINT_LIST[i].getId() == point_id) | ||
{ | ||
POINT_LIST[i].set_state(state); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
void IOManager::setStopState(String stop_id, STOP_STATE state) | ||
{ | ||
for (int i = 0; i < STOP_LIST_INDEX; i++) | ||
{ | ||
if (STOP_LIST[i].getId() == stop_id) | ||
{ | ||
STOP_LIST[i].set_state(state); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
void IOManager::loop() | ||
{ | ||
for (int i = 0; i < DETECTOR_LIST_INDEX; i++) | ||
{ | ||
DETECTOR_LIST[i].loop(); | ||
} | ||
// for (int i = 0; i < NFC_LIST_INDEX; i++) | ||
// { | ||
// NFC_LIST[i].loop(); | ||
// } | ||
} |
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 @@ | ||
#ifndef IOMANAGER_H | ||
#define IOMANAGER_H | ||
#include <Arduino.h> | ||
#include <PassDetector.h> | ||
#include <PointRail.h> | ||
#include <StopRail.h> | ||
|
||
#define MAX_POINT_NUM 5 | ||
#define MAX_STOP_NUM 5 | ||
#define MAX_DETECTOR_NUM 5 | ||
#define MAX_NFC_NUM 5 | ||
|
||
class IOManager | ||
{ | ||
public: | ||
IOManager(PubSubClient client); | ||
PubSubClient client; | ||
void addStop(uint8_t pin, String stop_id); | ||
void addPoint(uint8_t pin, String point_id); | ||
|
||
void setStopState(String stop_id, STOP_STATE state); | ||
void setPointState(String point_id, POINT_STATE state); | ||
void addDetector(uint8_t pin, String block_id, String target); | ||
// addNfc(uint8_t pin, String block_id); | ||
|
||
void loop(); | ||
|
||
private: | ||
uint8_t POINT_LIST_INDEX; | ||
uint8_t STOP_LIST_INDEX; | ||
uint8_t DETECTOR_LIST_INDEX; | ||
// uint8_t NFC_LIST_INDEX; | ||
PointRail POINT_LIST[MAX_POINT_NUM]; | ||
StopRail STOP_LIST[MAX_STOP_NUM]; | ||
PassDetector DETECTOR_LIST[MAX_DETECTOR_NUM]; | ||
// NfcReader NFC_LIST[MAX_NFC_NUM]; | ||
}; | ||
|
||
#endif |
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
8 changes: 4 additions & 4 deletions
8
hardware/esp32-control/src/switch.cpp → hardware/esp32-control/src/PassDetector.cpp
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,35 @@ | ||
#include "PointRail.h" | ||
|
||
PointRail::PointRail() {} | ||
|
||
void PointRail::attach(uint8_t pin, String point_id) | ||
{ | ||
point_id = point_id; | ||
pin = pin; | ||
servo.setPeriodHertz(50); | ||
} | ||
|
||
void PointRail::set_state(POINT_STATE state) | ||
{ | ||
state = state; | ||
servo.attach(pin, 500, 2400); | ||
if (state == POINT_STATE_NORMAL) | ||
{ | ||
servo.write(POINT_STRAIGHT_ANGLE); | ||
} | ||
else | ||
{ | ||
servo.write(POINT_REVERSE_ANGLE); | ||
} | ||
servo.detach(); | ||
} | ||
|
||
String PointRail::getId() | ||
{ | ||
return point_id; | ||
} | ||
|
||
POINT_STATE PointRail::getState() | ||
{ | ||
return state; | ||
} |
Oops, something went wrong.