Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capacitive Variant TFT #1

Open
numer opened this issue Nov 23, 2014 · 11 comments
Open

Capacitive Variant TFT #1

numer opened this issue Nov 23, 2014 · 11 comments

Comments

@numer
Copy link

numer commented Nov 23, 2014

Software does not start.

Mouse can not be disabled, it crashes on:
pygame.mouse.set_visible(False)

In terms of backlight the following error occurse:
tee: /sys/class/backlight/*/bl_power: No such file or directory

@ISO-B
Copy link
Owner

ISO-B commented Nov 25, 2014

Backlight in capacitive version is used diffrently. Try commenting out

  • Line 175 from ui.py
  • Lines 98, 484, 486 and 490 from pitft_ui.py
    those should remove that problem.

Did you set your touchscreen using adafruits tutorial that is made for capacitive version or did you just followed my instruction? If you used resistive config that might be reason for mouse crash.
Capacitive version: https://learn.adafruit.com/adafruit-2-8-pitft-capacitive-touch/capacitive-touchscreen

If you run following commands do you see image?

wget http://adafruit-download.s3.amazonaws.com/adapiluv320x240.jpg
sudo fbi -T 2 -d /dev/fb1 -noverbose -a adapiluv320x240.jpg

@numer
Copy link
Author

numer commented Nov 25, 2014

Yes I used adafruits tutorial and also adafruits prepared debian image.

It of course did work with those lines disabled, but then the backlight is lit up all the time and mouse pointer visible allt he time.

The command you wrote above displays nicely adafruits image on the display.

I'm running an mpd server and when I start (with the disabled lines) pmb-pitft I can hear disturbance in the played music sound.

@ISO-B
Copy link
Owner

ISO-B commented Nov 26, 2014

Do you hear that disturbance all the time or just start? I had problems with audio when I used adafruits image. I still have small disturbance at start of tracks when software fetches cover art. That is only with online source(eq. spotify) and with wifi.

What does ls -l /dev/input/touchscreen command returns?

What kind of setup you are running? Which audio output you are using?

If you are not using headphone jack you could try following changes to make backlight work. I made couple changes to code so now all backlight related codes are in one place.
pitft_ui.py
Add following two rows after comment on line 97 # Turn backlight on

subprocess.call("echo pwm > /sys/class/rpi-pwm/pwm0/mode", shell=True)
subprocess.call("echo 1000 > /sys/class/rpi-pwm/pwm0/frequency", shell=True)

Replace line 488:
subprocess.call("echo 1 | sudo tee /sys/class/backlight/*/bl_power", shell=True)
with:
subprocess.call("echo 1 > /sys/class/rpi-pwm/pwm0/duty", shell=True)

Replace line 492:
subprocess.call("echo 0 | sudo tee /sys/class/backlight/*/bl_power", shell=True)
with:
subprocess.call("echo 99 > /sys/class/rpi-pwm/pwm0/duty", shell=True)

@ISO-B ISO-B closed this as completed Nov 26, 2014
@ISO-B ISO-B reopened this Nov 26, 2014
@numer
Copy link
Author

numer commented Nov 27, 2014

I do hear that disturbance when music is played.

ls -l /dev/input/touchscree returns:
lrwxrwxrwx 1 root root 6 Nov 27 19:06 /dev/input/touchscreen -> event1

I've taken the Adafruit image for the capacitive tft and written in to the sd card for my raspberry. I installed MPD und my music files are on a network attached storage.
As audio output I use pupDAC which is a usb DAC which worked ok with raspbian and mpd in the past.

Your above commands echoed into the pwm0 files do work and changes the backlight!

Here is an output of process time consumption and when pmb-pitft runs python consumes over 70%

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2521 root 20 0 74984 19m 8272 R 74,1 4,5 5:17.58 python
2440 root 20 0 0 0 0 R 14,9 0,0 1:02.60 kworker/u2:1
2296 mpd 20 0 68172 12m 2480 S 9,4 2,8 1:03.58 mpd
2773 pi 20 0 6372 1404 1068 R 1,3 0,3 0:01.69 top

