8 # ----------------------- button beep ----------------------------------------------------------------
11 # ./fast-gpio pwm 38 500 50 7
13 # play -n synth sin %41 fade q 0.0 0.1 0.01 gain -25
16 # ----------------------------------------------------------------------------------------------------
18 # KBD_READ=$(( $KBD_MASK ^ ($1 & $KBD_MASK) ))
22 ## curentNumberOfMessages=$(awk 'END {print NR}' $TMPFS/$message)
24 if [ ! -s "$TMPFS/$kbdExec" ]; then
27 echo $KBD_READ > $TMPFS/$kbdExec
31 "$KBD_V_UP") # ----------------------- volume up --------------------------
37 currentVolume=$(cat $TMPFS/$volume)
38 if [ "$currentVolume" -lt "$VOLMAX" ]; then
39 currentVolume=$(( $currentVolume + $VOLSTEP ))
44 setVolume $currentVolume > /dev/null
45 echo $currentVolume > $TMPFS/$volume
48 "$KBD_V_DOWN") # ----------------------- volume down ----------------------
54 currentVolume=$(cat $TMPFS/$volume)
55 if [ "$currentVolume" -gt "$VOLMIN" ]; then
56 currentVolume=$(( $currentVolume - $VOLSTEP ))
60 setVolume $currentVolume > /dev/null
61 echo $currentVolume > $TMPFS/$volume
64 # ------------------- vol + & vol - shutdown ------------------------------
66 "$(( $KBD_V_UP ^ $KBD_V_DOWN ))")
68 echo "vol + - pressed" | myLog
70 if [ ! -s "$shutDown" ]; then
71 date +%s > "$shutDown"
74 prevtime=$(cat "$shutDown" 2>/dev/null)
75 if [ "$prevtime" == "" ]; then
79 tdiff=$(( $time - $prevtime ))
82 if [ "$tdiff" -gt "$SHORT_BUTTON_HOLD" ]; then
84 shutdownDevice $BUTTON_SHUTDOWN_DELAY "$DEV_JINGLE" "$DEVICE_OFF"
92 # ------------------- vol - & L, number of device -------------------------
94 # firmware version and date of updating
96 "$(( $KBD_V_UP ^ $KBD_L ))")
98 fwVER=$(cat version | tr "." " ")
100 if [ ! -f instime ]; then
104 insTime=$(date -d @$(cat instime) "+%d %B %Y" | sed "s/^0*//g; s/\.0*/./g")
106 CTfile=$(cat contenttime 2>/dev/null)
108 MAC=$(cat /proc/sys/kernel/hostname | awk -F'-' '{print $NF}')
110 if [ "$CTfile" == "" ]; then
113 contentTime=$(date -d @$CTfile "+%d %B %Y" | sed "s/^0*//g; s/\.0*/./g")
116 m1=$(generateRoboMessage "Device number is, $MAC")
117 m2=$(generateRoboMessage "Current firmware verson is, $fwVER, updated on, $insTime.")
118 m3=$(generateRoboMessage "Date of last content update is, $contentTime")
119 echo "$DEV_JINGLE|$m1|$m2|$m3|$DEV_JINGLE_OUT" > $TMPFS/$message
124 # ------------------- vol - & T, History Reset ----------------------------
126 "$(( $KBD_V_DOWN ^ $KBD_T ))")
128 echo "history reset" | myLog
130 narrativeStructureReset
132 m1=$(generateRoboMessage "The history of narration has been reset.")
133 echo "$DEV_JINGLE|$m1|$DEV_JINGLE_OUT" > $TMPFS/$message
138 "$KBD_T") # ----------------------- theme (language <) -------------------
144 listOfLanguages=$(ls -c1 $CONTENT)
145 numOflang=$( echo $listOfLanguages | awk '{print NF}' )
146 currentLN=$(cat $TMPFS/$currentLangNum)
148 if [ "$currentLN" -gt "1" ]; then
149 currentLN=$(( $currentLN - 1 ))
154 echo $currentLN > $TMPFS/$currentLangNum
155 currentL=$(echo $listOfLanguages | awk -v a=$currentLN '{print $a}')
156 echo $currentL > $TMPFS/$currentLang
158 echo "$DEV_JINGLE|$DEV_LANGUAGE" > $TMPFS/$message
160 echo $currentL $currentLN | myLog
165 "$KBD_L") # ----------------------- language > ----------------------------
169 echo "language" | myLog
171 if [ -s $TMPFS/$message ]; then
172 while killall madplay 2> /dev/null; do sleep 0; done
175 listOfLanguages=$(ls -c1 $CONTENT)
176 numOflang=$( echo $listOfLanguages | awk '{print NF}' )
177 currentLN=$(cat $TMPFS/$currentLangNum)
179 if [ "$currentLN" -lt "$numOflang" ]; then
180 currentLN=$(( $currentLN + 1 ))
185 echo $currentLN > $TMPFS/$currentLangNum
186 currentL=$(echo $listOfLanguages | awk -v a=$currentLN '{print $a}')
187 echo $currentL > $TMPFS/$currentLang
189 echo "$DEV_JINGLE|$DEV_LANGUAGE" > $TMPFS/$message
191 echo $currentL $currentLN | myLog
196 "$KBD_M") # ---------------------- nav memorize GPS ----------------------
200 echo "map marker" | myLog
204 CURRENTGPSStr=$(cat $CURRENTGPS)
205 prevtime=$(echo $CURRENTGPSStr | awk -F'|' '{print $3; exit}')
207 if [ "$prevtime" == "" ]; then prevtime=0; fi
208 tdiff=$(( $time - $prevtime ))
210 if [ "$prevtime" != "" ] && [ "$tdiff" -lt "$MAX_GPS_AGE_THRESHOLD" ]; then # valid GPS data checking
212 currentGPS=$(echo $CURRENTGPSStr | awk -F'|' '{print $1; exit}')
213 echo $currentGPS > $navMemo
215 # coordinates has been saved
217 echo "$DEV_JINGLE|$NAV_YOU_COORD_SAVED" > $TMPFS/$message
223 echo "$DEV_JINGLE|$DEV_NO_COORD" > $TMPFS/$message
225 echo "GPS not fixed" | myLog
231 "$KBD_R") # ----------------------- nav reminder -------------------------
235 echo "navigation" | myLog
239 if [ "$memo" != "" ]; then # GPS pont was saved early
241 navTurnedOn=$(cat $navOn)
243 if [ "$navTurnedOn" == "" ]; then
247 NAVMEMOGPS=$(cat $navMemo)
249 # navigation has been activated
251 echo "$DEV_JINGLE|$NAV_FUNC_ACTIVE" > $TMPFS/$message
253 echo "nav activated" | myLog
258 # navigation has been deactivated
260 echo $NAV_FUNC_TURNED_OFF >> $TMPFS/$message
262 echo "nav off" | myLog
265 else # device has no points in memory
267 echo $NAV_NO_POINTS >> $TMPFS/$message
269 echo "nav no saved points" | myLog
276 "$KBD_MIC") # ----------------------- mic --------------------------------
280 if [ -s "$wifiState" ]; then
284 myLog "mic wifi disabled"
291 "$KBD_WIFI") # ----------------------- wifi ------------------------------
297 if [ ! -s "$wifiButton" ]; then
298 date +%s > "$wifiButton"
301 prevtime=$(cat "$wifiButton" 2>/dev/null)
302 if [ "$prevtime" == "" ]; then
306 tdiff=$(( $time - $prevtime ))
309 if [ "$tdiff" -gt "$SHORT_BUTTON_HOLD" ]; then
313 if [ -s "$wifiState" ]; then
315 if [ "$MODE" == "l" ]; then
316 m1=$(generateRoboMessage "Leading mode deactivated.")
319 echo "$DEV_JINGLE|$DEV_WIFI_OFF|$m1" > $TMPFS/$message
323 myLog "wifi disabled"
329 echo "$DEV_JINGLE|$DEV_WIFI_ON|$DEV_JINGLE_OUT" > $TMPFS/$message
331 echo 1 > "$wifiState"
345 "$KBD_RELEASE") # ----------------------- release buttons ----------------
347 echo "kbd release" | myLog
351 if [ -s "$recStart" ]; then
354 # kill -9 $(pidof arecord)
355 # kill -9 $(pidof rec)
356 kill -15 $(cat /tmp/rec.pid)
357 echo "rec release" | myLog
362 if [ -s "$wifiButton" ]; then
368 if [ -s "$shutDown" ]; then
371 echo "$DEV_JINGLE|$INTRO_INSTRUCTION|$INTRO_INSTRUCTION_EXTRA|$INTRO_INSTRUCTION_EXTRA2|$DEV_JINGLE_OUT" > $TMPFS/$message