Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Onyx Boox

Notices

Reply
 
Thread Tools Search this Thread
Old 04-30-2012, 07:51 AM   #1
tuxor
9.7-inch-user
tuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animals
 
Posts: 303
Karma: 6731
Join Date: Oct 2011
Location: Germany
Device: Onyx Boox M92
PyOnyx: API for Onyx libs. I need your help!

Hi,

since Python is such a pythonic language and C++ simply isn't, I would love to be able to write small (gui) applications for my Onyx Boox in Python. Maybe you feel the same? Then I really need your help!

At first, it looks like cross compiling PyQt and Python is sufficient. But I have succesfully done this and still only non-graphical applications work. The reason is missing eink screen support in Qt. Onyx handled this issue by writing a big stack of c++ libraries that wrap around the original Qt libraries provided with the imx508 toolchain (https://github.com/onyx-intl/toolcha.../master/imx508).

So there is still hope, that we will finally be able to write applications for Onyx Boox devices in Python by taking the effort of writing a Python API for the Onyx libraries. And writing a Python API is actually not that hard, if you use SIP (http://riverbankcomputing.com/software/sip/download).

I set up the necessary git repo on https://github.com/tuxor1337/PyOnyx

For compatibility reasons I built PyQt version 4.8.5 using SIP 4.12.2. So a potential API for the onyx libraries will have to be built using the same SIP version. The source code for this version is available from the respective tarball (sip-4.12.2.tar.gz) in the PyOnyx repository. This tarball also contains the version specific documentation of SIP. The readily compiled Python and PyQt builds are available from "onyx_pyqt.zip".

Unfortunately, I have no experience with SIP so far. So it would be great if we found somebody with insight in this whole topic of writing an API.

In the end, I want to stress that I won't be able to carry out this project alone. Maybe it's not even that much work (potentially 244 header files to convert, but each one we convert can immediately be used inside of Python) once you know how SIP works. But since I'm really unfamiliar with C++ and SIP, I will have a hard time making my first steps in this project without your support. So I won't start serious work on this project, as long as I'm alone...

Last edited by tuxor; 04-30-2012 at 06:56 PM.
tuxor is offline   Reply With Quote
Old 04-30-2012, 07:01 PM   #2
tuxor
9.7-inch-user
tuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animals
 
Posts: 303
Karma: 6731
Join Date: Oct 2011
Location: Germany
Device: Onyx Boox M92
To give a simple example I set up a simple configure.py file and the first sip file: onyx_dialog.sip. Unfortunately message_dialog.sip is not working at the moment. But I'm sure now this whole project will turn out much easier than expected.

Please note: It's _not_ necessary to write an API for _all_ of those onyx/* libraries. We only pick the methods and classes we'd like to use in our Python code. It's really easy to add new methods and classes once we have a basic selection of classes/methods - simply because (once you are familiar with the SIP syntax) the hardest work to do here is setting up the configure.py and pyonyxconfig.py.in files.
tuxor is offline   Reply With Quote
Old 05-01-2012, 05:05 AM   #3
spaetz
Enthusiast
spaetz began at the beginning.
 
Posts: 25
Karma: 30
Join Date: Sep 2009
Location: Switzerland
Device: Boox M92, formerly iRex DR1000 (broke just as they went bankrupt)
Hi tuxor. I've never used sip and see that you have posted a cross-compiled python. Does it include ctypes which is included in the stdlib? That can also be used to create C-lib interfaces and I have limited experiencence in doing so. (not sure if/how well it works on ARM though).

I have ordered my M92 but have still to receive it (thanks booxtor ;-)), and would be interested in getting some tools done, preferrably in python if at all possible :-)
spaetz is offline   Reply With Quote
Old 05-01-2012, 05:22 AM   #4
tuxor
9.7-inch-user
tuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animals
 
Posts: 303
Karma: 6731
Join Date: Oct 2011
Location: Germany
Device: Onyx Boox M92
Yes, I built python with CTypes, though I didn't test it yet on my M92, because I have no idea of that module.

Since the onyx libs are really closely connected to the Qt libs, it looked pretty obvious to me connecting any Python API of the onyx libs with the corresponding PyQt modules, which is easy when using SIP, since PyQt is also built using SIP.

Is something similar possible with CTypes?

Last edited by tuxor; 05-01-2012 at 05:34 AM.
tuxor is offline   Reply With Quote
Old 05-01-2012, 05:25 AM   #5
tuxor
9.7-inch-user
tuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animals
 
Posts: 303
Karma: 6731
Join Date: Oct 2011
Location: Germany
Device: Onyx Boox M92
By the way, I compiled the first module for the PyOnyx API and I'm running into a segmentation fault, when using this code.
Code:
import PyOnyx 
from sys import argv
from PyQt4.QtGui import QApplication,QMessageBox
from PyQt4.QtCore import QObject

app = QApplication(argv)
app.setApplicationName("ack_widget")
about = PyOnyx.ui.MessageDialog(QMessageBox.Icon(QMessageBox.Information), app.tr(argv[1]), app.tr(argv[2]), QMessageBox.No | QMessageBox.Yes)

