Took 1 hour 16 minutes
This commit is contained in:
Tobias Hopp 2023-01-09 21:44:23 +01:00
parent b1fe4e0953
commit 9c63516ab8
5 changed files with 54 additions and 13 deletions

13
ToDo.md
View File

@ -8,4 +8,15 @@
- [ ] Container option "Auto tare" hinzufügen
- Heißt, sobald ein Inhalt in einen Container eingestellt wird und das Volumen angegeben ist, werden die Sensoren auf den aktuellen Füllstand als 100% gesetzt
- [ ] Nach Speichern des Setups und bei Einmessen auf Schließen, Setup verlassen
- [ ]
------
# New
- Gesamtvolumen des Containers komplett entfernen
- Bei Behälter aktualisieren wird das Volumen des neu zu stellendes Behälters eingestellt, welches dann als 100% interpretiert wird
- Im Setup kommt ein neues Feature, tarieren von Wägezelle (also der 0-Wert der Wägezelle) nach Speicherung, anstatt aktueller 2-Wege-Tarierung
- Ultraschallsensor wird entfernt
- Wenn Sensorik für Behälter vorhanden ist, nutze Wägezelle des Containers und messe anhand dessen Inhaltsmenge
- 1G=1ML
- Bei Einstellung neues Inhalts wird das Gewicht als ml übersetzt, danach wird Gewicht-Eingestellte Millitier gerechnet, das Ergebnis ist das Gewicht des Behälters

View File

@ -5,6 +5,9 @@ if [ "$EUID" -ne 0 ]; then
exit
fi
echo "Creating user if not exists"
adduser itender || true
echo "Updating indexes"
apt update
@ -42,13 +45,13 @@ ufw allow 3000/tcp
ufw allow 3015/tcp
ufw --force enable
echo "Updating indexes and installing mongodb and yarn..."
echo "Updating indexes..."
# Final update
apt update
echo "Installing mongodb and yarn..."
apt install nodejs yarn mongodb-org -y
apt upgrade -y
echo "Installing autostart..."
# Autostart
cat <<EOT >/etc/xdg/openbox/autostart
@ -64,8 +67,12 @@ sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/
/usr/bin/chromium-browser --disable-infobars --kiosk --incognito --disable-pinch --overscroll-history-navigation=0 "http://127.0.0.1:3000/" &
EOT
echo "Setting to console autologin..."
raspi-config nonint do_boot_behaviour B2
echo "Installing bashrc"
echo "[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && startx -- -nocursor" >> /home/itender/.bashrc
echo "clear" >>/home/itender/.bashrc
echo "[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && startx -- -nocursor >/dev/null 2>&1" >>/home/itender/.bashrc
#
#echo "Installing start.sh"
#cat <<EOT >>/home/itender/start.sh
@ -101,14 +108,14 @@ yarn run compile
echo "Updating Cron..."
# Add line to cron
echo "@reboot sudo chmod g+rw /dev/tty?" > /tmp/currentCron
echo "@reboot sudo chmod g+rw /dev/tty?" >/tmp/currentCron
#echo "@reboot cd /home/itender/itender/ && /usr/bin/yarn run start &" >> /tmp/currentCron
chown itender:itender /tmp/currentCron
#install new cron file
sudo -u itender crontab /tmp/currentCron
echo "Installing systemd service..."
cat <<EOT > /etc/systemd/system/itender.service
cat <<EOT >/etc/systemd/system/itender.service
[Unit]
Description=iTender App
After=network.target mongod.service
@ -132,7 +139,6 @@ WantedBy=multi-user.target
EOT
#sh -c "git pull --quiet || true"
echo "Activating systemctl daemons..."
systemctl daemon-reload
systemctl enable mongod
@ -156,6 +162,21 @@ fi
if ! grep -w "disable_splash=1" /boot/config.txt; then
echo "disable_splash=1" >>/boot/config.txt
fi
if ! grep -w "vc4-fkms-v3d" /boot/config.txt; then
sed -i 's/dtoverlay=vc4-kms-v3d/dtoverlay=vc4-fkms-v3d,disable-bt/' /boot/config.txt
fi
if ! grep -w "boot_delay=0" /boot/config.txt; then
echo "boot_delay=0" >>/boot/config.txt
fi
if ! grep -w "over_voltage=6" /boot/config.txt; then
echo "over_voltage=6" >>/boot/config.txt
fi
if ! grep -w "arm_freq=1300" /boot/config.txt; then
echo "arm_freq=1300" >>/boot/config.txt
fi
if ! grep -w "gpu_freq=700" /boot/config.txt; then
echo "gpu_freq=700" >>/boot/config.txt
fi
echo "Setting no-logo..."
systemctl disable getty@tty1.service
@ -167,9 +188,17 @@ if ! grep -w "logo.nologo" /boot/cmdline.txt; then
#cp /tmp/cmdline.txt /boot/cmdline.txt
sed -i "1 s|$| vt.global_cursor_default=0|" /boot/cmdline.txt
sed -i '1 i\avoid_warnings=1' /boot/config.txt
sed -i 's/console=tty0/console=tty3/' /boot/cmdline.txt
fi
echo "iTender 2022
Programmed by Tobias Hopp" >/etc/motd
echo "[Service]
ExecStart=/usr/sbin/dhcpcd -q" >/etc/systemd/system/dhcpcd.service.d/wait.conf
chown itender:itender -R /home/itender/
adduser itender gpio
adduser itender sudo
reboot now

View File

@ -1,6 +1,7 @@
import GPIO from "rpi-gpio";
import Container from "./database/Container";
import debug from "debug";
const log = debug("itender:gpio");
// Package is raspi-gpio in raspberrypi

View File

@ -78,7 +78,7 @@ export class WebSocketHandler {
let stats = {
"drinks_finished": (await Job.countDocuments({successful: true})),
"drink_most": ( counts.length == 0 ) ? "Keiner" : counts[0].name,
"drink_most": (counts.length == 0) ? "Keiner" : counts[0].name,
"count_ingredients": (await Ingredient.countDocuments()),
"count_cocktails": (await Drink.countDocuments())
};

View File

@ -41,7 +41,6 @@ router.ws('/', async (ws, req, next) => {
}
switch (msg.event) {
case WebSocketEvent.TARE: {
if (msg.data["state"] == true) {
@ -52,14 +51,14 @@ router.ws('/', async (ws, req, next) => {
break;
}
case WebSocketEvent.CONTAINERS: {
let data = msg.data as { pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; volume: number; }[];
await Container.deleteMany({});
let data = msg.data as { pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; }[];
await Container.deleteMany({}); // V2: Remove this and check every container based on id if changes occurs
let i = 0;
for (let c of data) {
let container = new Container();
container.slot = i;
container.volume = c.volume;
//container.volume = c.volume; // V2: Removed
container.pumpPin = c.pumpPin;
container.sensorType = c.sensorType;
container.sensorPin1 = c.sensor1;
@ -83,6 +82,7 @@ router.ws('/', async (ws, req, next) => {
}
container.filled = parseInt(msg.data["filled"]);
container.volume = parseInt(msg.data["filled"]); // V2: Volume is now being updated after change of ingredient
container.content = ingredient;
await container.save();
@ -94,7 +94,7 @@ router.ws('/', async (ws, req, next) => {
case WebSocketEvent.CONFIG: {
// ToDo
console.log("New Settings:", msg.data);
// Danach setup modus us
// Danach setup modus aus
for (const [key, value] of Object.entries(msg.data)) {
Settings.set(key, value);
}