无法在触摸屏中使用 3.5 的 Raspberry Pi 3 上成功启动 Kivy 应用程序

Posted

技术标签:

【中文标题】无法在触摸屏中使用 3.5 的 Raspberry Pi 3 上成功启动 Kivy 应用程序【英文标题】:Can't successfully start Kivy applications on Raspberry Pi 3 with 3.5 in Touchscreen 【发布时间】:2016-08-20 05:47:22 【问题描述】:

我遵循了所有关于将 Kivy 安装到 Raspberry Pi 的指南。

我的触摸屏工作正常,我认为 Kivy 无法正常启动与此无关。

尝试启动各种 Kivy 演示会导致似乎是部分启动,但随后它会挂起......也许我的 config.ini 配置不正确?

例如,为示例/演示/图片/运行“python main.py”会给我:

[INFO   ] [Logger      ] Record log in /home/pi/.kivy/logs/kivy_16-04-25_12.txt
[INFO   ] [Kivy        ] v1.9.2-dev0
[INFO   ] [Python      ] v2.7.9 (default, Mar  8 2015, 00:52:26)
[GCC 4.9.2]
[INFO   ] [Factory     ] 193 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif, img_pygame, img_pil (img_ffpyplayer ignored)
[INFO   ] [Window      ] Provider: egl_rpi
[INFO   ] [GL          ] OpenGL version <OpenGL ES 2.0>
[INFO   ] [GL          ] OpenGL vendor <Broadcom>
[INFO   ] [GL          ] OpenGL renderer <VideoCore IV HW>
[INFO   ] [GL          ] OpenGL parsed version: 2, 0
[INFO   ] [GL          ] Shading version <OpenGL ES GLSL ES 1.00>
[INFO   ] [GL          ] Texture max size <2048>
[INFO   ] [GL          ] Texture max units <8>
[INFO   ] [Shader      ] fragment shader: <Compiled>
[INFO   ] [Shader      ] vertex shader: <Compiled>
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [GL          ] NPOT texture support is available
[INFO   ] [Text        ] Provider: pygame
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [ProbeSysfs  ] device match: /dev/input/event0
[INFO   ] [MTD         ] Read event from </dev/input/event0>
[INFO   ] [ProbeSysfs  ] device match: /dev/input/event0
[INFO   ] [HIDInput    ] Read event from </dev/input/event0>
[INFO   ] [Base        ] Start application main loop
[INFO   ] [MTD         ] </dev/input/event0> range position X is 0 - 4095
[INFO   ] [MTD         ] </dev/input/event0> range position Y is 0 - 4095
[INFO   ] [MTD         ] </dev/input/event0> range touch major is 0 - 0
[INFO   ] [MTD         ] </dev/input/event0> range touch minor is 0 - 0
[INFO   ] [MTD         ] </dev/input/event0> range pressure is 0 - 255
[INFO   ] [MTD         ] </dev/input/event0> axes invertion: X is 0, Y is 0
[INFO   ] [MTD         ] </dev/input/event0> rotation set to 0
[INFO   ] [HIDMotionEvent] using <ADS7846 Touchscreen>
[INFO   ] [HIDMotionEvent] <ADS7846 Touchscreen> range ABS X position is 0 -     4095
[INFO   ] [HIDMotionEvent] <ADS7846 Touchscreen> range ABS Y position is 0 - 4095
[INFO   ] [HIDMotionEvent] <ADS7846 Touchscreen> range ABS pressure is 0 - 65535

然后它就永远挂起。没有弹出窗口,什么也没有。

从触摸屏运行、通过 SSH 运行以及通过tightvncserver 远程桌面运行都会发生同样的事情。

