jvpernis / esp32-ps3

Control your ESP32 projects with a PS3 controller!
319 stars 86 forks source link

Cant combine two codes #46

Open poisoh opened 2 years ago

poisoh commented 2 years ago

There are code with live video streaming + listening commands from port 400 and sending to serial. Need add code to paire ps3 gamepad over Bluetooth. I can paire ps3 with esp32cam with example code from library. But there is many errors when adding ps3conltroller library to code for vodeo streaming. Help please.

ESP32Cam. Board "AI Thinker ESP32-CAM"

WiFi ESP32-CAM Controller on Android app..https://play.google.com/store/apps/details?id=com.fvasquez.esp32_wifi_controller&hl=en_US&gl=US

`/***** Rui Santos Complete project details at https://RandomNerdTutorials.com/esp32-cam-video-streaming-web-server-camera-home-assistant/

IMPORTANT!!!

`#include

int Flashlight = 4; bool Flashlightstatus=false;

void notify() { //--- Digital cross/square/triangle/circle button events --- if( Ps3.event.button_down.cross ) Serial.println("cross_on"); if( Ps3.event.button_up.cross ) Serial.println("cross_off");

if( Ps3.event.button_down.square )
    Serial.println("square_on");
if( Ps3.event.button_up.square )
    Serial.println("square_off");

if( Ps3.event.button_down.triangle )
    Serial.println("triangle_on");
if( Ps3.event.button_up.triangle )
    Serial.println("triangle_off");

if( Ps3.event.button_down.circle )
    Serial.println("circle_on");
if( Ps3.event.button_up.circle )
    Serial.println("circle_off");

//--------------- Digital D-pad button events --------------
if( Ps3.event.button_down.up ){
    Serial.println("up_on");

} if( Ps3.event.button_up.up ){ Serial.println("up_off"); }

if( Ps3.event.button_down.right ){
    Serial.println("right_on");

} if( Ps3.event.button_up.right ){ Serial.println("right_off"); }

if( Ps3.event.button_down.down ){
    Serial.println("down_on");

} if( Ps3.event.button_up.down ){ Serial.println("down_off"); }

if( Ps3.event.button_down.left ){
    Serial.println("left_on");

} if( Ps3.event.button_up.left ){ Serial.println("left_off"); }

//------------- Digital shoulder button events -------------
if( Ps3.event.button_down.l1 )
    Serial.println("left1_on");
if( Ps3.event.button_up.l1 )
    Serial.println("left1_off");

if( Ps3.event.button_down.r1 )
    Serial.println("right1_on");
if( Ps3.event.button_up.r1 )
    Serial.println("right1_off");

//-------------- Digital trigger button events -------------
if( Ps3.event.button_down.l2 )
    Serial.println("left2_on");
if( Ps3.event.button_up.l2 )
    Serial.println("left2_off");

if( Ps3.event.button_down.r2 )
    Serial.println("right2_on");
if( Ps3.event.button_up.r2 )
    Serial.println("right2_off");

//--------------- Digital stick button events --------------
if( Ps3.event.button_down.l3 )
    Serial.println("left3_on");
if( Ps3.event.button_up.l3 )
    Serial.println("left3_off");

if( Ps3.event.button_down.r3 )
    Serial.println("right3_on");
if( Ps3.event.button_up.r3 )
    Serial.println("right3_off");

//---------- Digital select/start/ps button events ---------
if( Ps3.event.button_down.select )
    Serial.println("select_on");
if( Ps3.event.button_up.select )
    Serial.println("select_off");

if( Ps3.event.button_down.start )
    Serial.println("start_on");
if( Ps3.event.button_up.start )
    Serial.println("start_off");

if( Ps3.event.button_down.ps ){
    Flashlights();
    Serial.println("ps_on");}
if( Ps3.event.button_up.ps ){
    Serial.println("ps_off");}

//---------------- Analog stick value events ---------------

if( abs(Ps3.event.analog_changed.stick.lx) + abs(Ps3.event.analog_changed.stick.ly) > 2 ){ Serial.print("lsx"); Serial.println(Ps3.data.analog.stick.lx, DEC); Serial.print("lsy"); Serial.println(Ps3.data.analog.stick.ly, DEC); }

if( abs(Ps3.event.analog_changed.stick.rx) + abs(Ps3.event.analog_changed.stick.ry) > 2 ){ Serial.print("rsx"); Serial.println(Ps3.data.analog.stick.rx, DEC); Serial.print("rsy"); Serial.println(Ps3.data.analog.stick.ry, DEC); }

}

void onConnect(){ Serial.println("Connected."); // Turn rumble on full intensity Ps3.setRumble(100.0, 1000); delay(500); // Turn rumble on full intensity indefinitely Ps3.setRumble(50.1000); delay(500); // Turn off rumble Ps3.setRumble(0.0);

    Flashlights();
    delay(1000);
    Flashlights();

}

void setup() { Serial.begin(115200);

Ps3.attach(notify);
Ps3.attachOnConnect(onConnect);
Ps3.begin("8c:ce:4e:88:47:ea");

Serial.println("Ready.");

pinMode(Flashlight, OUTPUT); }

void loop(){ if(!Ps3.isConnected()){ return; }

delay(100);

}

void Flashlights(void) { if (!Flashlightstatus){ digitalWrite(Flashlight,HIGH); Flashlightstatus=true;} else{ digitalWrite(Flashlight,LOW); Flashlightstatus=false;} }`

poisoh commented 2 years ago

If add #include videostream not work without error