|
|
@ -15,7 +15,7 @@
|
|
|
|
// WiFi stuff
|
|
|
|
// WiFi stuff
|
|
|
|
const char* ssid = "sirening";
|
|
|
|
const char* ssid = "sirening";
|
|
|
|
const char* pwd = "alarm_11735";
|
|
|
|
const char* pwd = "alarm_11735";
|
|
|
|
const IPAddress ip(192, 168, 4, 201);
|
|
|
|
const IPAddress ip(192, 168, 4, 203);
|
|
|
|
const IPAddress gateway(192, 168, 4, 1);
|
|
|
|
const IPAddress gateway(192, 168, 4, 1);
|
|
|
|
const IPAddress subnet(255, 255, 0, 0);
|
|
|
|
const IPAddress subnet(255, 255, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
@ -33,7 +33,7 @@ AiEsp32RotaryEncoder ampEncoderButton = AiEsp32RotaryEncoder(33, 25, 26, -1, 4);
|
|
|
|
float frequency = 0;
|
|
|
|
float frequency = 0;
|
|
|
|
float amplitude = 0;
|
|
|
|
float amplitude = 0;
|
|
|
|
const int ports = 6;
|
|
|
|
const int ports = 6;
|
|
|
|
const int motorIndex = 0;
|
|
|
|
const int motorIndex = 2;
|
|
|
|
|
|
|
|
|
|
|
|
// Display Defs
|
|
|
|
// Display Defs
|
|
|
|
#define I2C_ADDRESS 0x3C
|
|
|
|
#define I2C_ADDRESS 0x3C
|
|
|
@ -49,11 +49,11 @@ void killAll() {
|
|
|
|
updateAmp(0.0);
|
|
|
|
updateAmp(0.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float hzToRads(int freq){
|
|
|
|
float hzToRads(float freq){
|
|
|
|
return freq * TWO_PI / ports;
|
|
|
|
return freq * TWO_PI / ports;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float rpmToRads(int rpm){
|
|
|
|
float rpmToRads(float rpm){
|
|
|
|
return (rpm / 60) * TWO_PI;
|
|
|
|
return (rpm / 60) * TWO_PI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -81,11 +81,17 @@ void setupOSC(){
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
OscWiFi.subscribe(settings_port, "/freq", [](const OscMessage& m) {
|
|
|
|
OscWiFi.subscribe(settings_port, "/freq", [](const OscMessage& m) {
|
|
|
|
updateFreq(m.arg<float>(0));
|
|
|
|
float input = m.arg<float>(0);
|
|
|
|
|
|
|
|
if(input < 500.0 && input >= 0.0){
|
|
|
|
|
|
|
|
updateFreq(input);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
OscWiFi.subscribe(settings_port, "/amp", [](const OscMessage& m) {
|
|
|
|
OscWiFi.subscribe(settings_port, "/amp", [](const OscMessage& m) {
|
|
|
|
updateAmp(m.arg<float>(0));
|
|
|
|
float input = m.arg<float>(0);
|
|
|
|
|
|
|
|
if(input < 500.0 && input >= 0.0){
|
|
|
|
|
|
|
|
updateAmp(input);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -104,19 +110,21 @@ void setupEncoderButton(AiEsp32RotaryEncoder& eb, char* val){
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
eb.setup(readAmpEncoderISR);
|
|
|
|
eb.setup(readAmpEncoderISR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eb.setBoundaries(0, 4000, false);
|
|
|
|
eb.setBoundaries(0, 5000, false);
|
|
|
|
eb.setAcceleration(1000);
|
|
|
|
eb.setAcceleration(1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//This needs to be more sophisticated. Moving on if it disconnects...
|
|
|
|
//This needs to be more sophisticated. Moving on if it disconnects...
|
|
|
|
void initWiFi() {
|
|
|
|
void initWiFi() {
|
|
|
|
|
|
|
|
int attempts = 0;
|
|
|
|
WiFi.mode(WIFI_STA);
|
|
|
|
WiFi.mode(WIFI_STA);
|
|
|
|
WiFi.begin(ssid, pwd);
|
|
|
|
WiFi.begin(ssid, pwd);
|
|
|
|
WiFi.config(ip, gateway, subnet);
|
|
|
|
WiFi.config(ip, gateway, subnet);
|
|
|
|
Serial.println();
|
|
|
|
Serial.println();
|
|
|
|
Serial.print("Connecting to WiFi ..");
|
|
|
|
Serial.print("Connecting to WiFi ..");
|
|
|
|
while (WiFi.status() != WL_CONNECTED) {
|
|
|
|
while (WiFi.status() != WL_CONNECTED && attempts < 5) {
|
|
|
|
Serial.print('.');
|
|
|
|
Serial.print('.');
|
|
|
|
|
|
|
|
attempts += 1;
|
|
|
|
delay(1000);
|
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Serial.println(WiFi.localIP());
|
|
|
|
Serial.println(WiFi.localIP());
|
|
|
|