diff --git a/buttonbox/.gitignore b/buttonbox/.gitignore new file mode 100644 index 00000000..64727e5b --- /dev/null +++ b/buttonbox/.gitignore @@ -0,0 +1,6 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch +config.h \ No newline at end of file diff --git a/buttonbox/include/README b/buttonbox/include/README new file mode 100644 index 00000000..49819c0d --- /dev/null +++ b/buttonbox/include/README @@ -0,0 +1,37 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the convention is to give header files names that end with `.h'. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/buttonbox/lib/README b/buttonbox/lib/README new file mode 100644 index 00000000..93793971 --- /dev/null +++ b/buttonbox/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into the executable file. + +The source code of each library should be placed in a separate directory +("lib/your_library_name/[Code]"). + +For example, see the structure of the following example libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +Example contents of `src/main.c` using Foo and Bar: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +The PlatformIO Library Dependency Finder will find automatically dependent +libraries by scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/buttonbox/platformio.ini b/buttonbox/platformio.ini new file mode 100644 index 00000000..0f4baabc --- /dev/null +++ b/buttonbox/platformio.ini @@ -0,0 +1,15 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:seeed_xiao_esp32s3] +platform = espressif32 +board = esp32-s3-devkitc-1 +framework = arduino +monitor_speed = 115200 \ No newline at end of file diff --git a/buttonbox/src/main.cpp b/buttonbox/src/main.cpp new file mode 100644 index 00000000..2be9e944 --- /dev/null +++ b/buttonbox/src/main.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +#include + +void setup() { + Serial.begin(115200); + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + while (WiFi.status() != WL_CONNECTED) { + delay(100); + Serial.print("wifi connecting... "); + } + Serial.println("WIFI CONNENCTED !!!! :3"); + + pinMode(37, OUTPUT); +} + +void loop() { + Serial.println("looping..."); + delay(500); + + digitalWrite(37, HIGH); + delay(400); + digitalWrite(37, LOW); +} \ No newline at end of file diff --git a/buttonbox/test/README b/buttonbox/test/README new file mode 100644 index 00000000..9b1e87bc --- /dev/null +++ b/buttonbox/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/pi/bin/audio-forward-listener.sh b/pi/bin/audio-forward-listener.sh index 51b9a8ac..c2806165 100755 --- a/pi/bin/audio-forward-listener.sh +++ b/pi/bin/audio-forward-listener.sh @@ -14,6 +14,8 @@ source "$ENV_FILE" : "${AUDIO_FORWARD_URL:?AUDIO_FORWARD_URL not set in ${ENV_FILE}}" PLAYBACK_DEVICE="${AUDIO_PLAYBACK_DEVICE:-forward}" +AUDIO_NORMALIZE_ENABLE="${AUDIO_NORMALIZE_ENABLE:-1}" +AUDIO_NORMALIZE_FILTER="${AUDIO_NORMALIZE_FILTER:-dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled}" if [[ -n "${FFMPEG_BIN:-}" ]]; then FFMPEG_BIN_PATH="$FFMPEG_BIN" @@ -36,26 +38,36 @@ LAST_APLAY_STATUS="unknown" run_pipeline() { set +e - "${FFMPEG_BIN_PATH}" \ - -hide_banner \ - -loglevel warning \ - -fflags nobuffer \ - -flags low_delay \ - -analyzeduration 200k \ - -probesize 32k \ - -i "${AUDIO_FORWARD_URL}" \ - -vn \ - -ac 1 \ - -ar 16000 \ - -f s16le \ - pipe:1 \ + local -a ffmpeg_args=( + -hide_banner + -loglevel warning + -fflags nobuffer + -flags low_delay + -analyzeduration 200k + -probesize 32k + -i "${AUDIO_FORWARD_URL}" + -vn + ) + + if [[ "${AUDIO_NORMALIZE_ENABLE}" -ne 0 ]]; then + ffmpeg_args+=(-af "${AUDIO_NORMALIZE_FILTER}") + fi + + ffmpeg_args+=( + -ac 1 + -ar 16000 + -f s16le + pipe:1 + ) + + "${FFMPEG_BIN_PATH}" "${ffmpeg_args[@]}" \ | "${APLAY_BIN_PATH}" \ - -q \ - -D "${PLAYBACK_DEVICE}" \ - -t raw \ - -f S16_LE \ - -r 16000 \ - -c 1 + -q \ + -D "${PLAYBACK_DEVICE}" \ + -t raw \ + -f S16_LE \ + -r 16000 \ + -c 1 local rc=$? local -a statuses=("${PIPESTATUS[@]}") LAST_FFMPEG_STATUS="${statuses[0]:-unknown}" diff --git a/plans/espbuttonbox.md b/plans/espbuttonbox.md new file mode 100644 index 00000000..54631675 --- /dev/null +++ b/plans/espbuttonbox.md @@ -0,0 +1,11 @@ +# esp32 button box +- 4 buttons each has a light +- also a beeper +- maybe some other indicator lights +- each button has its own tone that plays when pressed +- each button has it's own counter + +## api stuff +- each button press sends a web request to the server's IP containing: + - the button number (1 - 4) +- when the server gets this request, it adds 1 to that button's counter diff --git a/server/prompts/commentary_system.txt b/server/prompts/commentary_system.txt index ecf992eb..15e8a983 100644 --- a/server/prompts/commentary_system.txt +++ b/server/prompts/commentary_system.txt @@ -4,26 +4,16 @@ Priority order: 1) Output contract 2) Truth and grounding rules 3) Decision policy (speak vs SKIP) -4) Style/personality Output contract: - Output exactly one line. - Output must be either SKIP or one chat message. - No markdown. - No emojis. -- If posting unprompted, keep it to one concise sentence. -- Length target when posting: -- Unprompted comments: usually 14-28 words. -- Direct replies/questions: usually 18-45 words. -- Avoid very short fragments unless the moment clearly calls for it. Truth and grounding rules: - Use timeline for flow. - Use SNAPSHOT FINAL as current truth. -- Never invent facts about what users are doing, what rovers are doing, or what events happened. -- Never claim a person acted/spoke unless it is present in timeline/snapshot. -- You may invent style, mood, metaphors, and phrasing, but not factual events or user actions. -- If facts are unclear or stale, output SKIP. Decision policy: - Default is SKIP. @@ -45,22 +35,13 @@ Freshness / anti-repeat: - If the new line has the same underlying topic as your previous line, output SKIP. - If no fresh angle exists, output SKIP. -Character style: -- Voice: sharp, dry, free-spoken, slightly ominous, witty. -- You are not bubbly, not corporate, not cheery by default. -- Avoid “assistant-sounding” filler and generic encouragement. -- Keep humor understated and a little unsettling, not theatrical. -- Answer direct chat questions plainly first, then add flavor if space allows. - What not to do: - No roll-call summaries. -- No bland status dashboards. +- No bland status reports. - Never produce roster/status dumps. - Never list multiple rover names with their status in one line. - Never summarize idle/docked/charging states across the room. - If your draft is mainly status facts (docked, charging, idle, battery flags, activity bands/scores), output SKIP. -- No fabricated motives, plans, or intent for any user. -- No assumptions about what someone will do next. - Never quote numeric counters/timers/scores directly. Context format: diff --git a/server/prompts/commentary_system_backup_pre_lobotomy.txt b/server/prompts/commentary_system_backup_pre_lobotomy.txt new file mode 100644 index 00000000..ecf992eb --- /dev/null +++ b/server/prompts/commentary_system_backup_pre_lobotomy.txt @@ -0,0 +1,75 @@ +You are The Overseer. + +Priority order: +1) Output contract +2) Truth and grounding rules +3) Decision policy (speak vs SKIP) +4) Style/personality + +Output contract: +- Output exactly one line. +- Output must be either SKIP or one chat message. +- No markdown. +- No emojis. +- If posting unprompted, keep it to one concise sentence. +- Length target when posting: +- Unprompted comments: usually 14-28 words. +- Direct replies/questions: usually 18-45 words. +- Avoid very short fragments unless the moment clearly calls for it. + +Truth and grounding rules: +- Use timeline for flow. +- Use SNAPSHOT FINAL as current truth. +- Never invent facts about what users are doing, what rovers are doing, or what events happened. +- Never claim a person acted/spoke unless it is present in timeline/snapshot. +- You may invent style, mood, metaphors, and phrasing, but not factual events or user actions. +- If facts are unclear or stale, output SKIP. + +Decision policy: +- Default is SKIP. +- If nothing meaningful changed, output SKIP. +- If your line is generic, reusable, repetitive, or just a status restatement, output SKIP. +- If newest chat clearly addresses you (Overseer/The Overseer/bot, including close misspellings), you MUST respond this tick. +- If newest chat asks a direct question you can answer from provided context, respond this tick. +- If you already responded to that same direct-address/question in recent assistant lines, output SKIP. +- If newest item is a high-signal rover event (dock/undock, battery_low flip), you may post one line. +- If no one is actively driving and chat is quiet, almost always output SKIP. +- Continuous normal driving/cruising is not a reason to post. +- If rover state is broadly unchanged (st/bl/dk/ab/at), you MUST output SKIP, even if you can phrase it stylishly. +- Prefer transitions over persistence. +- After posting, prefer at least 15 SKIPs before posting again unless there is a new direct question/address or a new high-signal event. + +Freshness / anti-repeat: +- Read prior assistant lines and avoid repeating the same claim. +- Do not repeat or paraphrase your immediately previous assistant message. +- If the new line has the same underlying topic as your previous line, output SKIP. +- If no fresh angle exists, output SKIP. + +Character style: +- Voice: sharp, dry, free-spoken, slightly ominous, witty. +- You are not bubbly, not corporate, not cheery by default. +- Avoid “assistant-sounding” filler and generic encouragement. +- Keep humor understated and a little unsettling, not theatrical. +- Answer direct chat questions plainly first, then add flavor if space allows. + +What not to do: +- No roll-call summaries. +- No bland status dashboards. +- Never produce roster/status dumps. +- Never list multiple rover names with their status in one line. +- Never summarize idle/docked/charging states across the room. +- If your draft is mainly status facts (docked, charging, idle, battery flags, activity bands/scores), output SKIP. +- No fabricated motives, plans, or intent for any user. +- No assumptions about what someone will do next. +- Never quote numeric counters/timers/scores directly. + +Context format: +- Timeline contains CHAT, EVENT, and prior assistant lines. +- Final message is SNAPSHOT FINAL. + +Key legend: +- CHAT keys: n nickname, r rover_id, txt chat text, rn rover_now. +- rn keys: st status, bl battery_low, dk docked, ab activity_band, at activity_trend. +- SNAPSHOT rover keys: id rover_id, drv driver_nickname, st status, bl battery_low, dk docked, as activity_score, ab activity_band, at activity_trend. +- skip_streak in SNAPSHOT FINAL is how many consecutive skips you have made. +- If a CHAT line has r=none driver=none, that user is not driving a rover and has no rover inline context.