machining docs start

This commit is contained in:
2025-04-21 22:22:43 +02:00
parent f0744a5ec0
commit 3bd7a07563
4 changed files with 318 additions and 11 deletions

View File

@@ -8,6 +8,7 @@ int mapPot(int normalizedValue);
int analogReadMultiPlexer(int addressA, int addressB, int addressC, int addressD, int pin);
void espNow();
void readAllMultiPlexer();
void espNowLoop();
const int MAXPWMVALUE = 1000;
const int MINPWMVALUE = 2000;
@@ -40,31 +41,31 @@ void setup()
void loop()
{
readAllMultiPlexer();
// Set values to send
JoystickData.PWMCH1 = mapPot(analogReadMultiPlexer(0, 0, 0, 0, A0)); //Right joystick Y
JoystickData.PWMCH2 = mapPot(analogReadMultiPlexer(1, 0, 0, 0, A0)); // Right joystick X
JoystickData.PWMCH3 = mapPot(analogReadMultiPlexer(0, 0, 0, 1, A0)); // left joystick Y
JoystickData.PWMCH4 = mapPot(analogReadMultiPlexer(1, 0, 0, 1, A0)); // left joystick X
Serial.print("PWMCH1: ");
Serial.println(JoystickData.PWMCH1);
Serial.print(" PWMCH2: ");
Serial.println(JoystickData.PWMCH2);
Serial.print(" PWMCH3: ");
Serial.println(JoystickData.PWMCH3);
Serial.print(" PWMCH4: ");
Serial.println(JoystickData.PWMCH4);
// Send message via ESP-NOW
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *)&JoystickData, sizeof(JoystickData));
if (result == ESP_OK)
{
// Serial.println("Sent with success");
}
else
{
// Serial.println("Error sending the data");
}
espNowLoop();
delay(10); // delay to avoid hammering the radio and to save power/heat
}
int mapPot(int normalizedValue)
{
return map(normalizedValue, 400, 2500, MINPWMVALUE, MAXPWMVALUE); // map the normalized value to the PWM range
}
//legacy stuff for original potsliders
int normalizePot(int pin, int minValue) // normalize the pot value to a range of 80 to 4095 instead of 0 to 4095 because the potmeter is at lower values not accurate
{
int pot = analogRead(pin);
@@ -145,4 +146,17 @@ void readAllMultiPlexer()
Serial.println(analogReadMultiPlexer(0, 1, 1, 1, A0));
Serial.print("1,1,1,1: ");
Serial.println(analogReadMultiPlexer(1, 1, 1, 1, A0));
}
void espNowLoop(){
// Send message via ESP-NOW
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *)&JoystickData, sizeof(JoystickData));
if (result == ESP_OK)
{
// Serial.println("Sent with success");
}
else
{
// Serial.println("Error sending the data");
}
}