PyOnyx.sys.SysStatus.instance().setSystemBusy(False)

decision = about.exec_()

print decision
Any ideas how to debug a segmentation fault? It must be somehow related to the line with "about = PyOnyx.ui.MessageDialog(". Because when I comment out everything behind that line, the script runs fine. And the "PyOnyx.sys.SysStatus..." line runs fine, when tested separately.

Last edited by tuxor; 05-01-2012 at 06:07 AM.
tuxor is offline   Reply With Quote
Old 05-01-2012, 05:41 AM   #6
spaetz
Enthusiast
spaetz began at the beginning.
 
Posts: 25
Karma: 30
Join Date: Sep 2009
Location: Switzerland
Device: Boox M92, formerly iRex DR1000 (broke just as they went bankrupt)
Quote:
Originally Posted by tuxor View Post
Yes, I built python with CTypes, though I didn't test it yet on my M92, because I have no idea of that module.
Mmmh, given that both PyQT and the boox SDK code is C++, ctypes might not be so useful after all, it binds well to C libraries but not C++.

Never used SIP (or QT really), so I am afraid I cannot really help with the segfault. But I think this would be a very promising way forward. While it is a resource-constrained device, I find programming in python to be much more productive than anything else. (Once I get my device, I will try to compile that too).
spaetz is offline   Reply With Quote
Old 05-01-2012, 05:43 AM   #7
spaetz
Enthusiast
spaetz began at the beginning.
 
Posts: 25
Karma: 30
Join Date: Sep 2009
Location: Switzerland
Device: Boox M92, formerly iRex DR1000 (broke just as they went bankrupt)
Quote:
Originally Posted by tuxor View Post
Any ideas how to debug a segmentation fault?
I would think that getting a stack trace with GDB would be the next step: http://wiki.python.org/moin/DebuggingWithGdb

You run the code on the M92 or on the host?
spaetz is offline   Reply With Quote
Old 05-01-2012, 06:11 AM   #8
tuxor
9.7-inch-user
tuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animals
 
Posts: 303
Karma: 6731
Join Date: Oct 2011
Location: Germany
Device: Onyx Boox M92
Running the code on the host won't work because of missing QWS. So I have to test everything on the M92. And there I don't have gdb

Last edited by tuxor; 05-01-2012 at 06:14 AM.
tuxor is offline   Reply With Quote
Old 05-01-2012, 12:30 PM   #9
raphman
Junior Member
raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!raphman , Klaatu Barada Niktu!
 
Posts: 8
Karma: 5088
Join Date: Dec 2010
Location: Regensburg, Germany
Device: none
Hmm, is it really necessary to create new bindings?

I have only taken a short look at the Boox SDK but it seems that all that is needed to update the screen is a re-implementation of https://github.com/onyx-intl/booxsdk...reen_proxy.cpp (and some accompanying files) in Python.
Apparently, the screen is updated by sending one of a few update commands to the display server (correct name?) over UDP. The display server then copies the appropriate bitmap from framebuffer to display controller and updates the screen using a configurable waveform.
Not sure whether it is easily possible to detect widget updates in PyQt, however.
At least, it should be possible to manually update the screen by sending the appropriate command via UDP.
Did I overlook something?
raphman is offline   Reply With Quote
Old 05-01-2012, 04:43 PM   #10
tuxor
9.7-inch-user
tuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animals
 
Posts: 303
Karma: 6731
Join Date: Oct 2011
Location: Germany
Device: Onyx Boox M92
Okay. So let's come to terms: We try to get a Python API for that screen_proxy.h and once we have that, we can still decide whether to expand the API for other Onyx libraries or not. Sounds like a sensible compromise
tuxor is offline   Reply With Quote
Old 05-01-2012, 06:02 PM   #11
tuxor
9.7-inch-user
tuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animals
 
Posts: 303
Karma: 6731
Join Date: Oct 2011
Location: Germany
Device: Onyx Boox M92
The segmentation fault is gone now. My little test script from http://www.mobileread.com/forums/sho...62&postcount=5 works fine. (Except for the fact, that the answer yes/no can't be selected using the joystick, but only using the pen?!)

The ScreenProxy class with all methods listed here: https://github.com/tuxor1337/PyOnyx/...reen_proxy.sip ... is now successfully implemented in my PyOnyx API. Now please show me an example how to use this ScreenProxy with standard PyQt, because I don't have the time to read through all the C++ code at the moment (and my C++ skills are really lousy).
tuxor is offline   Reply With Quote
Old 05-01-2012, 10:38 PM   #12
pkbo
Addict
pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.
 
Posts: 208
Karma: 151212
Join Date: Sep 2006
Device: PocketBook 360°
I don't have any skills inPython or PyQt so consider below as pseudocode. If you subclass some widget you may override event() method:
Code:
def event(self, event):
        ret =  Qwidget.event(self, event)
        if (event.type()==QEvent.UpdateRequest) and PyOnyx.screen.ScreenProxy.instance().isUpdateEnabled():
             PyOnyx.screen.ScreenProxy.instance().updateWidget(self, PyOnyx.screen.ScreenProxy.GU, true, PyOnyx.screen.ScreenProxy.WAIT_ALL)
        return ret
