Browse Source

fix: Adding display config instructions and test python source

Matthias Ladkau 4 years ago
parent
commit
de1c62eb4c
6 changed files with 93 additions and 5 deletions
  1. 6 0
      display_test/install.txt
  2. 55 0
      display_test/test.py
  3. 2 5
      doc/configs.txt
  4. BIN
      doc/display_wiring.jpg
  5. BIN
      doc/pi4_pins.jpg
  6. 30 0
      doc/tft_display.txt

+ 6 - 0
display_test/install.txt

@@ -0,0 +1,6 @@
+Raspberry:
+apt-get install python3-pygame
+
+Mint:
+apt-get install python3-pip
+pip3 install pygame

+ 55 - 0
display_test/test.py

@@ -0,0 +1,55 @@
+#!/usr/bin/python3
+
+import sys,os
+os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
+import pygame
+
+from pygame.locals import *
+os.environ["SDL_FBDEV"] = "/dev/fb1"
+# Uncomment if you have a touch panel and find the X value for your device
+#os.environ["SDL_MOUSEDRV"] = "TSLIB"
+#os.environ["SDL_MOUSEDEV"] = "/dev/input/eventX"
+
+pygame.init()
+
+# set up the window
+DISPLAYSURF = pygame.display.set_mode((128, 160), 0, 32)
+pygame.display.set_caption('Drawing')
+
+# set up the colors
+BLACK = (  0,   0,   0)
+WHITE = (255, 255, 255)
+RED   = (255,   0,   0)
+GREEN = (  0, 255,   0)
+BLUE  = (  0,   0, 255)
+
+# draw on the surface object
+DISPLAYSURF.fill(WHITE)
+pygame.draw.polygon(DISPLAYSURF, GREEN, ((16, 0), (111, 106), (36, 277), (56, 27), (0, 106)))
+pygame.draw.line(DISPLAYSURF, BLUE, (60, 60), (120, 60), 4)
+pygame.draw.line(DISPLAYSURF, BLUE, (120, 60), (60, 120))
+pygame.draw.line(DISPLAYSURF, BLUE, (60, 120), (120, 120), 4)
+pygame.draw.circle(DISPLAYSURF, BLUE, (40, 50), 20, 0)
+pygame.draw.ellipse(DISPLAYSURF, RED, (110, 200, 40, 80), 1)
+box = pygame.draw.rect(DISPLAYSURF, RED, (100, 150, 100, 50))
+
+pixObj = pygame.PixelArray(DISPLAYSURF)
+pixObj[120][144] = BLACK
+pixObj[122][146] = BLACK
+pixObj[124][148] = BLACK
+pixObj[126][158] = BLACK
+pixObj[126][158] = BLACK
+del pixObj
+
+# run the game loop
+while True:
+    for event in pygame.event.get():
+        if event.type == QUIT:
+            pygame.quit()
+            sys.exit()
+        if event.type == pygame.MOUSEBUTTONDOWN:
+            print("Pos: %sx%s\n" % pygame.mouse.get_pos())
+            if box.collidepoint(pygame.mouse.get_pos()):
+                pygame.quit()
+                sys.exit()
+    pygame.display.update()

+ 2 - 5
doc/configs.txt

@@ -30,14 +30,11 @@ hackerradio
 
 5. Add prompt and ll command
 
-Add to .profile for root and pi
+Add to ~/bashrc for root and pi
 
+alias ll='ls --color=always -alh'
 PS1="\u@\h:\w>"
 
-ll () {
-    ls -alh --color=always "$@"
-}
-
 6. Add essential commands
 
 apt-get install screen

BIN
doc/display_wiring.jpg


BIN
doc/pi4_pins.jpg


+ 30 - 0
doc/tft_display.txt

@@ -0,0 +1,30 @@
+TFT Display
+--
+Driver: https://github.com/notro/fbtft
+Docs: https://github.com/notro/fbtft/wiki
+
+apt-get install binutils
+
+Add to /boot/config.txt
+dtparam=spi=on
+
+Manually load driver with:
+sudo modprobe fbtft_device name=adafruit18
+
+Add to /etc/modules
+fbtft_device
+
+Create /etc/modprobe.d/fbtft_device.conf
+options fbtft_device name=adafruit18
+
+See kernel messages with:
+dmesg -w
+
+Check display:
+fbset -fb /dev/fb1
+
+Test display output:
+cat /dev/urandom >/dev/fb1
+
+Install python game
+apt-get install python3-pygame