GamePi20_linux
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
&size(24){GAMEPI20に純なLinux(RaspberryPi OS)を入れる};
#contents
* 基本的な情報源 [#a2a7605d]
https://github.com/darrenliew96/gamepi20_drivers
* MicroSDカードにRaspberryPi OS を焼く [#d3dbc880]
RasPi ImagerでカードにOSを焼く~
Updateする~
sudo apt update
sudo apt full-upgrade
audo apt dist-update
$ uname -a
Linux raspberrypi 5.10.63+ #1459 Wed Oct 6 16:40:27 BST ...
* GAMEPI20ドライバ [#u2c2b8d3]
** gamepi20.dtsを作る [#v552db6d]
$ nano gamepi20.dts
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "br...
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
spidev@0{
status = "disabled";
};
spidev@1{
status = "disabled";
};
};
};
fragment@1 {
target = <&gpio>;
__overlay__ {
gamepi20_pins: gamepi20 {
brcm,pins = <25 27 >;
brcm,function = <1 1>; /...
brcm,pull = <0>; /* none...
};
};
};
fragment@2 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
gamepi20: gamepi20@0{
compatible = "sitronix,st...
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&gamepi20_pi...
spi-max-frequency = <9600...
rotate = <90>;
width = <240>;
height = <320>;
fps = <60>;
buswidth = <8>;
spi-cpol;
spi-cpha;
custom = <1>;
bgr;
reset-gpios = <&gpio 27 1>;
dc-gpios = <&gpio 25 0>;
led-gpios = <&gpio 24 1>;
/*cs-gpios = <&gpio 8 0>;*/
debug = <0>;
init = <0x1000011
0x20000ff
0x1000036 0xA0
0x100003a 0x05
0x1000021
0x100002a 0x00 0x...
0x100002b 0x00 0x...
0x10000b2 0x0c 0x...
0x10000b7 0x35
0x10000bb 0x1f
0x10000c0 0x0c
0x10000c2 0x01
0x10000c3 0x12
0x10000c4 0x20
0x10000c6 0x0f
0x10000d0 0xa4 0xa1
0x10000e0 0xd0 0x...
0x10000e1 0xd0 0x...
0x1000029>;
};
};
};
__overrides__ {
speed = <&gamepi20>,"spi-max-frequency...
rotate = <&gamepi20>,"rotate:0";
width = <&gamepi20>,"width:0";
height = <&gamepi20>,"height:0";
fps = <&gamepi20>,"fps:0";
debug = <&gamepi20>,"debug:0";
};
};
元ネタの https://github.com/darrenliew96/gamepi20_drivers...
具体的には、~
修正前 led-gpios = <&gpio 24 0>;
修正後 led-gpios = <&gpio 24 1>;
** gamepi20.dtsを登録する [#w67e5e63]
$ sudo dtc -@ -I dts -O dtb -o /boot/overlays/gamepi20.dt...
* config.txtを編集 [#pf6001e4]
# Uncomment some or all of these to enable the optional ...
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on
#dtoverlay=i2c-dev=spi_bcm2835
# Automatically load overlays for detected cameras
camera_auto_detect=0
#無効にしておく
# Automatically load overlays for detected DSI displays
display_auto_detect=0
#無効にしておく
# Enable DRM VC4 V3D driver
#dtoverlay=vc4-kms-v3d
#max_framebuffers=2
#無効にしておく
# Disable compensation for displays with overscan
disable_overscan=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB control...
# This line should be removed if the legacy DWC2 control...
# (e.g. for USB device mode) or if USB support is not re...
#otg_mode=1
#無効にしておく
[all]
#dtoverlay=pi3-disable-bt
#dtoverlay=pi3-miniuart-bt
#enable_uart=1
#GAMEPI20のディスプレイドライバ指定
dtoverlay=gamepi20
#画面解像度を適当に小さくしておく(HDMIはVGAの60fps GAME...
hdmi_force_hotplug=1
hdmi_cvt=640 480 60 1 0 0 0
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
audio_pwm_mode=2
dtoverlay=audremap,pins_18_19
* fbcpを作る [#d969aa64]
sudo apt-get install cmake git
cd ~
git clone https://github.com/tasanakorn/rpi-fbcp
cd rpi-fbcp/
mkdir build
cd build/
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp
フレームバッファー間のコピーを行うコマンド。~
プライマリディスプレイのフレームバッファの内容をセカンダ...
つまり、ミラーリング。
* /etc/modulesに追記 [#d966ecef]
sudo nano /etc/modulesに追記
i2c-dev
spi-bcm2835
flexfb
fbtft_device
* fbtft.conf fileを作る(2行) [#jf355e13]
sudo nano /etc/modprobe.d/fbtft.conf
options fbtft_device name=flexfb gpios=reset:27,dc:25,cs...
options flexfb setaddrwin=0 width=320 height=240 init=-1...
* /etc/rc.localを編集 [#k4450a73]
fbcp &
exit 0
* 各キーのGPIO割り当て [#v06bf620]
|キー |BCM No.|
| ↑ |12 |
| →|13 |
|← |21 |
| ↓ |20 |
|SELECT|16 |
|START |26 |
| Y |17 |
| X|22 |
|A |23 |
| B |4 |
|L |5 |
| R|6 |
L R
┌────┐
↑ │ │ Y
← → │ │ X B
↓ │ │ A
└────┘
SELECT START
&ref(GAMEPI20.png);
** pythonでボタンを読む [#tc55c233]
#!/usr/bin/python3
import RPi.GPIO as GPIO
import time
import sys
#ポート番号の定義
SW_U = 12
SW_D = 20
SW_L = 21
SW_R = 13
SW_A = 23
SW_B = 4
SW_X = 22
SW_Y = 17
SW_L2 = 5
SW_R2 = 6
SW_SEL = 16
SW_STA = 26
#GPIOの設定
GPIO.setmode(GPIO.BCM)
#GPIOを入力モードに設定してプルダウン抵抗を有効にする
GPIO.setup(SW_U, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_D, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_L, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_R, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_A, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_B, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_X, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_Y, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_L2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_R2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_SEL, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_STA, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
try:
if(GPIO.input(SW_U) == 0):
print("UP")
elif(GPIO.input(SW_D) == 0):
print("DOWN")
elif(GPIO.input(SW_L) == 0):
print("LEFT")
elif(GPIO.input(SW_R) == 0):
print("RIGHT")
elif(GPIO.input(SW_A) == 0):
print("A")
elif(GPIO.input(SW_B) == 0):
print("B")
elif(GPIO.input(SW_X) == 0):
print("X")
elif(GPIO.input(SW_Y) == 0):
print("Y")
elif(GPIO.input(SW_L2) == 0):
print("L-BACK")
elif(GPIO.input(SW_R2) == 0):
print("R-BACK")
elif(GPIO.input(SW_SEL) == 0):
print("SELECT")
elif(GPIO.input(SW_STA) == 0):
print("START")
time.sleep(0.1) #0.1秒間待つ
except KeyboardInterrupt: #Ctrl+Cキーが押...
GPIO.cleanup() #GPIOをクリーン...
sys.exit()
終了行:
&size(24){GAMEPI20に純なLinux(RaspberryPi OS)を入れる};
#contents
* 基本的な情報源 [#a2a7605d]
https://github.com/darrenliew96/gamepi20_drivers
* MicroSDカードにRaspberryPi OS を焼く [#d3dbc880]
RasPi ImagerでカードにOSを焼く~
Updateする~
sudo apt update
sudo apt full-upgrade
audo apt dist-update
$ uname -a
Linux raspberrypi 5.10.63+ #1459 Wed Oct 6 16:40:27 BST ...
* GAMEPI20ドライバ [#u2c2b8d3]
** gamepi20.dtsを作る [#v552db6d]
$ nano gamepi20.dts
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "br...
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
spidev@0{
status = "disabled";
};
spidev@1{
status = "disabled";
};
};
};
fragment@1 {
target = <&gpio>;
__overlay__ {
gamepi20_pins: gamepi20 {
brcm,pins = <25 27 >;
brcm,function = <1 1>; /...
brcm,pull = <0>; /* none...
};
};
};
fragment@2 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
gamepi20: gamepi20@0{
compatible = "sitronix,st...
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&gamepi20_pi...
spi-max-frequency = <9600...
rotate = <90>;
width = <240>;
height = <320>;
fps = <60>;
buswidth = <8>;
spi-cpol;
spi-cpha;
custom = <1>;
bgr;
reset-gpios = <&gpio 27 1>;
dc-gpios = <&gpio 25 0>;
led-gpios = <&gpio 24 1>;
/*cs-gpios = <&gpio 8 0>;*/
debug = <0>;
init = <0x1000011
0x20000ff
0x1000036 0xA0
0x100003a 0x05
0x1000021
0x100002a 0x00 0x...
0x100002b 0x00 0x...
0x10000b2 0x0c 0x...
0x10000b7 0x35
0x10000bb 0x1f
0x10000c0 0x0c
0x10000c2 0x01
0x10000c3 0x12
0x10000c4 0x20
0x10000c6 0x0f
0x10000d0 0xa4 0xa1
0x10000e0 0xd0 0x...
0x10000e1 0xd0 0x...
0x1000029>;
};
};
};
__overrides__ {
speed = <&gamepi20>,"spi-max-frequency...
rotate = <&gamepi20>,"rotate:0";
width = <&gamepi20>,"width:0";
height = <&gamepi20>,"height:0";
fps = <&gamepi20>,"fps:0";
debug = <&gamepi20>,"debug:0";
};
};
元ネタの https://github.com/darrenliew96/gamepi20_drivers...
具体的には、~
修正前 led-gpios = <&gpio 24 0>;
修正後 led-gpios = <&gpio 24 1>;
** gamepi20.dtsを登録する [#w67e5e63]
$ sudo dtc -@ -I dts -O dtb -o /boot/overlays/gamepi20.dt...
* config.txtを編集 [#pf6001e4]
# Uncomment some or all of these to enable the optional ...
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on
#dtoverlay=i2c-dev=spi_bcm2835
# Automatically load overlays for detected cameras
camera_auto_detect=0
#無効にしておく
# Automatically load overlays for detected DSI displays
display_auto_detect=0
#無効にしておく
# Enable DRM VC4 V3D driver
#dtoverlay=vc4-kms-v3d
#max_framebuffers=2
#無効にしておく
# Disable compensation for displays with overscan
disable_overscan=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB control...
# This line should be removed if the legacy DWC2 control...
# (e.g. for USB device mode) or if USB support is not re...
#otg_mode=1
#無効にしておく
[all]
#dtoverlay=pi3-disable-bt
#dtoverlay=pi3-miniuart-bt
#enable_uart=1
#GAMEPI20のディスプレイドライバ指定
dtoverlay=gamepi20
#画面解像度を適当に小さくしておく(HDMIはVGAの60fps GAME...
hdmi_force_hotplug=1
hdmi_cvt=640 480 60 1 0 0 0
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
audio_pwm_mode=2
dtoverlay=audremap,pins_18_19
* fbcpを作る [#d969aa64]
sudo apt-get install cmake git
cd ~
git clone https://github.com/tasanakorn/rpi-fbcp
cd rpi-fbcp/
mkdir build
cd build/
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp
フレームバッファー間のコピーを行うコマンド。~
プライマリディスプレイのフレームバッファの内容をセカンダ...
つまり、ミラーリング。
* /etc/modulesに追記 [#d966ecef]
sudo nano /etc/modulesに追記
i2c-dev
spi-bcm2835
flexfb
fbtft_device
* fbtft.conf fileを作る(2行) [#jf355e13]
sudo nano /etc/modprobe.d/fbtft.conf
options fbtft_device name=flexfb gpios=reset:27,dc:25,cs...
options flexfb setaddrwin=0 width=320 height=240 init=-1...
* /etc/rc.localを編集 [#k4450a73]
fbcp &
exit 0
* 各キーのGPIO割り当て [#v06bf620]
|キー |BCM No.|
| ↑ |12 |
| →|13 |
|← |21 |
| ↓ |20 |
|SELECT|16 |
|START |26 |
| Y |17 |
| X|22 |
|A |23 |
| B |4 |
|L |5 |
| R|6 |
L R
┌────┐
↑ │ │ Y
← → │ │ X B
↓ │ │ A
└────┘
SELECT START
&ref(GAMEPI20.png);
** pythonでボタンを読む [#tc55c233]
#!/usr/bin/python3
import RPi.GPIO as GPIO
import time
import sys
#ポート番号の定義
SW_U = 12
SW_D = 20
SW_L = 21
SW_R = 13
SW_A = 23
SW_B = 4
SW_X = 22
SW_Y = 17
SW_L2 = 5
SW_R2 = 6
SW_SEL = 16
SW_STA = 26
#GPIOの設定
GPIO.setmode(GPIO.BCM)
#GPIOを入力モードに設定してプルダウン抵抗を有効にする
GPIO.setup(SW_U, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_D, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_L, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_R, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_A, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_B, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_X, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_Y, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_L2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_R2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_SEL, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(SW_STA, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
try:
if(GPIO.input(SW_U) == 0):
print("UP")
elif(GPIO.input(SW_D) == 0):
print("DOWN")
elif(GPIO.input(SW_L) == 0):
print("LEFT")
elif(GPIO.input(SW_R) == 0):
print("RIGHT")
elif(GPIO.input(SW_A) == 0):
print("A")
elif(GPIO.input(SW_B) == 0):
print("B")
elif(GPIO.input(SW_X) == 0):
print("X")
elif(GPIO.input(SW_Y) == 0):
print("Y")
elif(GPIO.input(SW_L2) == 0):
print("L-BACK")
elif(GPIO.input(SW_R2) == 0):
print("R-BACK")
elif(GPIO.input(SW_SEL) == 0):
print("SELECT")
elif(GPIO.input(SW_STA) == 0):
print("START")
time.sleep(0.1) #0.1秒間待つ
except KeyboardInterrupt: #Ctrl+Cキーが押...
GPIO.cleanup() #GPIOをクリーン...
sys.exit()
ページ名: