From 1b566880151fea3da7a0438d31f94484c7625da9 Mon Sep 17 00:00:00 2001 From: Your Name <you@example.com> Date: Mon, 11 Jan 2021 13:38:50 +0100 Subject: [PATCH] Poprawki w GPIO --- lab01/README.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/lab01/README.md b/lab01/README.md index b546b21..f009ba4 100644 --- a/lab01/README.md +++ b/lab01/README.md @@ -50,18 +50,18 @@ pip install -r requirements.txt #!/usr/bin/env python3.6 import time import gpio -print( "Test LED@I2C1_DATA\n") -gpio.setup(490, gpio.OUT) +print( "Test LED@PWM0\n") +gpio.setup(504, gpio.OUT) while(True): - gpio.set(490, 1) + gpio.set(504, 1) time.sleep(0.5) - gpio.set(490, 0) + gpio.set(504, 0) time.sleep(0.5) ``` # Odczyt stanu przycisku: - - gpio.setup(491, gpio.IN) - - gpio.read(491) # I2C1_CLK + - gpio.setup(488, gpio.IN) + - gpio.read(488) # I2C0_DATA@GPIO488 - zmiana ustawieĹ poziomu loggera z gpio: ```python gpio.log.setLevel(logging.INFO) @@ -114,7 +114,7 @@ def on_connect(client, userdata, flags, rc): print("Connected with result code "+str(rc)) # Subscribing in on_connect() means that if we lose the connection and # reconnect then subscriptions will be renewed. - client.subscribe("sensors/#") + client.subscribe("led/#") # The callback for when a PUBLISH message is received from the server. def on_message(client, userdata, msg): @@ -138,9 +138,9 @@ import time client = mqtt.Client() client.connect("localhost", 1883, 60) while(True): - client.publish("sensors/490", "1") + client.publish("led/504", "1") time.sleep(0.5) - client.publish("sensors/490", "0") + client.publish("led/504", "0") time.sleep(0.5) ``` # Autostart aplikacji @@ -158,16 +158,17 @@ SHELL=/bin/bash ```bash #!/bin/bash MY_PATH=$(dirname $(realpath -s $0)) -# Create a new tmux session named helloworld... -/usr/bin/tmux new-session -d -s helloworld -/usr/bin/tmux set-option -t helloworld remain-on-exit on -/usr/bin/tmux send-keys -t helloworld "source /root/.bashrc" C-m -/usr/bin/tmux send-keys -t helloworld "source /root/.profile" C-m -/usr/bin/tmux send-keys -t helloworld "date" C-m -/usr/bin/tmux send-keys -t helloworld "source virtenv/bin/active" C-m -/usr/bin/tmux send-keys -t helloworld "echo 'tutaj uruchom swoja app1'" C-m -/usr/bin/tmux split-window -t helloworld -/usr/bin/tmux send-keys -t helloworld "echo 'tutaj uruchom swoja app2 w drugim panelu'" C-m +# Create a new tmux session named pmk +SESSION_NAME="pmk" +/usr/bin/tmux new-session -d -s $SESSION_NAME} +/usr/bin/tmux set-option -t ${SESSION_NAME} remain-on-exit on +/usr/bin/tmux send-keys -t ${SESSION_NAME} "source /root/.bashrc" C-m +/usr/bin/tmux send-keys -t ${SESSION_NAME} "source /root/.profile" C-m +/usr/bin/tmux send-keys -t ${SESSION_NAME} "date" C-m +/usr/bin/tmux send-keys -t ${SESSION_NAME} "source virtenv/bin/active" C-m +/usr/bin/tmux send-keys -t ${SESSION_NAME} "echo 'tutaj uruchom swoja app1'" C-m +/usr/bin/tmux split-window -t ${SESSION_NAME} +/usr/bin/tmux send-keys -t ${SESSION_NAME} "echo 'tutaj uruchom swoja app2 w drugim panelu'" C-m ``` - PodĹÄ czenie do sesji tmux uruchomionej podczas startu systemu ```bash @@ -180,6 +181,7 @@ tmux a - nastÄpne okno: CTR+B n - wyjĹcie bez zamykania okna: CTR+B d - zamkniÄcie panelu: CTR+d + - zmiana panelu: CTR+b strzalki # Zadania: - PoĹÄ czenie z MQTT z innego NUC (odczyt stanu przycisku) -- GitLab