{"action":"created","issue":{"url":"https://api.github.com/repos/hzeller/rpi-rgb-led-matrix/issues/548","repository_url":"https://api.github.com/repos/hzeller/rpi-rgb-led-matrix","labels_url":"https://api.github.com/repos/hzeller/rpi-rgb-led-matrix/issues/548/labels{/name}","comments_url":"https://api.github.com/repos/hzeller/rpi-rgb-led-matrix/issues/548/comments","events_url":"https://api.github.com/repos/hzeller/rpi-rgb-led-matrix/issues/548/events","html_url":"https://github.com/hzeller/rpi-rgb-led-matrix/issues/548","id":303098734,"number":548,"title":"Output Display blinks instead of having single manual physical gpio button for on & off ","user":{"login":"henrylowzh","id":33551098,"avatar_url":"https://avatars1.githubusercontent.com/u/33551098?v=4","gravatar_id":"","url":"https://api.github.com/users/henrylowzh","html_url":"https://github.com/henrylowzh","followers_url":"https://api.github.com/users/henrylowzh/followers","following_url":"https://api.github.com/users/henrylowzh/following{/other_user}","gists_url":"https://api.github.com/users/henrylowzh/gists{/gist_id}","starred_url":"https://api.github.com/users/henrylowzh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henrylowzh/subscriptions","organizations_url":"https://api.github.com/users/henrylowzh/orgs","repos_url":"https://api.github.com/users/henrylowzh/repos","events_url":"https://api.github.com/users/henrylowzh/events{/privacy}","received_events_url":"https://api.github.com/users/henrylowzh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-03-07T13:30:29Z","updated_at":"2018-03-10T04:07:57Z","closed_at":null,"author_association":"NONE","body":"Hi there,\r\n\r\nI have created a manual trigger button(on/off) gpio button for my output. I took the \"image-viewer.py\" sample code as a reference. For your infomation I'm using a 64x128 display with a E line and had perform the pwm mod on the adafruit-hat.\r\n\r\nWhen i launched the script, the gpio button automatics triggers both On & Off(getting a undesired Blink Display) without me pressing anything. I'm curious is there anything on the rgbmatrix module conflicting with the gpio? Or is there somewhere wrong in the code?\r\n\r\nplease find my code below:\r\n\r\n```\r\nimport time     # Import sleep Library\r\nimport sys\r\nimport RPi.GPIO as GPIO    # Import GPIO Library\r\nfrom rgbmatrix import RGBMatrix, RGBMatrixOptions\r\nfrom PIL import Image\r\n\r\nstate = True\r\nsize = 64, 64\r\n\r\nGPIO.setwarnings(False)\r\nGPIO.setmode(GPIO.BCM)   # Use Physical Pin Numbering Scheme\r\nbutton1=21                 # Button 1 is connected to physical pin 40\r\n\r\nGPIO.setup(button1,GPIO.IN,pull_up_down=GPIO.PUD_UP) # Make button1 an input, Activate Pull UP Resistor\r\n\r\nBS1=False                  # Set Flag BS1 to indicate Display is initially off\r\n\r\nimage_file1 = '/home/pi/rpi-rgb-led-matrix/danger.jpg'\r\nimage1 = Image.open(image_file1)\r\nimageprop1 = image1.convert(\"RGB\").rotate(180)\r\n\r\noptions = RGBMatrixOptions()\r\noptions.rows = 64\r\noptions.cols =128\r\noptions.chain_length = 1\r\noptions.parallel = 1\r\noptions.hardware_mapping = 'adafruit-hat-pwm'  # If you have an Adafruit HAT: 'adafruit-hat'\r\n\r\nmatrix = RGBMatrix(options = options)\r\n\r\nwhile(1):                  # Create an infinite Loop\r\n        if GPIO.input(button1)==0:            # Look for button to press\r\n                if BS1==False:                # If the Display is off\r\n                        print\"Button was Pressed to Turn Display ON\"\r\n                        BS1=True              # Set Flag to show Display is now On\r\n                        image1.thumbnail(size, Image.ANTIALIAS)\r\n\t\t\timage1.load()\r\n\t\t\tmatrix.SetImage(imageprop1,32,0,)\r\n\t\t\ttime.sleep(.5)             # Delay\r\n                else:                         # If the Display is ON\r\n                        print\"Button Was Pressed to Turn Off\"\r\n                        matrix.Clear()\r\n                        BS1=False               # Set Flag to show Display is now Off\r\n                        time.sleep(.5)\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/hzeller/rpi-rgb-led-matrix/issues/comments/372000886","html_url":"https://github.com/hzeller/rpi-rgb-led-matrix/issues/548#issuecomment-372000886","issue_url":"https://api.github.com/repos/hzeller/rpi-rgb-led-matrix/issues/548","id":372000886,"user":{"login":"henrylowzh","id":33551098,"avatar_url":"https://avatars1.githubusercontent.com/u/33551098?v=4","gravatar_id":"","url":"https://api.github.com/users/henrylowzh","html_url":"https://github.com/henrylowzh","followers_url":"https://api.github.com/users/henrylowzh/followers","following_url":"https://api.github.com/users/henrylowzh/following{/other_user}","gists_url":"https://api.github.com/users/henrylowzh/gists{/gist_id}","starred_url":"https://api.github.com/users/henrylowzh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henrylowzh/subscriptions","organizations_url":"https://api.github.com/users/henrylowzh/orgs","repos_url":"https://api.github.com/users/henrylowzh/repos","events_url":"https://api.github.com/users/henrylowzh/events{/privacy}","received_events_url":"https://api.github.com/users/henrylowzh/received_events","type":"User","site_admin":false},"created_at":"2018-03-10T04:07:57Z","updated_at":"2018-03-10T04:07:57Z","author_association":"NONE","body":"Hi @hzeller \r\n\r\nThat totally works. The button is working as expected.\r\nHowever the display image on the led matrix turn out wasn't good. The display color seem to be stretch and there were some slight flickering. Has this anything got to do with the refresh rate or pwm?\r\n<a href=\"https://ibb.co/hNzA3S\"><img src=\"https://preview.ibb.co/m6k6cn/28870272_10213108723407117_8273359128206770176_o.jpg\" alt=\"28870272_10213108723407117_8273359128206770176_o\" border=\"0\"></a>\r\n\r\nCompare to the earlier display which was good but was blinking\r\n<a href=\"https://ibb.co/m5zoq7\"><img src=\"https://preview.ibb.co/cx8Rcn/28870984_10213108723327115_2440045889511751680_o.jpg\" alt=\"28870984_10213108723327115_2440045889511751680_o\" border=\"0\"></a>"}}
{"actor":{"display_login":"henrylowzh"}}