更新: 没有好消息,但有更多细节。使用带有键盘中断的基本应用程序 (https://kivy.org/docs/guide/basic.html#quickstart) 运行 python main.py -c kivy:log_level:trace

[INFO   ] [Logger      ] Record log in /home/pi/.kivy/logs/kivy_16-04-26_17.txt
[INFO   ] [Kivy        ] v1.9.2-dev0
[INFO   ] [Python      ] v2.7.9 (default, Mar  8 2015, 00:52:26)
[GCC 4.9.2]
[INFO   ] [Factory     ] 193 symbols loaded
[DEBUG  ] [Cache       ] register <kv.lang> with limit=None, timeout=None
[TRACE  ] [Builder     ] load file /home/pi/kivy/kivy/data/style.kv
[TRACE  ] [Parser      ] parsing 1271 lines
[TRACE  ] [Parser      ] got directive <kivy 1.0>
[TRACE  ] [Builder     ] build rule for <Label>
[TRACE  ] [Builder     ] build rule for <-Button,-ToggleButton>
[TRACE  ] [Builder     ] build rule for <BubbleContent>
[TRACE  ] [Builder     ] build rule for <BubbleButton>
[TRACE  ] [Builder     ] build rule for <Slider>
[TRACE  ] [Builder     ] build rule for <ProgressBar>
[TRACE  ] [Builder     ] build rule for <SplitterStrip>
[TRACE  ] [Builder     ] build rule for <Scatter>
[TRACE  ] [Builder     ] build rule for <RelativeLayout>
[TRACE  ] [Builder     ] build rule for <Image,AsyncImage>
[TRACE  ] [Builder     ] build rule for <EffectWidget>
[TRACE  ] [Builder     ] build rule for <TabbedPanelContent>
[TRACE  ] [Builder     ] build rule for <TabbedPanelStrip>
[TRACE  ] [Builder     ] build rule for <StripLayout>
[TRACE  ] [Builder     ] build rule for <TabbedPanelHeader>
[TRACE  ] [Builder     ] build rule for <Selector>
[TRACE  ] [Builder     ] build rule for <TextInput>
[TRACE  ] [Builder     ] build rule for <TextInputCutCopyPaste>
[TRACE  ] [Builder     ] build rule for <CodeInput>
[TRACE  ] [Builder     ] build rule for <TreeViewNode>
[TRACE  ] [Builder     ] build rule for <TreeViewLabel>
[TRACE  ] [Builder     ] build rule for <StencilView>
[TRACE  ] [Builder     ] build rule for <FileChooserListLayout>
[TRACE  ] [Builder     ] build rule for <FileChooserListView>
[TRACE  ] [Builder     ] build template for [FileListEntry@FloatLayout+TreeViewNode]
[TRACE  ] [Builder     ] build rule for <FileChooserIconLayout>
[TRACE  ] [Builder     ] build rule for <FileChooserIconView>
[TRACE  ] [Builder     ] build template for [FileIconEntry@Widget]
[TRACE  ] [Builder     ] build rule for <FileChooserProgress>
[TRACE  ] [Builder     ] build rule for <Switch>
[TRACE  ] [Builder     ] build rule for <ModalView>
[TRACE  ] [Builder     ] build rule for <Popup>
[TRACE  ] [Builder     ] build rule for <SpinnerOption>
[TRACE  ] [Builder     ] build rule for <Spinner>
[TRACE  ] [Builder     ] build rule for <ActionBar>
[TRACE  ] [Builder     ] build rule for <ActionView>
[TRACE  ] [Builder     ] build rule for <ActionSeparator>
[TRACE  ] [Builder     ] build rule for <ActionButton,ActionToggleButton>
[TRACE  ] [Builder     ] build rule for <ActionLabel>
[TRACE  ] [Builder     ] build rule for <ActionGroup>
[TRACE  ] [Builder     ] build rule for <ActionCheck>
[TRACE  ] [Builder     ] build rule for <ActionPreviousImage@Image>
[TRACE  ] [Builder     ] build rule for <ActionPreviousButton@Button>
[TRACE  ] [Builder     ] build rule for <ActionPrevious>
[TRACE  ] [Builder     ] build rule for <ActionGroup>
[TRACE  ] [Builder     ] build rule for <ActionOverflow>
[TRACE  ] [Builder     ] build rule for <ActionDropDown>
[TRACE  ] [Builder     ] build template for [AccordionItemTitle@Label]
[TRACE  ] [Builder     ] build rule for <AccordionItem>
[TRACE  ] [Builder     ] build rule for <SettingSpacer>
[TRACE  ] [Builder     ] build rule for <SettingItem>
[TRACE  ] [Builder     ] build rule for <SettingBoolean>
[TRACE  ] [Builder     ] build rule for <SettingString>
[TRACE  ] [Builder     ] build rule for <SettingPath>
[TRACE  ] [Builder     ] build rule for <SettingOptions>
[TRACE  ] [Builder     ] build rule for <SettingTitle>
[TRACE  ] [Builder     ] build rule for <SettingSidebarLabel>
[TRACE  ] [Builder     ] build rule for <SettingsPanel>
[TRACE  ] [Builder     ] build rule for <Settings>
[TRACE  ] [Builder     ] build rule for <InterfaceWithSidebar>
[TRACE  ] [Builder     ] build rule for <InterfaceWithSpinner>
[TRACE  ] [Builder     ] build rule for <MenuSpinner>
[TRACE  ] [Builder     ] build rule for <MenuSidebar>
[TRACE  ] [Builder     ] build rule for <ContentPanel>
[TRACE  ] [Builder     ] build rule for <InterfaceWithTabbedPanel>
[TRACE  ] [Builder     ] build rule for <ScrollView>
[TRACE  ] [Builder     ] build rule for <VideoPlayerPreview>
[TRACE  ] [Builder     ] build rule for <VideoPlayerAnnotation>
[TRACE  ] [Builder     ] build rule for <VideoPlayer>
[TRACE  ] [Builder     ] build rule for <CheckBox>
[TRACE  ] [Builder     ] build rule for <ScreenManager>
[TRACE  ] [Builder     ] build rule for <ColorPicker_Input@TextInput>
[TRACE  ] [Builder     ] build rule for <ColorPicker_Label@Label>
[TRACE  ] [Builder     ] build rule for <ColorPicker_Selector@BoxLayout>
[TRACE  ] [Builder     ] build rule for <ColorWheel>
[TRACE  ] [Builder     ] build rule for <ColorPicker>
[DEBUG  ] [Cache       ] register <kv.image> with limit=None, timeout=60
[DEBUG  ] [Cache       ] register <kv.atlas> with limit=None, timeout=None
[TRACE  ] [Image       ] Unable to use <gif> as loader!
[TRACE  ]
Traceback (most recent call last):
  File "/home/pi/kivy/kivy/core/__init__.py", line 129, in core_register_libs
    level=0)
  File "/home/pi/kivy/kivy/core/image/img_ffpyplayer.py", line 7, in <module>
    import ffpyplayer
