gsd 7 months ago
parent
commit
489a533b3f
  1. 25
      pipboyIO/pipboyIO.ino
  2. 38
      pipboyWEB/nginx.conf
  3. 6
      pipboyWEB/readme

25
pipboyIO/pipboyIO.ino

@ -1,7 +1,13 @@
#include <Encoder.h>
const int input[] = {36, 39, 34 ,35 ,32 ,33 ,25 ,26};
long inputValue[] = {0, 0, 0, 0, 0, 0, 0, 0};
const int numPins = sizeof(input) / sizeof(input[0]);
Encoder enc1(14,27);
Encoder enc2(13,12);
long positions[3] = {0, 0, 0};
#define RXD2 (16)
#define TXD2 (17)
@ -10,6 +16,7 @@ void setup() {
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
analogReadResolution(12);
analogSetAttenuation(ADC_11db);
}
void values2uart() {
@ -18,7 +25,14 @@ void values2uart() {
Serial2.print("-");
Serial2.print(inputValue[i]);
Serial2.print("\n");
}
for (int i = 0; i < 2; i++) {
Serial2.print("10");
Serial2.print(i);
Serial2.print("-");
Serial2.print(positions[i]);
Serial2.print("\n");
}
}
@ -27,6 +41,17 @@ void loop() {
inputValue[i] = map(analogRead(input[i]), 0, 4096, 0, 25);
}
long newPos1 = enc1.read();
long newPos2 = enc2.read();
if (newPos1 != positions[0]) {
positions[0] = newPos1;
}
if (newPos2 != positions[1]) {
positions[1] = newPos2;
}
values2uart();
delay(50);
}

38
pipboyWEB/nginx.conf

@ -0,0 +1,38 @@
server {
listen 80;
server_name pipboy; # Замените на ваш домен
root /home/pipboy/Pipboy3Kmark4/pipboyUI/dist/pipboy-ui; # Путь к Angular приложению
index index.html;
# Отдача статических файлов
location / {
try_files $uri $uri/ /index.html;
}
# Кэширование статических ресурсов
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2|ttf)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Запрет доступа к скрытым файлам
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Оптимизация для больших файлов
client_max_body_size 100m;
# Безопасность
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
# Gzip сжатие
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
}

6
pipboyWEB/readme

@ -0,0 +1,6 @@
sudo apt install nginx
sudo systemctl stop nginx
sudo rm /etc/nginx/sites-available/default
sudo ln -s ~/Pipboy3Kmark4/pipboyWEB/nginx.conf /etc/nginx/sites-available/pipboy
sudo nginx -t
sudo systemctl start nginx
Loading…
Cancel
Save