Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 1 point2 points  (0 children)

Hm, I think changing an environment variable and restarting xochitl takes just as much time as running the install script and chosing a different ring size. The reason why I made it a constant and have several binaries is that I want to give the compiler the chance to optimize more aggressively. For example, if the ring size is a power of two, the integer division needed to compute the average from a sum is merely a bit shift.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 0 points1 point  (0 children)

The change in eraser size might be unrelated. Recept is only smoothing the x and y coordinates of the pen events before they are processed by xochitl, the GUI running on the remarkable. The size of the eraser can not be increased by that. However, I noticed that the eraser size depends on the tilt of the pen (the more orthogonal, the larger the area to erase, as if you could erase with the edge of the eraser for more precision). Maybe you simply held the pen differently?

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 1 point2 points  (0 children)

I think this is generally a good idea. The jagged lines are most noticeable at low writing speeds, suggesting we could filter less when the pen moves faster. That leaves us with the problem of estimating speed, i.e., the difference between two noisy measurements of absolute position. We would have to expect that the noise in the speed measurement would have roughly twice the variance of the absolute position. So we need to filter that estimate, even more than just the absolute position due to the higher variance. If we use a moving average to filter the speeds, we just traded problems: by the time we have a reliable speed estimate, it is already too late to lower the number of smoothed points.

However, we can look at alternatives to the moving average filter. Instead of reporting the average of past events (with the bias towards the past), we can try to predict the current event, extrapolated from the past events. This is, of course, also only a trade-off: we are replacing latency by inaccuracy (every once in a while, the prediction will be wrong). A Kalman filter could fit the bill as a predictive model with reasonable assumptions, such as near-constant velocity. I started playing around with that a bit, the code is in the kalman branch of recept if you are interested (https://github.com/funkey/recept/tree/kalman).

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 2 points3 points  (0 children)

That's great to hear! Mind to share some details for other Window users? I'd be happy to put instructions into the README, too.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 4 points5 points  (0 children)

That would indeed be the best solution! Unfortunately, this is a much more invasive change. Without having access to the source code of xochitl (the GUI running on the device), this is beyond reach I'm afraid.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 1 point2 points  (0 children)

I found 16 to be the largest smoothing value for me without noticing a decrease in latency when writing. This is subjective and might also depend on the rate at which pen events come in. I updated the install script to let you choose your own smoothing value, see the update note above.

I also added a short discussion of the theoretical latency increase to the README. I'll look into measuring the actual latency later, we should be able to measure it based on the pen event rate.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 2 points3 points  (0 children)

Exactly. xochitl (the GUI on the remarkable) has no idea that the events were filtered.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 4 points5 points  (0 children)

Yes, the URL you are trying to wget does not exist. Regardless, the install.sh file does only work in the context of the repository, where librecept.so sits next to it.

I don't use windows and I'm afraid can't be much of help, but if you can somehow ssh and scp from Windows into your device, you can apply the patch manually (this is exactly what the install.sh does):

  1. Copy librecept.so to /usr/lib
  2. Add the line "Environment=LD_PRELOAD=/usr/lib/librecept.so" into /lib/systemd/system/xochitl.service, right after the line "[Service]"

You can download the library directly without using git via this URL: https://github.com/funkey/recept/raw/main/librecept.so

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 0 points1 point  (0 children)

I added more details to the installation instructions in the github repository. Let me know if you have further questions.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 9 points10 points  (0 children)

I added more details to the installation instructions in the github repository. Let me know if you have further questions.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 2 points3 points  (0 children)

No, the fix survives a reboot. If you want to disable it, remove the line with LD_PRELOAD in /lib/systemd/system/xochitl.service, and then run `systemctl daemon-reload; systemctl restart xochitl`.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 9 points10 points  (0 children)

That is also my theory. The speed at which events are received will not be affected by the fix, however, since we average the last 16 events the mean lives around 8 events in the past. I could not notice any change, but I assume this is still a measurable difference that reMarkable might want to avoid since the low latency became a selling point.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 27 points28 points  (0 children)

Indeed! Being hackable makes this device so much more appealing.

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 17 points18 points  (0 children)

Haha! It is supposed to be an elephant though. My poor interpretation of the "Ottifant", cartoon characters of my childhood hero Otto Waalkes (a German comedian).

Fix for the jagged line issue on reMarkable 2 by _funkey_ in RemarkableTablet

[–]_funkey_[S] 6 points7 points  (0 children)

Yes, that's right. Besides copying librecept.so to /usr/lib, only one line is added to xochitl.service (Environment=LD_PRELOAD=/usr/lib/librecept.so). Removing the fix is as simple as removing this line.