ImportError: No module named ffpyplayer
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif, img_pygame, img_pil (img_ffpyplayer ignored)
[DEBUG  ] [Cache       ] register <kv.texture> with limit=1000, timeout=60
[DEBUG  ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600
[INFO   ] [Text        ] Provider: pygame
[DEBUG  ] [App         ] Loading kv <./my.kv>
[DEBUG  ] [App         ] kv <./my.kv> not found
[INFO   ] [Window      ] Provider: egl_rpi
[DEBUG  ] [Window      ] Actual display size: 720x480
[INFO   ] [GL          ] OpenGL version <OpenGL ES 2.0>
[INFO   ] [GL          ] OpenGL vendor <Broadcom>
[INFO   ] [GL          ] OpenGL renderer <VideoCore IV HW>
[INFO   ] [GL          ] OpenGL parsed version: 2, 0
[INFO   ] [GL          ] Shading version <OpenGL ES GLSL ES 1.00>
[INFO   ] [GL          ] Texture max size <2048>
[INFO   ] [GL          ] Texture max units <8>
[INFO   ] [Shader      ] fragment shader: <Compiled>
[DEBUG  ] [Shader      ] Fragment compiled successfully
[INFO   ] [Shader      ] vertex shader: <Compiled>
[DEBUG  ] [Shader      ] Vertex compiled successfully
[DEBUG  ] [ImagePygame ] Load </home/pi/kivy/kivy/data/glsl/default.png>
[TRACE  ] [Image       ] '/home/pi/kivy/kivy/data/glsl/default.png', populate to textures (1)
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[TRACE  ] [Builder     ] Found 1 rules for <kivy.uix.label.Label object at 0x74333458>
[DEBUG  ] [Resource    ] add </usr/share/fonts/truetype> in path list
[DEBUG  ] [Resource    ] add </usr/share/fonts/truetype/freefont> in path list
[DEBUG  ] [Resource    ] add </usr/share/fonts/truetype/roboto> in path list
[DEBUG  ] [Resource    ] add </usr/share/fonts/truetype/openoffice> in path list
[DEBUG  ] [Resource    ] add </usr/share/fonts/truetype/dejavu> in path list
[DEBUG  ] [Resource    ] add </usr/share/fonts/truetype/gentium-basic> in path list
[DEBUG  ] [Resource    ] add </usr/local/share/fonts> in path list
[DEBUG  ] [Resource    ] add </home/pi/kivy/kivy/data/fonts> in path list
[INFO   ] [OSC         ] using <multiprocessing> for socket
[DEBUG  ] [Base        ] Create provider from mouse
[INFO   ] [Base        ] Start application main loop
[INFO   ] [GL          ] NPOT texture support is available
[TRACE  ] [Builder     ] call_fn <kivy.graphics.vertex_instructions.Rectangle object at 0x74317650>, key=size, value=<code object <module> at 0x76553890, file "/home/pi/kivy/kivy/data/style.kv", line 9>, 'self.texture_size'
[TRACE  ] [Builder     ] call_fn => value=[79, 18]
[TRACE  ] [Builder     ] call_fn <kivy.graphics.vertex_instructions.Rectangle object at 0x74317650>, key=texture, value=<code object <module> at 0x76553608, file "/home/pi/kivy/kivy/data/style.kv", line 8>, 'self.texture'
[TRACE  ] [Builder     ] call_fn => value=<Texture hash=1945546224 id=0 size=(79, 18) colorfmt='rgba' bufferfmt='ubyte' source=None observers=1>
[TRACE  ] [Builder     ] call_fn <kivy.graphics.vertex_instructions.Rectangle object at 0x74317650>, key=pos, value=<code object <module> at 0x765538d8, file "/home/pi/kivy/kivy/data/style.kv", line 10>, 'int(self.center_x - self.texture_size[0] / 2.), int(self.center_y - self.texture_size[1] / 2.)'
[TRACE  ] [Builder     ] call_fn => value=(320, 231)
^C[INFO   ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "main.py", line 11, in <module>
     MyApp().run()
   File "/home/pi/kivy/kivy/app.py", line 828, in run
     runTouchApp()
   File "/home/pi/kivy/kivy/base.py", line 487, in runTouchApp
     EventLoop.window.mainloop()
   File "/home/pi/kivy/kivy/core/window/window_egl_rpi.py", line 89, in mainloop
     self._mainloop()
   File "/home/pi/kivy/kivy/core/window/window_egl_rpi.py", line 84, in _mainloop
     EventLoop.idle()
   File "/home/pi/kivy/kivy/base.py", line 327, in idle
     Clock.tick()
   File "/home/pi/kivy/kivy/clock.py", line 499, in tick
     usleep(1000000 * (sleeptime - sleep_undershoot))
   File "/home/pi/kivy/kivy/clock.py", line 292, in usleep
     _libc_usleep(int(microseconds))
 KeyboardInterrupt

我最好的猜测是它要么是缺少 ffpyplayer 模块,要么与 EGL 有关。

更新 2: 好吧,我在我的 Windows Kivy 中重新运行了基本应用程序来比较日志(应用程序在我的 Windows Kivy 中成功启动)。 ffplayer 错误仍然存​​在,让我相信这是某种 EGL 问题。

【问题讨论】:

【参考方案1】:

也许这个tutorial 可以帮助你。它使用与您相同的控制器 (ADS7846)。只需跳过 GPIO 部分。文件~/.kivy/config.ini 中的 [input] 部分有一部分被更改:

mouse = mouse
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput

【讨论】:

我确实有。尽管配置的特定部分似乎与输入界面有关。我什至无法成功启动应用程序。【参考方案2】:

我目前在使用 Eleduino 10.1 英寸电容式触摸屏时遇到了同样的问题。我设法解决了配置文件的问题:~/.kivy/config.ini 转到 [input] 部分并评论所有内容。然后,添加以下行:

    test = mtdev,/dev/input/event3
    ntrig = mtdev,/dev/input/event1

【讨论】:

以上是关于无法在触摸屏中使用 3.5 的 Raspberry Pi 3 上成功启动 Kivy 应用程序的主要内容,如果未能解决你的问题,请参考以下文章

Raspberry Pi 上带有 Tslib 的 Qt 5.4 Linux 触摸屏输入因 LinuxFB QPA 平台插件而失败

DIUSTOU电子元器件的?Raspberry Pi 4B 3.5寸液晶屏有啥特点?

Tkinter 滑块和 Raspberry Pi 4 GPIO 接口

第15讲树莓派3.5寸LCD触摸屏怎么用

从Android Things设备上的应用程序中选择WiFi网络(Raspberry Pi 3)

UIScrollView 在 4 英寸上工作,在 3.5 英寸上不响应任何触摸