Advertisement
Maderdash

Needs cleaning

Jun 17th, 2024
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   -- New project --
  3.  
  4.   This source code of graphical user interface
  5.   has been generated automatically by RemoteXY editor.
  6.   To compile this code using RemoteXY library 3.1.13 or later version
  7.   download by link http://remotexy.com/en/library/
  8.   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/                  
  9.     - for ANDROID 4.13.13 or later version;
  10.     - for iOS 1.10.3 or later version;
  11.  
  12.   This source code is free software; you can redistribute it and/or
  13.   modify it under the terms of the GNU Lesser General Public
  14.   License as published by the Free Software Foundation; either
  15.   version 2.1 of the License, or (at your option) any later version.    
  16. */
  17.  
  18.  
  19. //////////////////////////////////////////////
  20. //        RemoteXY include library          //
  21. //////////////////////////////////////////////
  22.  
  23.  
  24. // you can enable debug logging to Serial at 115200
  25. //#define REMOTEXY__DEBUGLOG
  26.  
  27.  
  28. // RemoteXY select connection mode and include library
  29. #define REMOTEXY_MODE__ESP32CORE_BLE
  30.  
  31. #include <BLEDevice.h>
  32.  
  33. // RemoteXY connection settings
  34. #define REMOTEXY_BLUETOOTH_NAME "dΓΌpr"
  35. #define REMOTEXY_ACCESS_PASSWORD "esp"
  36.  
  37.  
  38. #include <RemoteXY.h>
  39.  
  40. // RemoteXY GUI configuration
  41. #pragma pack(push, 1)
  42. uint8_t RemoteXY_CONF[] =  // 92 bytes
  43.   { 255, 6, 0, 4, 0, 85, 0, 17, 0, 0, 0, 31, 2, 106, 200, 200, 84, 1, 1, 5,
  44.     0, 5, 201, 21, 143, 143, 2, 18, 54, 54, 32, 190, 28, 31, 5, 28, 21, 129, 129, 144,
  45.     17, 54, 54, 32, 190, 28, 31, 4, 44, 232, 7, 86, 25, 2, 154, 14, 128, 190, 28, 2,
  46.     52, 74, 23, 52, 112, 30, 30, 11, 0, 190, 28, 31, 31, 79, 78, 0, 79, 70, 70, 0,
  47.     68, 45, 112, 21, 95, 55, 53, 90, 31, 17, 28, 190 };
  48.  
  49. // this structure defines all the variables and events of your control interface
  50. struct {
  51.  
  52.   // input variables
  53.   int8_t joystick_links_x;   // from -100 to 100
  54.   int8_t joystick_links_y;   // from -100 to 100
  55.   int8_t joystick_rechts_x;  // from -100 to 100
  56.   int8_t joystick_rechts_y;  // from -100 to 100
  57.   int8_t servo;              // from 0 to 100
  58.   uint8_t switch_main;       // =1 if switch ON and =0 if OFF
  59.  
  60.  
  61.   // output variables
  62.   float onlineGraph_01_var1;
  63.  
  64.   // other variable
  65.   uint8_t connect_flag;  // =1 if wire connected, else =0
  66.  
  67. } RemoteXY;
  68. #pragma pack(pop)
  69.  
  70.  
  71. /////////////////////////////////////////////
  72. //           END RemoteXY include          //
  73. /////////////////////////////////////////////
  74.  
  75.  
  76. #include <ESP32Servo.h>
  77.  
  78. Servo myServo;
  79.  
  80.  
  81. void setup() {
  82.   int A = 4;
  83.   int B = 5;
  84.   int l;
  85.   int L;
  86.   l = RemoteXY.joystick_links_y;
  87.   L = l / 100 * 255;
  88.   if (l > 0) {
  89.     L = L;
  90.     digitalWrite(A, 0);
  91.     analogWrite(B, L);
  92.   } else if (l < 0) {
  93.     L = -L;
  94.     digitalWrite(B, 0);
  95.     analogWrite(A, L);
  96.   } else {
  97.     L = 0;
  98.     digitalWrite(A, 0);
  99.     analogWrite(B, 0);
  100.   }
  101.  
  102.   int C = 6;
  103.   int D = 7;
  104.   int r;
  105.   int R;
  106.   r = RemoteXY.joystick_rechts_y;
  107.   R = r / 100 * 255;
  108.   if (r > 0) {
  109.     R = R;
  110.     digitalWrite(C, 0);
  111.     analogWrite(D, R);
  112.   } else if (r < 0) {
  113.     R = -R;
  114.     digitalWrite(D, 0);
  115.     analogWrite(C, R);
  116.   } else {
  117.     R = 0;
  118.     digitalWrite(C, 0);
  119.     analogWrite(D, 0);
  120.   }
  121.  
  122.   RemoteXY_Init();
  123.  
  124.   myServo.attach(1);
  125.   RemoteXY.servo = 0;
  126.  
  127.   // TODO your setup code
  128. }
  129.  
  130.  
  131.  
  132.  
  133. void loop() {
  134.   RemoteXY_Handler();
  135.  
  136.   int ms = RemoteXY.servo * 20 + 500;
  137.   myServo.writeMicroseconds(ms);
  138.  
  139.   drive();
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement