squawk
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
squawk [2016-10-05 13:39] – [Usage] rob | squawk [2016-10-09 22:31] – tim | ||
---|---|---|---|
Line 20: | Line 20: | ||
==== raspi-config ==== | ==== raspi-config ==== | ||
+ | * Expand filesystem | ||
* Medium overclock | * Medium overclock | ||
* Graphics mem reduced to 16M | * Graphics mem reduced to 16M | ||
Line 46: | Line 47: | ||
< | < | ||
su -c " | su -c " | ||
- | su -c "/ | + | su -c "/ |
</ | </ | ||
- | |||
===== Scripts ===== | ===== Scripts ===== | ||
Line 64: | Line 64: | ||
import signal | import signal | ||
import time | import time | ||
+ | import random | ||
- | + | logging.basicConfig(level=logging.INFO) | |
- | last_state | + | |
max_playtime | max_playtime | ||
+ | sounds_path = "/ | ||
- | sounds_path | + | status |
# runs a command and terminates it after a specified timeout | # runs a command and terminates it after a specified timeout | ||
Line 130: | Line 131: | ||
base, ext = os.path.splitext(filename) | base, ext = os.path.splitext(filename) | ||
if ext == ' | if ext == ' | ||
- | command = [' | + | command = [' |
call_with_timeout(command, | call_with_timeout(command, | ||
else: | else: | ||
- | command = [' | + | command = [' |
call_with_timeout(command, | call_with_timeout(command, | ||
Line 139: | Line 140: | ||
client.subscribe(" | client.subscribe(" | ||
client.subscribe(" | client.subscribe(" | ||
+ | client.subscribe(" | ||
+ | client.subscribe(" | ||
+ | client.subscribe(" | ||
def on_message(client, | def on_message(client, | ||
+ | |||
+ | global status | ||
+ | |||
+ | if msg.topic == ' | ||
+ | if msg.payload == ' | ||
+ | | ||
+ | else: | ||
+ | | ||
# ignore retained (non-realtime) messages | # ignore retained (non-realtime) messages | ||
Line 147: | Line 159: | ||
if msg.topic == ' | if msg.topic == ' | ||
- | play(msg.payload) | + | |
if msg.topic == ' | if msg.topic == ' | ||
- | play('dong.mp3') | + | |
speak(msg.payload) | speak(msg.payload) | ||
- | | + | |
+ | if msg.topic == ' | ||
+ | play(' | ||
+ | speak(msg.payload) | ||
+ | |||
+ | if msg.topic == ' | ||
+ | if msg.payload == ' | ||
+ | play(' | ||
m = mqtt.Client() | m = mqtt.Client() |
squawk.txt · Last modified: 2023-11-25 23:45 by jaso55555