If you don't want to subclass a widget you may install event filter to it and process UpdateRequest event there, onyx/screen/screen_update_watcher.cpp is an example of such filter. It is also possible to subclass QApplication and override notify() method and to update screen there in this case you will not need to worry about screen refresh for every widget.

Last edited by pkbo; 05-01-2012 at 11:58 PM.
pkbo is offline   Reply With Quote
Old 05-02-2012, 01:14 PM   #13
tuxor
9.7-inch-user
tuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animals
 
Posts: 303
Karma: 6731
Join Date: Oct 2011
Location: Germany
Device: Onyx Boox M92
Working, but really slow, and really ugly. And still only pen input is recognized - joystick input seems to be ignored...

Here is the complete code of what I tested:
Code:
import sys
from PyQt4.QtGui import QApplication, QMessageBox
from PyQt4.QtCore import QEvent
from PyOnyxScreen import ScreenProxy, ScreenCommand

class OnyxQWidget(QMessageBox):
   def __init__(self):
      QMessageBox.__init__(self)
      self.setText("Hello, World!")
      
   def event(self, event):
        ret =  QMessageBox.event(self, event)
        if (event.type()==QEvent.UpdateRequest) and ScreenProxy.instance().isUpdateEnabled():
             ScreenProxy.instance().updateWidget(self, ScreenProxy.GU, True, ScreenCommand.WAIT_ALL)
        return ret
 
a = QApplication(sys.argv)

wid = OnyxQWidget()
print wid.exec_()
Any ideas, why the joystick input isn't working?
tuxor is offline   Reply With Quote
Old 05-02-2012, 01:49 PM   #14
tuxor
9.7-inch-user
tuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animalstuxor is kind to children and small, furry animals
 
Posts: 303
Karma: 6731
Join Date: Oct 2011
Location: Germany
Device: Onyx Boox M92
For a demonstration video see here: http://www.2shared.com/video/4yMZbIaG/pyonyx_test.html (~30 MB MP4-file from my smartphone camera)

It's bad quality and during the first 11 seconds nothing happens, because I was so damn slow. Here the explanation, what I do in this video:
[00:11] I start the test script (see last post) from my serial console via usb.
[00:14] The dialog window is there
[00:18] I approach the screen with the camera (but of course the camera loses focus)
[00:31] I press the "OK" button with my pen
[00:37] The message dialog is gone
[00:42] I restart the python script just like at 00:11
[00:47]-[01:00] I approach the screen with the camera
[01:03] I press the middle of the joystick
[01:09] demonstration what really happened when the message dialog disappeared (the currently selected entry of the underlying menu is "pressed")

So, what do we learn from this?
- The message dialog is ugly on first try and neat on second try. So the screen is indeed not properly refreshed despite the ScreenProxy directive.
- The whole performance of the dialog is extremely bad.
- Joystick input is redirected to the underlying menu as if the message dialog didn't have the focus!
- My smartphone camera is really, really bad...

Most important questions:
- How do we get the dialog window to be shown nicely every time it's executed?
- How do we get the focus for our QMessageBox?
- How can we dramatically ameliorate the performance?
tuxor is offline   Reply With Quote
Old 05-03-2012, 12:06 PM   #15
pkbo
Addict
pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.pkbo inspires wonder wherever he or she goes.
 
Posts: 208
Karma: 151212
Join Date: Sep 2006
Device: PocketBook 360°
Quote:
Originally Posted by tuxor View Post
Most important questions:
- How do we get the dialog window to be shown nicely every time it's executed?
- How do we get the focus for our QMessageBox?
- How can we dramatically ameliorate the performance?
1. I think you need to update screen in case of QEvent::WindowActivate and probably GC waveform should be used in this case. Or you may override exec() method like it is done in the Onyx MessageDialog:
Code:
    show();
    onyx::screen::instance().flush();
    onyx::screen::instance().updateWidgetRegion(
        0,
        outbounding(parentWidget()),
        onyx::screen::ScreenProxy::GC,
        false,
        onyx::screen::ScreenCommand::WAIT_ALL);
    return QMessageBox::exec();
2. I'm not sure how does it work in this case would it get the focus if you will make .oar script and execute it from the menu?
3. The screen update will be faster if only black and white colors will be used so as the first step you may restyle the controls to use black and white colors using setStyleSheet() method of Qapplication or some specific widget.
pkbo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why no mad rush to Int'l e-lending libs? 1611mac General Discussions 18 11-08-2011 12:20 PM
copy between libs, keep custom fields drMerry Library Management 1 05-24-2011 06:56 PM
ONYX BOOX 1.5.1 A60/X60/X60S(onyx-international.com) samerghafik Onyx Boox 4 01-03-2011 01:32 AM
DR800 non-stripped libs? pleeease? dima_tr iRex Developer's Corner 0 10-20-2010 08:14 AM
iLiad Possible to add libs to iLiad SDK? ericshliao iRex Developer's Corner 0 12-25-2007 04:37 AM


All times are GMT -4. The time now is 12:53 AM.


MobileRead.com is a privately owned, operated and funded community.