Which system do you use? Android, Ubuntu, OOWOW or others?
Android – built from Khadas Git sources
Which version of system do you use? Please provide the version of the system here:
Android 14, Android 13
Please describe your issue below:
The Khadas Edge2 comes with built-in sensors (gyroscope, accelerometer) whose data can be combined to determine a sense of orientation (resulting in a virtual orientation sensor). This way, an Android system can rotate the screen depending on the orientation of the board.
Now, here’s a problem with the currently used approach – the orientation sensor assumes the board is facing the user like this:
(Front Facing User)
When you rotate the board, it correctly changes the rotation of the screen.
If we assume, the board’s back is facing the user, however:
(Back Facing User)
the screen contents would rotate in the opposite direction compared to how I rotate the board.
With Android phones, this is not a realistic scenario but Khadas boards are versatile devices that could be mounted in many different ways (front to user, back to user, sideways with the top or bottom or left or right edge facing the user etc.).
Desired Solution:
A user and compile-time configurable setting which makes it possible to invert gyroscope / accelerometer / orientation sensor data on one, two or all three axes.
We are not just asking for a way to invert the screen rotation. It’s crucial to
invert the underlying sensor data so that 3rd party applications that rely on
these data do also receive these adjustments.
Optionally, if possible, a calibration function could be provided as well which
automates the process of detecting the orientation of the board to then be able
to compensate it.
We are looking forward to your response. Thank you in advance.
Hi @ap-ss ,
I think you can modify this issue by changing the direction of the data reported by the gravity sensor.
The code path: kernel-6.1\drivers\input\sensors\accel\kxtj9.c
I hope it can help you.
Please modify the values in the layout of dts to meet your requirements. This value can be set to 0~7 digits, and you need to try these 8 digits until they meet your needs. I guess your placement position may be between 4 ~ 7, most likely the number 4. rk3588s-khadas-edge2.dts
Dear @goenjoy, dear @william.lin, thank you for your prompt replies. We will investigate whether it works as soon as we get to it.
In the meantime a catch-up question: is there a possibility to configure this option during runtime of the operating system? Could you, for instance write to some kernel filesystem file to change this parameter? Would you plan on integrating such a possibility if it doesn’t exist yet?
@ap-ss The latest code for edge2-android13 has added the Device Tree Overlay feature. Now you can synchronize the code to take a look. The specific usage document has not been updated yet.
@goenjoy Thank you for your work on this matter. We found the time to test the layout compile-time parameter and it works. It’s a good idea that you added the DTO feature to Android 13 and Android 14.
If I understand correctly, changing the Device Tree Overlay will take effect on the next reboot (being that it’s applied by Das U-Boot). Is this correct?
As you have not yet documented how to use the Device Tree Overlay as a developer, could you give me a hint towards the right direction? This is especially interesting for Android as that operating system typically limits access to system files from user space. The end goal is to have a GUI setting somewhere where the user can select how their Edge2 is mounted. From an Android app, how would I apply that setting? Should I write directly to the DTO file? If so, would I have to make the app a privileged app?
Thank you and best regards.
(On a side note apart from our own work, having a user-configurable setting for this might be a desirable feature for your “Khadas Settings” section in the System Settings, too.)