element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Raspberry Pi 7# Touchscreen Calibrated fine in X-Windows but not the Console in Python
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 3 replies
  • Subscribers 664 subscribers
  • Views 1169 views
  • Users 0 members are here
  • raspberry_pi
Related

Raspberry Pi 7# Touchscreen Calibrated fine in X-Windows but not the Console in Python

drychronred
drychronred over 5 years ago

Hi,
I am using a Raspberry Pi 3B+ running with Full Buster Raspbian.  The display itself works fine.  I have Raspi-Config set to boot to the CLI and NOT load X-Windows.  When this happens and I run my python3 (3.7) program which uses pygame to get the mouse coordinates, pygame.mouse.get_position() (display set_mode to 800x480), the calibration is way off.  Now, when I run StartX, it loads x-windows and the mouse via the touchscreen works fin (calibration fine)... and when I click on the terminal and THEN run my python3 pygame program, the touchscreen is calibrated then also..... but... if I just boot to the CLI directly and run my program, the touchscreen calibration is off.  Clearly running StartX somehow uses a driver that the CLI isn't, and that driver remains running if I run my program in a terminal window.

I've researched a long time on the Net, and tried all kinds of solutions from others, and nothing seems to work.  Pygame is based on SDL.  I read that I need to change it so that Pygame uses something called FTSDL or something like that (darnit didn't write it down) that treats the touchscreen differently.  However, the instructions for that involve editing text in various configuration files and that text isn't there at all on my system - and I suspect that these instructions worked or were necessary prior to the touchscreen being integrated into the OS some time ago.  So I'm not sure where that leaves me.

I am sorry if I've not included something here or what-have-you.  This is my first question in a forum in many years and my first on the Pi/Touchscreen.  I'm a programmer for a living and an electronics designer.  I'm sure I'm just missing something obvious but not sure how to get from here to there...

Thank you for your time.

 

Cheers,
Jeff

  • Sign in to reply
  • Cancel
  • shabaz
    0 shabaz over 5 years ago

    Hi Jeff,

     

    I don't know the answer, and (long shot), does it make any difference if after you've run startx, you deliberately set the screen res to 800x480 and then do the calibration?

     

    I suppose it may be possible to work around the issue by changing the Pygame code, so that the detected co-ordinates are closer to what is expected. Again not ideal.

    Or, write your own cal routing in Python for your Python/Pygame app to use. It's hopefully not too difficult.

     

    You're not the only one with the issue incidentally, there's someone else with the same problem here, with no answer:

    https://www.raspberrypi.org/forums/viewtopic.php?t=225463

     

    And with a different framework, Kivy with Python, it looks like the calibration is done in the framework too:

    https://stackoverflow.com/questions/49776930/cant-calibrate-touchscreen-on-kivy

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • clem57
    0 clem57 over 5 years ago in reply to shabaz

    shabaz is correct and the framework controls much. I did read the following which may hold a clue:

    You can check to see if SDL is ready to be built from by running the command sdl-config and seeing if it is found. If the sdl-config script is not on the path (or you have more than one?) Set the environment variable SDL_CONFIG to its location.

    Sometimes you will have the SDL libraries installed in once location, and the other SDL libraries in another. This tricks the pygame config scripts, but you can help it out by setting the environment LOCALBASE to a path prefix where the other libraries are. The common case for this is SDL installed in /usr and other SDL libs installed in /usr/local. The command for this situation is "LOCALBASE=/usr/local python setup.py install".

    From: https://www.pygame.org/wiki/GettingStarted

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • clem57
    0 clem57 over 5 years ago

    Additionally this:

    https://raspberrypi.stackexchange.com/posts/1319/timeline  

    How X.Org works is that you have a desktop manager that boots the X Server for you. That means that in order to prevent X Server from starting, you need to remove your destkop manager from the daemons list.

    If you are using GNOME then you're desktop manager is GDM. If you're using KDE you're desktop manager will be KDM. For this, I'm going to assume that you're using GNOME; ergo you are using GDM as your desktop manager.

    In Raspian, the desktop manager is called LightDM.

    To disable a daemon in Debian (which Raspbian is a fork of) you have to run the following command.

    $ sudo update-rc.d <daemon> disable 

    So in order to disable LightDM we have to run the following command.

    $ sudo update-rc.d lightdm disable 

    And now on your next reboot LightDM shouldn't start and will, in turn, not start X Server.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube