mcallegari wrote: ↑Thu Sep 28, 2023 11:59 am
Changelog second row:
"engine: consider EFX fade in"
Since your EFX has a fade in time, that would have to ring a bell. At least IMHO...
Also, infinite fade time doesn't really make any sense. Second bell that should have rang...
I was looking for a way to send you a PM regarding the issue with Pan Fine & Tilt Fine when fading. I spent 50+ years as a programmer, so I understand logic, but I'm not a C++ program. I asked ChatGPT take a look at the problem. I provided the following specifications:
Start with a 16 bit starting value (Pan is 1st 8 bit, Fine is 2nd), and a 16 bit target.
Have a timer that can be up to 24 hours, but is calculated in milliseconds.
Increment or decrement the starting value by x0001 so that it reaches the target value when the timer expires.
Output the value of the 1st 8 bits (Pan) every time it changes
Output the value of the 2nd 8 bit (Fine) every time it changes.
Again, I'm not a C++ programmer, so I can't really test this code, but I'm fairly certain my logic is correct. I also don't know how efficient this code is, and if it can execute properly if the movement is too much for the fade time allotted. I just hope it can help resolve the Fine issue.
#include <iostream>
#include <bitset>
#include <chrono>
#include <thread>
int main() {
// Specify the starting and ending values
uint16_t startValue = 0;
uint16_t endValue = 0xFFFF;
// Specify the maximum time limit in milliseconds (24 hours)
long long maxTimeMillis = 24 * 60 * 60 * 1000LL; // 24 hours in milliseconds
auto startTime = std::chrono::high_resolution_clock::now();
std::cout << "Incrementing/Decrementing:" << std::endl;
// Set a fixed time step for each iteration
constexpr int timeStepMillis = 10; // Adjust the time step as needed
// Variable to track the direction (1 for increment, -1 for decrement)
int direction = (endValue >= startValue) ? 1 : -1;
// Variables to store the last observed values
uint8_t lastFirst8bits = static_cast<uint8_t>(startValue >> 8);
uint8_t lastSecond8bits = static_cast<uint8_t>(startValue & 0xFF);
for (uint16_t value = startValue; ; value += direction) {
// Extract the 1st 8 bits and 2nd 8 bits
uint8_t first8bits = static_cast<uint8_t>(value >> 8);
uint8_t second8bits = static_cast<uint8_t>(value & 0xFF);
// Output the second 8 bits in every iteration
std::cout << "Decimal: " << static_cast<unsigned>(value)
<< " | 2nd 8 bits: " << std::bitset<8>(second8bits);
// Output the first 8 bits only when they change
if (first8bits != lastFirst8bits) {
std::cout << " | 1st 8 bits: " << std::bitset<8>(first8bits);
// Update the last observed value of the first 8 bits
lastFirst8bits = first8bits;
}
std::cout << std::endl;
// Sleep for the fixed time step
std::this_thread::sleep_for(std::chrono::milliseconds(timeStepMillis));
// Check if the elapsed time exceeds the maximum time limit
auto currentTime = std::chrono::high_resolution_clock::now();
std::chrono::duration<long long, std::milli> elapsedMillis = currentTime - startTime;
if ((direction == 1 && value > endValue) || (direction == -1 && value < endValue) || elapsedMillis.count() >= maxTimeMillis) {
std::cout << "Time limit reached or target value reached. Exiting." << std::endl;
break;
}
}
return 0;
}