You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The triangle waveform generated by pslab-android was messed up due to a difference in how the modulo operator is handled in Python and Java. pslab-python uses this function:
y = abs(x % 4 - 2) - 1, -1 <= x < 3
In Python, -1 % 4 == 3, so this results in:
But in Java, the modulo operator return the negative remainder if the dividend is negative; -1 % 4 == -1, so this function instead results in:
pslab-android now uses this function instead:
y = abs(x % 4 - 2), 0 <= x < 4
Which results in:
This function should also be used in pslab-python, for two reasons:
We want to minimize differences between pslab-python and pslab-android
As the bug in pslab-android demonstrates, it is unwise to rely on the behavior of the modulo operator with negative numbers
Since this change will change pslab-python's observerble behavior (i.e. the bytes it sends over serial), it will be necessary to re-record the serial traffic for the associated test case.
The text was updated successfully, but these errors were encountered:
fossasia/pslab-hardware#111
fossasia/pslab-android#2364
The triangle waveform generated by pslab-android was messed up due to a difference in how the modulo operator is handled in Python and Java. pslab-python uses this function:
y = abs(x % 4 - 2) - 1, -1 <= x < 3
In Python, -1 % 4 == 3, so this results in:
But in Java, the modulo operator return the negative remainder if the dividend is negative; -1 % 4 == -1, so this function instead results in:
pslab-android now uses this function instead:
y = abs(x % 4 - 2), 0 <= x < 4
Which results in:
This function should also be used in pslab-python, for two reasons:
Since this change will change pslab-python's observerble behavior (i.e. the bytes it sends over serial), it will be necessary to re-record the serial traffic for the associated test case.
The text was updated successfully, but these errors were encountered: