mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
prebubtotn
This commit is contained in:
+90
-6
@@ -4,6 +4,61 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
// button pin defs
|
||||||
|
const int buttonPins[] = {15, 16, 17, 18};
|
||||||
|
const int buttonCount = sizeof(buttonPins) / sizeof(buttonPins[0]);
|
||||||
|
const int beeperPin = 13;
|
||||||
|
|
||||||
|
// Using INPUT_PULLUP means idle = HIGH, pressed = LOW (button to GND).
|
||||||
|
const int buttonPressedState = LOW;
|
||||||
|
const unsigned long debounceMs = 40;
|
||||||
|
const int toneDurationMs = 90;
|
||||||
|
|
||||||
|
// One tone per button (1-4).
|
||||||
|
const int buttonTonesHz[buttonCount] = {262, 330, 392, 523};
|
||||||
|
|
||||||
|
int lastStableState[buttonCount];
|
||||||
|
int lastReading[buttonCount];
|
||||||
|
unsigned long lastDebounceTime[buttonCount];
|
||||||
|
|
||||||
|
void PlayButtonTone(int buttonNumber) {
|
||||||
|
if (buttonNumber < 1 || buttonNumber > buttonCount) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int frequencyHz = buttonTonesHz[buttonNumber - 1];
|
||||||
|
tone(beeperPin, frequencyHz, toneDurationMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// button request function
|
||||||
|
bool SendButtonPressRequest(int buttonNumber) {
|
||||||
|
Serial.println("attempting to send button press");
|
||||||
|
bool success = false;
|
||||||
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
HTTPClient http;
|
||||||
|
http.begin(SERVER_URL);
|
||||||
|
http.addHeader("Content-Type", "text/plain");
|
||||||
|
|
||||||
|
int httpResponseCode = http.POST(String(buttonNumber));
|
||||||
|
|
||||||
|
if (httpResponseCode > 0) {
|
||||||
|
Serial.println("http response code: ");
|
||||||
|
Serial.print(httpResponseCode);
|
||||||
|
Serial.println(http.getString());
|
||||||
|
success = true;
|
||||||
|
} else {
|
||||||
|
Serial.println("HTTP ERROR!!! ");
|
||||||
|
Serial.print(httpResponseCode);
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
http.end();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Serial.println("Not ocnnectec to wifi! cant send request!");
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
||||||
@@ -13,14 +68,43 @@ void setup() {
|
|||||||
}
|
}
|
||||||
Serial.println("WIFI CONNENCTED !!!! :3");
|
Serial.println("WIFI CONNENCTED !!!! :3");
|
||||||
|
|
||||||
pinMode(37, OUTPUT);
|
for (int i = 0; i < buttonCount; i++) {
|
||||||
|
pinMode(buttonPins[i], INPUT_PULLUP);
|
||||||
|
int initial = digitalRead(buttonPins[i]);
|
||||||
|
lastStableState[i] = initial;
|
||||||
|
lastReading[i] = initial;
|
||||||
|
lastDebounceTime[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pinMode(beeperPin, OUTPUT);
|
||||||
|
noTone(beeperPin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
Serial.println("looping...");
|
unsigned long now = millis();
|
||||||
delay(500);
|
|
||||||
|
|
||||||
digitalWrite(37, HIGH);
|
for (int i = 0; i < buttonCount; i++) {
|
||||||
delay(400);
|
int reading = digitalRead(buttonPins[i]);
|
||||||
digitalWrite(37, LOW);
|
|
||||||
|
if (reading != lastReading[i]) {
|
||||||
|
lastDebounceTime[i] = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((now - lastDebounceTime[i]) > debounceMs) {
|
||||||
|
if (reading != lastStableState[i]) {
|
||||||
|
lastStableState[i] = reading;
|
||||||
|
|
||||||
|
// Trigger once on press edge.
|
||||||
|
if (reading == buttonPressedState) {
|
||||||
|
if (SendButtonPressRequest(i + 1)) {
|
||||||
|
PlayButtonTone(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lastReading[i] = reading;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(5);
|
||||||
}
|
}
|
||||||
+42
-10
@@ -1,11 +1,43 @@
|
|||||||
# esp32 button box
|
# button box mechanic
|
||||||
- 4 buttons each has a light
|
- a box with 4 buttons which sends web requests to the server when a button is pressed
|
||||||
- also a beeper
|
- each button has a counter in the server
|
||||||
- maybe some other indicator lights
|
- when the counter's goal is met, the reward happens
|
||||||
- each button has its own tone that plays when pressed
|
|
||||||
- each button has it's own counter
|
|
||||||
|
|
||||||
## api stuff
|
## rewards
|
||||||
- each button press sends a web request to the server's IP containing:
|
- theres a list of rewards in the server
|
||||||
- the button number (1 - 4)
|
- rewards create chaos in different ways using the physical things that already exist
|
||||||
- when the server gets this request, it adds 1 to that button's counter
|
- rewards have actions and a counter goal set per reward to assign value to better rewards
|
||||||
|
- when a reward is met, the button gets a new goal, reset counter, and new reward
|
||||||
|
|
||||||
|
## UI
|
||||||
|
- a new full-width panel above the room cameras in the main tab
|
||||||
|
- divided into columns, one for each of the 4 buttons
|
||||||
|
- each columns shows:
|
||||||
|
- button number
|
||||||
|
- current count
|
||||||
|
- reward and reward number
|
||||||
|
- column flashes when button gets upped
|
||||||
|
- column plays a sound when button gets upped. same tone as the button.
|
||||||
|
- match styling and layout rules of the rest of the ui
|
||||||
|
|
||||||
|
### reward ideas
|
||||||
|
1. dock panic
|
||||||
|
force all online rovers to run seek-dock immediately, interrupting whatever it was doing and causing sudden behavior change
|
||||||
|
2. camera whiplash
|
||||||
|
apply a short burst of random camera servo nudges on all rovers so the view jerks around rapidly for a moment
|
||||||
|
3. light strobe
|
||||||
|
toggle all configured room controls on and off repeatedly for 10 seconds
|
||||||
|
4. ghost typing spam
|
||||||
|
emit fake typing events into chat so users see rapid typing indicators from fake/ghost senders without actual messages
|
||||||
|
5. darkness
|
||||||
|
turn room lights off for 1 minute and force rover night-vision/headlight state off for that same window, then restore normal state
|
||||||
|
6. discord stalker ping
|
||||||
|
send a chaos alert message to the configured discord general channel and ping the configured stalker role
|
||||||
|
7. rogue event spam
|
||||||
|
push a burst of fake alert events with random titles/colors into the web ui alert feed for jump-scare style noise
|
||||||
|
8. mode jam
|
||||||
|
switch server mode to admin for a short timed window, set admin reason to a chaos message at activation, then restore previous mode and previous admin reason
|
||||||
|
9. assignment roulette
|
||||||
|
forcibly release current user rover assignments/drivers and let assignment logic re-place users, causing sudden rover ownership reshuffle
|
||||||
|
10. chat spam
|
||||||
|
spam random letters in chat as an injected spectator user with a random letter name
|
||||||
|
|||||||
Reference in New Issue
Block a user