Compare commits
18
Commits
580688a850
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5341379774 | ||
|
|
75f2635277 | ||
|
|
6b8edbd8ae | ||
|
|
a7b2188a47 | ||
|
|
7a5bc7e5b0 | ||
|
|
4fd3f1d322 | ||
|
|
0ab4988964 | ||
|
|
f6cdbce038 | ||
|
|
630f3920ed | ||
|
|
a71924c2e9 | ||
|
|
98bac35ca4 | ||
|
|
1a48c4d1d8 | ||
|
|
3baab5e20a | ||
|
|
c09524fec8 | ||
|
|
2d7ec8c2fb | ||
|
|
675d050581 | ||
|
|
bf0216684d | ||
|
|
ccc70e9e4f |
No files matched your search
@@ -11,3 +11,27 @@ Bau eines Hausaufgaben Robos
|
|||||||
* Repo für die Web-App, um den Vokabeltester / Mathe-Checker zu starten.
|
* Repo für die Web-App, um den Vokabeltester / Mathe-Checker zu starten.
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
|
|
||||||
|
## Configs
|
||||||
|
Das Unit file für einen quiz Service (auf Gunicorn Basis)
|
||||||
|
|
||||||
|
* vi /etc/systemd/system/quiz.service
|
||||||
|
|
||||||
|
~~~
|
||||||
|
[Unit]
|
||||||
|
Description=Gunicorn instance to serve quiz
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=kico
|
||||||
|
Group=www-data
|
||||||
|
WorkingDirectory=/home/kico/git/robotik-wise23/quiz
|
||||||
|
#Environment="PATH=/home/sammy/myproject/myprojectenv/bin"
|
||||||
|
#ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app
|
||||||
|
ExecStart=/usr/bin/gunicorn --workers 1 --bind 0.0.0.0:8000 quiz:app
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
~~~
|
||||||
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import RPi.GPIO as GPIO
|
||||||
|
import time
|
||||||
|
|
||||||
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
GPIO.setwarnings(False)
|
||||||
|
coil_A_1_pin = 24 # pink
|
||||||
|
coil_A_2_pin = 4 # orange
|
||||||
|
coil_B_1_pin = 23 # blau
|
||||||
|
coil_B_2_pin = 25 # gelb
|
||||||
|
coil2_A_1_pin = 18 # pink
|
||||||
|
coil2_A_2_pin = 22 # orange
|
||||||
|
coil2_B_1_pin = 17 # blau
|
||||||
|
coil2_B_2_pin = 27 # gelb
|
||||||
|
|
||||||
|
StepCount = 8
|
||||||
|
Seq = list(range(0, StepCount))
|
||||||
|
Seq[0] = [0,1,0,0]
|
||||||
|
Seq[1] = [0,1,0,1]
|
||||||
|
Seq[2] = [0,0,0,1]
|
||||||
|
Seq[3] = [1,0,0,1]
|
||||||
|
Seq[4] = [1,0,0,0]
|
||||||
|
Seq[5] = [1,0,1,0]
|
||||||
|
Seq[6] = [0,0,1,0]
|
||||||
|
Seq[7] = [0,1,1,0]
|
||||||
|
|
||||||
|
GPIO.setup(coil_A_1_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil_A_2_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil_B_1_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil_B_2_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil2_A_1_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil2_A_2_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil2_B_1_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil2_B_2_pin, GPIO.OUT)
|
||||||
|
|
||||||
|
def setStep(w1, w2, w3, w4):
|
||||||
|
GPIO.output(coil_A_1_pin, w1)
|
||||||
|
GPIO.output(coil2_A_1_pin, w1)
|
||||||
|
GPIO.output(coil_A_2_pin, w2)
|
||||||
|
GPIO.output(coil2_A_2_pin, w2)
|
||||||
|
GPIO.output(coil_B_1_pin, w3)
|
||||||
|
GPIO.output(coil2_B_1_pin, w3)
|
||||||
|
GPIO.output(coil_B_2_pin, w4)
|
||||||
|
GPIO.output(coil2_B_2_pin, w4)
|
||||||
|
|
||||||
|
def forward(delay, steps):
|
||||||
|
for i in range(steps):
|
||||||
|
for j in range(StepCount):
|
||||||
|
setStep(Seq[j][0], Seq[j][1], Seq[j][2], Seq[j][3])
|
||||||
|
time.sleep(delay)
|
||||||
|
|
||||||
|
def backwards(delay, steps):
|
||||||
|
for i in range(steps):
|
||||||
|
for j in reversed(range(StepCount)):
|
||||||
|
setStep(Seq[j][0], Seq[j][1], Seq[j][2], Seq[j][3])
|
||||||
|
time.sleep(delay)
|
||||||
|
|
||||||
|
# 20 langsame Schritte Vorwärts
|
||||||
|
# delay = 20
|
||||||
|
# steps = 20
|
||||||
|
# forward(int(delay) / 1000.0, int(steps))
|
||||||
|
|
||||||
|
# 200 schnelle Schritte Rückwärts
|
||||||
|
delay = 1
|
||||||
|
steps = 1000
|
||||||
|
backwards(int(delay) / 1000.0, int(steps))
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
\documentclass[12pt,a4paper]{article}
|
||||||
|
\usepackage[utf8]{inputenc}
|
||||||
|
\usepackage[T1]{fontenc}
|
||||||
|
\usepackage{lmodern}
|
||||||
|
\usepackage{graphicx}
|
||||||
|
\usepackage{xcolor}
|
||||||
|
\usepackage{qrcode}
|
||||||
|
\usepackage{geometry}
|
||||||
|
\usepackage{fancyhdr}
|
||||||
|
\usepackage{hyperref}
|
||||||
|
|
||||||
|
% Farbdefinitionen
|
||||||
|
\definecolor{HeaderColor}{rgb}{0.26, 0.45, 0.76} % Dunkelblau
|
||||||
|
\definecolor{TextColor}{rgb}{0.06, 0.42, 0.13} % Dunkelgrün
|
||||||
|
\definecolor{LinkColor}{rgb}{0.76, 0.13, 0.28} % Dunkelrot
|
||||||
|
|
||||||
|
% Seitenlayout und Ränder
|
||||||
|
\geometry{
|
||||||
|
left=20mm,
|
||||||
|
right=20mm,
|
||||||
|
top=30mm,
|
||||||
|
bottom=30mm,
|
||||||
|
headheight=15mm,
|
||||||
|
footskip=15mm
|
||||||
|
}
|
||||||
|
|
||||||
|
% Kopf- und Fußzeilen
|
||||||
|
\pagestyle{fancy}
|
||||||
|
\fancyhf{}
|
||||||
|
% \rhead{\includegraphics[width=3cm]{logo.png}} % Logo einfügen
|
||||||
|
\lhead{\textcolor{HeaderColor}{\Large IQ-O-Mat}}
|
||||||
|
\lfoot{\textcolor{TextColor}{Kinder-College}}
|
||||||
|
\rfoot{\thepage}
|
||||||
|
|
||||||
|
% Schriftart und Farben
|
||||||
|
\renewcommand{\familydefault}{\sfdefault} % Serifenlose Schrift
|
||||||
|
\setlength{\parindent}{0em}
|
||||||
|
\setlength{\parskip}{1em}
|
||||||
|
\color{TextColor}
|
||||||
|
|
||||||
|
\providecommand{\tightlist}{%
|
||||||
|
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
|
||||||
|
|
||||||
|
\setcounter{secnumdepth}{0} % Deaktiviert die Nummerierung von Überschriften
|
||||||
|
|
||||||
|
% Pandoc spezifische Einstellungen (für Titel, Autoren, Datum, etc.)
|
||||||
|
$if(title)$
|
||||||
|
\title{$title$}
|
||||||
|
$endif$
|
||||||
|
$if(author)$
|
||||||
|
\author{$for(author)$$author$$sep$ \and $endfor$}
|
||||||
|
$endif$
|
||||||
|
$if(date)$
|
||||||
|
\date{$date$}
|
||||||
|
$endif$
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
$if(title)$
|
||||||
|
\maketitle
|
||||||
|
$endif$
|
||||||
|
|
||||||
|
$body$
|
||||||
|
|
||||||
|
\end{document}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Executable
+39
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
ABLAGEDIR=~/Robotik-Ablage
|
||||||
|
PDFDIR=$ABLAGEDIR/pdfs
|
||||||
|
mkdir -p $PDFDIR
|
||||||
|
for i in {01..39}
|
||||||
|
#for i in {01..02}
|
||||||
|
do
|
||||||
|
cat <<EOF > $PDFDIR/kicopi$i.md
|
||||||
|
---
|
||||||
|
title: "IQ-O-Mat"
|
||||||
|
author: "Kinder-College Björn Runden <br@runden.de>"
|
||||||
|
date: "2024-01-13"
|
||||||
|
---
|
||||||
|
## Quiz-Roboter
|
||||||
|
|
||||||
|
*Entstanden am Kinder-College als "Hausaufgaben-Robo"*
|
||||||
|
|
||||||
|
Wenn der Raspi Hochgefahren ist, gelangt man zur App mit dem URL:
|
||||||
|
|
||||||
|
* [http://KiCoPi$i.local/](http://kicopi$i.local/)
|
||||||
|
|
||||||
|
Oder dem Link im QR Code folgen:
|
||||||
|
|
||||||
|
\\begin{figure}[h]
|
||||||
|
\\centering
|
||||||
|
\\qrcode[height=6cm]{http://kicopi$i.local/}
|
||||||
|
\\end{figure}
|
||||||
|
|
||||||
|
*Anmerkungen:* (WLAN am Raspberry einschalten:)
|
||||||
|
|
||||||
|
* https://www.elektronik-kompendium.de/sites/raspberry-pi/1912221.htm
|
||||||
|
* https://www.raspberry-pi-geek.de/ausgaben/rpg/2017/10/ssh-und-wlan-schon-bei-der-installation-konfigurieren/
|
||||||
|
|
||||||
|
Der Raspberry kann daheim per LAN Kabel betrieben werden. Danach mittels raspi-config in's heimische WLAN eingebunden werden.
|
||||||
|
Der Raspberry kann per HDMI am Monitor oder TV betrieben werden. Mit (USB-) Maus und Tastatur lässt er sich ins WLAN einbinden.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
pandoc $PDFDIR/kicopi$i.md -o $PDFDIR/kicopi$i.pdf --template default.latex
|
||||||
|
done
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# IQ-O-Mat
|
||||||
|
**Quiz-Roboter**
|
||||||
|
*Entstanden am Kinder-College als "Hausaufgaben-Robo"*
|
||||||
|
|
||||||
|
Wenn der Raspi Hochgefahren ist, gelangt man zur App mit dem URL:
|
||||||
|
|
||||||
|
* [KiCoPi{NUM}](http://kicopi{NUM}.local/)
|
||||||
|
|
||||||
|
Oder dem Link im QR Code folgen:
|
||||||
|
|
||||||
|
* {QRCODE}
|
||||||
|
|
||||||
+70
-4
@@ -2,11 +2,13 @@ import os
|
|||||||
from flask import Flask, redirect, render_template, request, session
|
from flask import Flask, redirect, render_template, request, session
|
||||||
import csv # CSV handling
|
import csv # CSV handling
|
||||||
import random
|
import random
|
||||||
|
import RPi.GPIO as GPIO
|
||||||
|
import time
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
def load_database():
|
def load_database():
|
||||||
file = os.path.join(os.path.expanduser("~"), "Robotik-Ablage", "fragen2.csv")
|
file = os.path.join(os.path.expanduser("~"), "Robotik-Ablage", "quiz.csv")
|
||||||
|
|
||||||
#with open(file, newline="", encoding="utf-8") as csvfile: #
|
#with open(file, newline="", encoding="utf-8") as csvfile: #
|
||||||
with open(file, newline="", encoding="cp1252") as csvfile: # Code wird als Excel Windows-1252 Input CSV gelesen
|
with open(file, newline="", encoding="cp1252") as csvfile: # Code wird als Excel Windows-1252 Input CSV gelesen
|
||||||
@@ -18,8 +20,72 @@ def load_database():
|
|||||||
answer = str(row[2]) # Antwort (3. Spalte in der CSV Datenbank)
|
answer = str(row[2]) # Antwort (3. Spalte in der CSV Datenbank)
|
||||||
q_a.append({"index": index,"question": question, "answer": answer}) # Eine Liste bauen
|
q_a.append({"index": index,"question": question, "answer": answer}) # Eine Liste bauen
|
||||||
return q_a
|
return q_a
|
||||||
|
|
||||||
|
###
|
||||||
|
# Volle Drehung sind etwa 16400
|
||||||
|
# 1/4 Drehung = 1 Loch weiter = 4100 / evtl. 4300
|
||||||
|
ViertelRundeSteps = 4800
|
||||||
|
|
||||||
|
# ----------------- MOTOR KRAM
|
||||||
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
GPIO.setwarnings(False)
|
||||||
|
coil_A_1_pin = 24 # pink
|
||||||
|
coil_A_2_pin = 4 # orange
|
||||||
|
coil_B_1_pin = 23 # blau
|
||||||
|
coil_B_2_pin = 25 # gelb
|
||||||
|
coil2_A_1_pin = 18 # pink
|
||||||
|
coil2_A_2_pin = 22 # orange
|
||||||
|
coil2_B_1_pin = 17 # blau
|
||||||
|
coil2_B_2_pin = 27 # gelb
|
||||||
|
|
||||||
|
StepCount = 8
|
||||||
|
Seq = list(range(0, StepCount))
|
||||||
|
Seq[0] = [0,1,0,0]
|
||||||
|
Seq[1] = [0,1,0,1]
|
||||||
|
Seq[2] = [0,0,0,1]
|
||||||
|
Seq[3] = [1,0,0,1]
|
||||||
|
Seq[4] = [1,0,0,0]
|
||||||
|
Seq[5] = [1,0,1,0]
|
||||||
|
Seq[6] = [0,0,1,0]
|
||||||
|
Seq[7] = [0,1,1,0]
|
||||||
|
|
||||||
|
GPIO.setup(coil_A_1_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil_A_2_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil_B_1_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil_B_2_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil2_A_1_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil2_A_2_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil2_B_1_pin, GPIO.OUT)
|
||||||
|
GPIO.setup(coil2_B_2_pin, GPIO.OUT)
|
||||||
|
|
||||||
|
def setStep(w1, w2, w3, w4):
|
||||||
|
GPIO.output(coil_A_1_pin, w1)
|
||||||
|
GPIO.output(coil2_A_1_pin, w1)
|
||||||
|
GPIO.output(coil_A_2_pin, w2)
|
||||||
|
GPIO.output(coil2_A_2_pin, w2)
|
||||||
|
GPIO.output(coil_B_1_pin, w3)
|
||||||
|
GPIO.output(coil2_B_1_pin, w3)
|
||||||
|
GPIO.output(coil_B_2_pin, w4)
|
||||||
|
GPIO.output(coil2_B_2_pin, w4)
|
||||||
|
|
||||||
|
def forward(delay, steps):
|
||||||
|
for i in range(steps):
|
||||||
|
for j in range(StepCount):
|
||||||
|
setStep(Seq[j][0], Seq[j][1], Seq[j][2], Seq[j][3])
|
||||||
|
time.sleep(delay)
|
||||||
|
|
||||||
|
def backwards(delay, steps):
|
||||||
|
for i in range(steps):
|
||||||
|
for j in reversed(range(StepCount)):
|
||||||
|
setStep(Seq[j][0], Seq[j][1], Seq[j][2], Seq[j][3])
|
||||||
|
time.sleep(delay)
|
||||||
|
|
||||||
|
# ----------------- MOTOR KRAM ENDE
|
||||||
|
|
||||||
def FahreMotor():
|
def FahreMotor():
|
||||||
|
#forward(1.0/1000.0, ViertelRundeSteps)
|
||||||
|
# falls auf der anderen Seite montiert:
|
||||||
|
backwards(1.0/1000.0, ViertelRundeSteps)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
fragen_liste = load_database()
|
fragen_liste = load_database()
|
||||||
@@ -57,7 +123,7 @@ def submit_quiz():
|
|||||||
user_answer = request.form.get('answer')
|
user_answer = request.form.get('answer')
|
||||||
correct_answer = fragen_liste[current_index]['answer']
|
correct_answer = fragen_liste[current_index]['answer']
|
||||||
|
|
||||||
if user_answer.lower() == correct_answer.lower():
|
if user_answer.strip() == correct_answer.strip():
|
||||||
last_correct = True
|
last_correct = True
|
||||||
correct_sum += 1
|
correct_sum += 1
|
||||||
# debugtxt = correct_answer + " ist richtig! passt zu deiner Angabe: " + user_answer
|
# debugtxt = correct_answer + " ist richtig! passt zu deiner Angabe: " + user_answer
|
||||||
@@ -89,8 +155,8 @@ def submit_quiz():
|
|||||||
current_index=0
|
current_index=0
|
||||||
successtxt += "<br /> <br /> <br /> Gewonnen! - Gut gemacht! <br /> Guten Appetit!"
|
successtxt += "<br /> <br /> <br /> Gewonnen! - Gut gemacht! <br /> Guten Appetit!"
|
||||||
# print ("gewonnen! - Fahre 10 Sek!")
|
# print ("gewonnen! - Fahre 10 Sek!")
|
||||||
FahreMotor
|
|
||||||
correct_sum =0
|
correct_sum =0
|
||||||
won = True
|
won = True
|
||||||
|
FahreMotor()
|
||||||
|
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
# + Updatefunktion
|
# + Updatefunktion
|
||||||
|
|
||||||
#GITDIR=~/git/robotSoSe2022
|
#GITDIR=~/git/robotSoSe2022
|
||||||
#GITDIR=~/git/robotik-wise23
|
GITDIR=~/git/robotik-wise23
|
||||||
GITDIR=./
|
#GITDIR=./
|
||||||
|
|
||||||
Choice=$( whiptail --title "Hausaufgabenrobo Start und Update" --radiolist \
|
Choice=$( whiptail --title "Hausaufgabenrobo Start und Update" --radiolist \
|
||||||
"Bitte wählen" 20 78 4 \
|
"Bitte wählen" 20 78 4 \
|
||||||
|
|||||||
Reference in new issue
Block a user