@truckershitch
Copy link

I also have the Adafruit capacitive touchscreen LCD. I ended up using the Adafruit guide to setting it up and am using the kernel and boot loader that are found on the initial setup pages. Calibrating the screen did not work with the Adafruit automatic script, but I was able to do it with the manual calibration found on the other PiTFT pages.

Let me say that this is a great project! I am enjoying the process of getting this GUI to work.

I tried the changes given above and I experienced distortion in playing back a stream. I have a USB soundcard. I changed the lines that turn the LCD on and off to just 'pass' to give a dummy line of code for the code blocks. After that, the sound issues went away at the expense of the backlight code.

It seems to me that the PWM calls are interfering with the audio stream. I'm not sure what could be done about this. Could there be some other workaround?

Thanks for sharing this with the community!

@ISO-B
Copy link
Owner

ISO-B commented Jan 2, 2015

Sorry that answering took very long, but I had very busy December.

@numer with my setupo mopidy uses ~70% CPU and python ~25% except when song is changing.

@truckershitch https://learn.adafruit.com/adafruit-2-8-pitft-capacitive-touch/backlight-control there is something about pwm, but is only with headphone jack so I dont have any idea why it does that.

And for extra note I am ordering capacitive module too.

@truckershitch
Copy link

I have a Raspberry Pi B revision 2.0. I have been trying to pinpoint the source of the noise. I can't seem to get good audio whenever the capacitive screen is on. I am not sure at this point what is going on. I will keep trying.

I had the console displaying (the boot screen) and noticed a pulsing which I determined to be the blinking cursor. I also get noise when I reboot, with the text on the screen.

It appears that your code may be fine with respect to audio noise and it is something on my side. I might have to try this again from the beginning. Maybe it is some kind of power supply issue.

Also, i fixed a small bug. When the sleep is set, and then set back to OFF, the display still shows a value instead of OFF. I added the last 3 lines to the # Sleeptimer if statement block (around 302-304):

                # Sleeptimer
                if self.sleepTimer:
                        td = self.sleepTimer - datetime.datetime.now()
                        if self.sleepTimer > datetime.datetime.now():
                                sleepTimerText = str(int(td.total_seconds() / 60))
                                if self.sleepTimerText != sleepTimerText:
                                        self.sleepTimerText = sleepTimerText
                                        self.updateSleepTimer = True
                        else:

                                self.sleepTimerText = "OFF"
                                self.sleepTimer = None
                                self.updateSleepTimer = True
                                self.sleepThread = Thread(target=self.sleep)
                                self.sleepThread.start()
                else:
                        self.sleepTimerText = "OFF"
                        self.updateSleepTimer = True

Did anyone run into problems with audio feedback from the screen? If so, did you resolve them?

@truckershitch
Copy link

Okay, I made some progress with the buzzing.

I found this page on the Adafruit Forums that seems to be working.

I now have options fbtft_device name=adafruitct28 rotate=270 frequency=32000000 txbuflen=512 in /etc/modules.d/pitft.conf. This seems to fix the problem!

I hope this helps someone else.

@retrorich75
Copy link

Hi,
I'd really like to understand how to define the correct font, in the readme;

From pitft-ui.py you need to change font if you are using something else than Helvetica Neue Bold and check that path is correct.

But all I get is [screen is terminating] and the only thing that stop is the font on line 52.

Let me know

@ISO-B
Copy link
Owner

ISO-B commented Jan 26, 2015

@retrorich75 Put font that you want to use pmb-pitft folder where .py files and images are. After that edit line 26 from pitft_ui.py file self.fontfile = self.path + "helvetica-neue-bold.ttf
And change that helvetica-neue-bold.ttf to font file that you want to use. Atleast it supports .ttf fonts.

I hope this helps.

@mikroflo
Copy link

mikroflo commented Apr 6, 2015

@ISO-B can you update your suggested changes for the latest version of your files? thanks a lot :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants