{"mode":"Blocks","workspace":"<xml xmlns=\"http://www.w3.org/1999/xhtml\"><variables><variable type=\"\" id=\"_2.^beQjx|FGt38A,8(E\" islocal=\"false\" iscloud=\"false\" arraylength=\"0\" arraywidth=\"0\">myVariable</variable></variables><block type=\"iq_events_when_started\" id=\".NsXwU_L.OuU1l7Sho$F\" x=\"70\" y=\"-90\"><next><block type=\"iq_motion_set_motor_velocity\" id=\"tA_ap9qXyoO?iFQ$5Ms)\"><field name=\"MOTOR\">IntakeMotor</field><field name=\"UNITS\">pct</field><value name=\"VELOCITY\"><shadow type=\"math_number\" id=\"s9(r#V29?(]RT;T%iGu~\"><field name=\"NUM\">100</field></shadow></value><next><block type=\"iq_motion_set_motor_velocity\" id=\"pm=I8_!jo44/J-D]97Pv\"><field name=\"MOTOR\">CatapultMotor</field><field name=\"UNITS\">pct</field><value name=\"VELOCITY\"><shadow type=\"math_number\" id=\";EV!+}{]TJjjq2d8sONF\"><field name=\"NUM\">100</field></shadow></value><next><block type=\"iq_drivetrain_set_drive_velocity\" id=\"GGXJJe4OU*)^!raaqdds\"><field name=\"UNITS\">pct</field><value name=\"VELOCITY\"><shadow type=\"math_number\" id=\"u8]aWRUuO+$v=bPGS7%r\"><field name=\"NUM\">100</field></shadow></value><next><block type=\"iq_control_forever\" id=\";!UZ{uZ7Q=0e-Oko)Y^-\"><statement name=\"SUBSTACK\"><block type=\"procedures_call\" id=\"Xmsj3Ivj=5Tb[)H8fG(V\"><mutation proccode=\"SetUp\" proceduredefid=\"XdZt:.@LfwVjxYP4s3mj\" argumentids=\"[]\" warp=\"false\"></mutation></block></statement></block></next></block></next></block></next></block></next></block><block type=\"iq_events_when_controller_button\" id=\"`ANwiVd{p5h1998C0;1*\" x=\"510\" y=\"-90\"><field name=\"BUTTON\">ButtonFUp</field><field name=\"EVENTTYPE\">released</field><next><block type=\"iq_motion_stop_motor\" id=\"g^eSn`_u0LyqOCN:MW/Q\"><field name=\"MOTOR\">CatapultMotor</field></block></next></block><block type=\"iq_events_when_controller_button\" id=\"2...9:#:}~]2L@c;uQj^\" x=\"930\" y=\"-90\"><field name=\"BUTTON\">ButtonEDown</field><field name=\"EVENTTYPE\">pressed</field><next><block type=\"iq_control_if_then\" id=\"4Pr!ZK]RsLnH{FIQm%]N\"><value name=\"CONDITION\"><block type=\"iq_sensing_pressing_bumper\" id=\"F-9@cr8suXHG-Ja:EQ%6\"><field name=\"BUMPER\">CatapultBumper</field></block></value><statement name=\"SUBSTACK\"><block type=\"procedures_call\" id=\".7PadR*6G%*Rmk0=UzeR\"><mutation proccode=\"ShootCatapult\" proceduredefid=\"z(:B)VHO6Gk*dGF5$cr(\" argumentids=\"[]\" warp=\"false\"></mutation></block></statement><next><block type=\"iq_control_if_then\" id=\"j/@=u656hVM5%r~9l:e*\"><value name=\"CONDITION\"><block type=\"iq_operator_not\" id=\"P}^)^~e!_sfRKm;=|D?H\"><value name=\"OPERAND\"><block type=\"iq_sensing_pressing_bumper\" id=\"^G6Mb=Y4.C6Wb`377tT-\"><field name=\"BUMPER\">CatapultBumper</field></block></value></block></value><statement name=\"SUBSTACK\"><block type=\"procedures_call\" id=\"0XG$YVueyaEMV#+qowB%\"><mutation proccode=\"ReturnCatapult\" proceduredefid=\"QHZJ)~M/=u$IUGANVuc{\" argumentids=\"[]\" warp=\"false\"></mutation></block></statement></block></next></block></next></block><block type=\"iq_events_when_controller_button\" id=\"JwzqiHZlgD50q(1w:=J(\" x=\"510\" y=\"50\"><field name=\"BUTTON\">ButtonFUp</field><field name=\"EVENTTYPE\">pressed</field><next><block type=\"iq_motion_spin\" id=\"DU~;2%4(X:lf{u28tLJ@\"><field name=\"MOTOR\">CatapultMotor</field><field name=\"DIRECTION\">fwd</field></block></next></block><block type=\"iq_events_when_controller_button\" id=\")1`OeXNL0Vv~=5H$CU=W\" x=\"510\" y=\"191\"><field name=\"BUTTON\">ButtonFDown</field><field name=\"EVENTTYPE\">pressed</field><next><block type=\"iq_motion_spin\" id=\"~9FWrKyv{OO?l[.e%8G9\"><field name=\"MOTOR\">CatapultMotor</field><field name=\"DIRECTION\">rev</field></block></next></block><block type=\"iq_events_when_controller_button\" id=\"C%Fx7/v*#Lg%Pe6__{)F\" x=\"510\" y=\"350\"><field name=\"BUTTON\">ButtonFDown</field><field name=\"EVENTTYPE\">released</field><next><block type=\"iq_motion_stop_motor\" id=\"6U14[l;G]Dv(E~v/AT=O\"><field name=\"MOTOR\">CatapultMotor</field></block></next></block><block type=\"procedures_definition\" id=\"Bhms{~mD*OQP:p*:m{U9\" x=\"50\" y=\"610\"><statement name=\"custom_block\"><shadow type=\"procedures_prototype\" id=\"XdZt:.@LfwVjxYP4s3mj\"><mutation proccode=\"SetUp\" proceduredefid=\"XdZt:.@LfwVjxYP4s3mj\" argumentids=\"[]\" argumentnames=\"[]\" argumentdefaults=\"[]\" argumenttypes=\"[]\" warp=\"false\"></mutation></shadow></statement><next><block type=\"iq_looks_clear_all_rows\" id=\"?%iZ{T8;myxW^|]5^hMO\"><next><block type=\"iq_looks_set_cursor\" id=\"E0g2#)wdt=,Z0sNzT,g3\"><value name=\"ROW\"><shadow type=\"math_whole_number\" id=\"/1bu4@59PZ||`)%{d6mA\"><field name=\"NUM\">1</field></shadow></value><value name=\"COLUMN\"><shadow type=\"math_whole_number\" id=\"gc-~}kiznPhIu~|}{AKn\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"iq_looks_set_cursor\" id=\"J,?w);OFlTyF`?:`gX/B\"><value name=\"ROW\"><shadow type=\"math_whole_number\" id=\"},ZF:7bG_,|^]=-L1=KU\"><field name=\"NUM\">2</field></shadow></value><value name=\"COLUMN\"><shadow type=\"math_whole_number\" id=\"v4jCrL,m4JXg%7=*XR!)\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"iq_looks_print\" id=\"0EmhOj;2F67?PBI6})pj\"><value name=\"DATA\"><shadow type=\"text\" id=\"@hU}*.jhO4fvb2[_^H|Q\"><field name=\"TEXT\">Hello</field></shadow><block type=\"iq_sensing_position_of_motor\" id=\"k2={PuBNxhbpC9frl#Yn\"><field name=\"MOTOR\">CatapultMotor</field><field name=\"UNITS\">deg</field></block></value><next><block type=\"iq_looks_set_cursor\" id=\".NWStj44NahCT^$!ZJoG\"><value name=\"ROW\"><shadow type=\"math_whole_number\" id=\"^Y9vs-L7+*^un91C+gwZ\"><field name=\"NUM\">3</field></shadow></value><value name=\"COLUMN\"><shadow type=\"math_whole_number\" id=\"S}yM]{HO7#KVu|$*_vR=\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"iq_looks_print\" id=\":=*2#S?byx%q+(*Yq!%E\"><value name=\"DATA\"><shadow type=\"text\" id=\"T_P{o(;yX2tWz,X:Ht40\"><field name=\"TEXT\">Hello</field></shadow><block type=\"iq_operator_divide\" id=\"(.g0TzJSyCuk_dC70:9~\"><value name=\"NUM1\"><shadow type=\"math_number\" id=\"g*DB_o=;fOXF48hd`|TS\"><field name=\"NUM\"></field></shadow><block type=\"iq_sensing_position_of_motor\" id=\"#9aKJtG~!dre`W/9PcNa\"><field name=\"MOTOR\">CatapultMotor</field><field name=\"UNITS\">deg</field></block></value><value name=\"NUM2\"><shadow type=\"math_number\" id=\",o`7?!ME?UYTe*}jh`1R\"><field name=\"NUM\">5400</field></shadow></value></block></value><next><block type=\"iq_looks_set_cursor\" id=\"^JFBq[uY|`!fT{I#3,jb\"><value name=\"ROW\"><shadow type=\"math_whole_number\" id=\"uh/8,kE];dw+1%[1v3%j\"><field name=\"NUM\">4</field></shadow></value><value name=\"COLUMN\"><shadow type=\"math_whole_number\" id=\"/grL=|Cv+|x{WIyyH!?e\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"iq_control_while\" id=\":8CU[RbO$;M|hy:gUi.[\"><value name=\"CONDITION\"><block type=\"iq_sensing_pressing_bumper\" id=\"@CqR38Oftxtm_oo/C~+;\"><field name=\"BUMPER\">CatapultBumper</field></block></value><statement name=\"SUBSTACK\"><block type=\"iq_looks_print\" id=\"w+J;L+x?t^L)x#98AKTw\"><value name=\"DATA\"><shadow type=\"text\" id=\"~V]%5+|)!`Mx_,RxP#)!\"><field name=\"TEXT\">Bumper Pressed!</field></shadow></value><next><block type=\"iq_control_break\" id=\"ExK4uxj[)Y[UyO`_}S2u\"></block></next></block></statement></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block><block type=\"procedures_definition\" id=\"x-jTHRrdt,,,wo57r:HX\" x=\"590\" y=\"590\"><statement name=\"custom_block\"><shadow type=\"procedures_prototype\" id=\"z(:B)VHO6Gk*dGF5$cr(\"><mutation proccode=\"ShootCatapult\" proceduredefid=\"z(:B)VHO6Gk*dGF5$cr(\" argumentids=\"[]\" argumentnames=\"[]\" argumentdefaults=\"[]\" argumenttypes=\"[]\" warp=\"false\"></mutation></shadow></statement><next><block type=\"iq_motion_spin_for\" id=\"Q)x+*tQm0=puGVR$g%4+\"><field name=\"MOTOR\">CatapultMotor</field><field name=\"DIRECTION\">fwd</field><field name=\"UNITS\">deg</field><field name=\"anddontwait_mutator\">TRUE</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"n0.^.lTP}#KLP+?TrU(M\"><field name=\"NUM\">8000</field></shadow></value><next><block type=\"iq_control_wait_until\" id=\"{*rWC$gu+y,lVhyU/,h.\"><value name=\"CONDITION\"><block type=\"iq_operator_not\" id=\"tr:n^OmTAR=et_y?r#|s\"><value name=\"OPERAND\"><block type=\"iq_sensing_pressing_bumper\" id=\"TPHhT]YzsfF6]qu2[m3}\"><field name=\"BUMPER\">CatapultBumper</field></block></value></block></value><next><block type=\"iq_control_wait\" id=\"B-?/vjqV96MJ$eiD@Oi^\"><value name=\"DURATION\"><shadow type=\"math_positive_number\" id=\"HsA6zXU;p`f=[!EaH2eW\"><field name=\"NUM\">0.25</field></shadow></value><next><block type=\"iq_control_wait_until\" id=\"%-lope`,a@hSNl,[}Iy?\"><value name=\"CONDITION\"><block type=\"iq_sensing_pressing_bumper\" id=\"18dj]-k@SIDavRn-,Z~f\"><field name=\"BUMPER\">CatapultBumper</field></block></value><next><block type=\"iq_motion_stop_motor\" id=\"e(N`fwxu8csa)Z%S/U=1\"><field name=\"MOTOR\">CatapultMotor</field></block></next></block></next></block></next></block></next></block></next></block><block type=\"procedures_definition\" id=\"=mvE9jzNb_BwsvXB;/_}\" x=\"590\" y=\"970\"><statement name=\"custom_block\"><shadow type=\"procedures_prototype\" id=\"QHZJ)~M/=u$IUGANVuc{\"><mutation proccode=\"ReturnCatapult\" proceduredefid=\"QHZJ)~M/=u$IUGANVuc{\" argumentids=\"[]\" argumentnames=\"[]\" argumentdefaults=\"[]\" argumenttypes=\"[]\" warp=\"false\"></mutation></shadow></statement><next><block type=\"iq_motion_spin_for\" id=\"T#~_x=#8LGi`FC*yAq%K\"><field name=\"MOTOR\">CatapultMotor</field><field name=\"DIRECTION\">fwd</field><field name=\"UNITS\">deg</field><field name=\"anddontwait_mutator\">TRUE</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"bxvo{tH9/F_uQC:$S^l.\"><field name=\"NUM\">5400</field></shadow></value><next><block type=\"iq_control_wait_until\" id=\"hNq},^(BxA)#cf`d~WLX\"><value name=\"CONDITION\"><block type=\"iq_sensing_pressing_bumper\" id=\"+3Q}URz3j7[nBg`*J;6u\"><field name=\"BUMPER\">CatapultBumper</field></block></value><next><block type=\"iq_motion_stop_motor\" id=\"/5~4ZO`P?YR,z(K]GSv;\"><field name=\"MOTOR\">CatapultMotor</field></block></next></block></next></block></next></block></xml>","rconfig":[{"port":[1,3,0],"name":"Drivetrain","customName":false,"deviceType":"Drivetrain","setting":{"type":"2-motor","wheelSize":"200mm","gearRatio":"1:1","direction":"rev","gyroType":"none","width":"10.25","unit":"in","wheelbase":"3","wheelbaseUnit":"in"},"triportSourcePort":22},{"port":[2],"name":"IntakeMotor","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse"},"triportSourcePort":22},{"port":[4],"name":"CatapultMotor","customName":true,"deviceType":"Motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse"},"triportSourcePort":22},{"port":[5],"name":"CatapultBumper","customName":true,"deviceType":"Bumper","setting":{},"triportSourcePort":22},{"port":[],"name":"Controller","customName":false,"deviceType":"Controller","setting":{"left":"IntakeMotor","leftDir":"false","right":"","rightDir":"false","e":"","eDir":"false","f":"","fDir":"false","drive":"arcader"},"triportSourcePort":22}],"slot":0,"platform":"IQ","sdkVersion":"","appVersion":"","fileFormat":"1.0.0","icon":"","cppStatus":"true","cpp":"// Make sure all required headers are included.\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <math.h>\n#include <string.h>\n\n\n#include \"iq_cpp.h\"\n\nusing namespace vex;\n\n// Brain should be defined by default\nbrain Brain;\n\n\n// START IQ MACROS\n#define waitUntil(condition)                                                   \\\n  do {                                                                         \\\n    wait(5, msec);                                                             \\\n  } while (!(condition))\n\n#define repeat(iterations)                                                     \\\n  for (int iterator = 0; iterator < iterations; iterator++)\n// END IQ MACROS\n\n\n// Robot configuration code.\nmotor LeftDriveSmart = motor(PORT1, 1, true);\nmotor RightDriveSmart = motor(PORT3, 1, false);\ndrivetrain Drivetrain = drivetrain(LeftDriveSmart, RightDriveSmart,200, 260.34999999999997, 76.19999999999999, mm, 1);\nmotor IntakeMotor = motor(PORT2, true);\nmotor CatapultMotor = motor(PORT4, true);\nbumper CatapultBumper = bumper(PORT5);\ncontroller Controller = controller();\n\n\n\n//Vision sensor index vars.\nint Vision1_objectIndex = 0;\n\n\n\n// Generated code.\n\n\n\n\n// define variable for remote controller enable/disable\nbool RemoteControlCodeEnabled = true;\n// define variables used for controlling motors based on controller inputs\nbool ControllerLeftShoulderControlMotorsStopped = true;\nbool DrivetrainNeedsToBeStopped_Controller = true;\n\n// define a task that will handle monitoring inputs from Controller\nint rc_auto_loop_function_Controller() {\n  // process the controller input every 20 milliseconds\n  // update the motors based on the input values\n  while(true) {\n    if(RemoteControlCodeEnabled) {\n      // calculate the drivetrain motor velocities from the controller joystick axies\n      // left = AxisD + AxisC\n      // right = AxisD - AxisC\n      int drivetrainLeftSideSpeed = Controller.AxisD.position() + Controller.AxisC.position();\n      int drivetrainRightSideSpeed = Controller.AxisD.position() - Controller.AxisC.position();\n      \n      // check if the values are inside of the deadband range\n      if (abs(drivetrainLeftSideSpeed) < 5 && abs(drivetrainRightSideSpeed) < 5) {\n        // check if the motors have already been stopped\n        if (DrivetrainNeedsToBeStopped_Controller) {\n          // stop the drive motors\n          LeftDriveSmart.stop();\n          RightDriveSmart.stop();\n          // tell the code that the motors have been stopped\n          DrivetrainNeedsToBeStopped_Controller = false;\n        }\n      } else {\n        // reset the toggle so that the deadband code knows to stop the motors next time the input is in the deadband range\n        DrivetrainNeedsToBeStopped_Controller = true;\n      }\n      \n      // only tell the left drive motor to spin if the values are not in the deadband range\n      if (DrivetrainNeedsToBeStopped_Controller) {\n        LeftDriveSmart.setVelocity(drivetrainLeftSideSpeed, percent);\n        LeftDriveSmart.spin(forward);\n      }\n      // only tell the right drive motor to spin if the values are not in the deadband range\n      if (DrivetrainNeedsToBeStopped_Controller) {\n        RightDriveSmart.setVelocity(drivetrainRightSideSpeed, percent);\n        RightDriveSmart.spin(forward);\n      }\n      // check the ButtonLUp/ButtonLDown status to control IntakeMotor\n      if (Controller.ButtonLUp.pressing()) {\n        IntakeMotor.spin(forward);\n        ControllerLeftShoulderControlMotorsStopped = false;\n      } else if (Controller.ButtonLDown.pressing()) {\n        IntakeMotor.spin(reverse);\n        ControllerLeftShoulderControlMotorsStopped = false;\n      } else if (!ControllerLeftShoulderControlMotorsStopped) {\n        IntakeMotor.stop();\n        // set the toggle so that we don't constantly tell the motor to stop when the buttons are released\n        ControllerLeftShoulderControlMotorsStopped = true;\n      }\n    }\n    // wait before repeating the process\n    wait(20, msec);\n  }\n  return 0;\n}\n\n\n// Include the IQ Library\n#include \"iq_cpp.h\"\n  \n// Allows for easier use of the VEX Library\nusing namespace vex;\n\n// User defined function\nvoid myblockfunction_SetUp();\n// User defined function\nvoid myblockfunction_ShootCatapult();\n// User defined function\nvoid myblockfunction_ReturnCatapult();\n\nint Brain_precision = 0;\n\nfloat myVariable;\n\n// Used to find the format string for printing numbers with the\n// desired number of decimal places\nconst char* printToBrain_numberFormat() {\n  // look at the current precision setting to find the format string\n  switch(Brain_precision){\n    case 0:  return \"%.0f\"; // 0 decimal places (1)\n    case 1:  return \"%.1f\"; // 1 decimal place  (0.1)\n    case 2:  return \"%.2f\"; // 2 decimal places (0.01)\n    case 3:  return \"%.3f\"; // 3 decimal places (0.001)\n    default: return \"%f\"; // use the print system default for everthing else\n  }\n}\n\n// User defined function\nvoid myblockfunction_SetUp() {\n  Brain.Screen.clearScreen();\n  Brain.Screen.setCursor(1, 1);\n  Brain.Screen.setCursor(2, 1);\n  Brain.Screen.print(printToBrain_numberFormat(), static_cast<float>(CatapultMotor.position(degrees)));\n  Brain.Screen.setCursor(3, 1);\n  Brain.Screen.print(printToBrain_numberFormat(), static_cast<float>(CatapultMotor.position(degrees) / 5400.0));\n  Brain.Screen.setCursor(4, 1);\n  while (CatapultBumper.pressing()) {\n    Brain.Screen.print(\"Bumper Pressed!\");\n    break;\n  wait(20, msec);\n  }\n}\n\n// User defined function\nvoid myblockfunction_ShootCatapult() {\n  CatapultMotor.spinFor(forward, 8000.0, degrees, false);\n  waitUntil((!CatapultBumper.pressing()));\n  wait(0.25, seconds);\n  waitUntil(CatapultBumper.pressing());\n  CatapultMotor.stop();\n}\n\n// User defined function\nvoid myblockfunction_ReturnCatapult() {\n  CatapultMotor.spinFor(forward, 5400.0, degrees, false);\n  waitUntil(CatapultBumper.pressing());\n  CatapultMotor.stop();\n}\n\n// \"when started\" hat block\nint whenStarted1() {\n  IntakeMotor.setVelocity(100.0, percent);\n  CatapultMotor.setVelocity(100.0, percent);\n  Drivetrain.setDriveVelocity(100.0, percent);\n  while (true) {\n    myblockfunction_SetUp();\n  wait(20, msec);\n  }\n  return 0;\n}\n\n// \"when Controller ButtonFUp released\" hat block\nvoid onevent_ControllerButtonFUp_released_0() {\n  CatapultMotor.stop();\n}\n\n// \"when Controller ButtonEDown pressed\" hat block\nvoid onevent_ControllerButtonEDown_pressed_0() {\n  if (CatapultBumper.pressing()) {\n    myblockfunction_ShootCatapult();\n  }\n  if (!CatapultBumper.pressing()) {\n    myblockfunction_ReturnCatapult();\n  }\n}\n\n// \"when Controller ButtonFUp pressed\" hat block\nvoid onevent_ControllerButtonFUp_pressed_0() {\n  CatapultMotor.spin(forward);\n}\n\n// \"when Controller ButtonFDown pressed\" hat block\nvoid onevent_ControllerButtonFDown_pressed_0() {\n  CatapultMotor.spin(reverse);\n}\n\n// \"when Controller ButtonFDown released\" hat block\nvoid onevent_ControllerButtonFDown_released_0() {\n  CatapultMotor.stop();\n}\n\n\nint main() {\n  task rc_auto_loop_task_Controller(rc_auto_loop_function_Controller);\n\n  // register event handlers\n  Controller.ButtonFUp.released(onevent_ControllerButtonFUp_released_0);\n  Controller.ButtonEDown.pressed(onevent_ControllerButtonEDown_pressed_0);\n  Controller.ButtonFUp.pressed(onevent_ControllerButtonFUp_pressed_0);\n  Controller.ButtonFDown.pressed(onevent_ControllerButtonFDown_pressed_0);\n  Controller.ButtonFDown.released(onevent_ControllerButtonFDown_released_0);\n\n  wait(15, msec);\n  whenStarted1();\n}"}