Skip to content

Commit

Permalink
Switch to scan mode on startup to deal with multi networks
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Dec 21, 2023
1 parent 22af1f7 commit f5d0707
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.settings*
/Release/
/sloeber.ino.cpp
/spec.d
7 changes: 3 additions & 4 deletions GetIMU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ void GetIMU::event(float * buffer) {
bufferINTERNAL[9]=bno->orientationY;
bufferINTERNAL[10]=bno->orientationX;
bufferINTERNAL[11]=bno->orientationZ;


for (int i = 0; i < NUM_IMU_VALUES; i++) {
buffer[i] = bufferINTERNAL[i];
}

}
bool GetIMU::loop() {
//print();
}

void GetIMU::setXPosition(float x){
bufferINTERNAL[12] =x;
}
Expand Down
2 changes: 1 addition & 1 deletion GetIMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GetIMU: public PacketEventAbstract {
// Buffer contains data from the packet cming in at the start of the function
// User data is written into the buffer to send it back
void event(float * buffer);
bool loop();

void startSensor(EasyBNO055_ESP * _bno);
void print();

Expand Down
13 changes: 10 additions & 3 deletions MarcosFirmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,26 @@ void otherI2CUpdate(){
}

void setup() {
manager.setup();
manager.setupScan();
manager.startThread();
servos = new ServoServer();
while(manager.getState()!=Connected){
vTaskDelay(10); //sleep 10ms
}
Serial.println("Starting Firmware Setup after WiFi connection");
sensor = new GetIMU();
bno.start(&otherI2CUpdate);
sensor->startSensor(&bno);
Serial.println("Loading with name: " + name[0]);
servos = new ServoServer();

coms.attach(new NameCheckerServer(name));
coms.attach((PacketEvent*)sensor);
coms.attach((PacketEvent*)servos);
Serial.println("Starting Firmware Loop");

}

void loop() {
manager.loop();
if(manager.getState()==Connected)
coms.server();
}
1 change: 1 addition & 0 deletions ServoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ void ServoServer::event(float *buffer) {
//if(value>0&& value<254)
servos[i]->write(constrain(value, 0, 180));
}

}

0 comments on commit f5d0707

Please sign in to comment.