Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GUI {
- public:
- GUI(std::vector<pros::Motor>) motor_list(motor_list) {}
- std::vector<pros::Motor> motor_list;
- int current_view = 0;
- int selected_auto = 0;
- bool elim_awp = 0;
- void read_file (std::string& filename) {
- std::string str;
- std::ifstream file(filename);
- file >> str;
- file.close();
- selected_auto = std::stoi(str);
- }
- void write_file (std::string& filename) {
- std::ofstream file(filename);
- file << selected_auto;
- file.close();
- }
- private:
- int E_IMAGE_WIDTH = 480;
- void render () {
- void print_motor_temprature_screen() {
- pros::screen::set_pen(pros::Color::white_smoke);
- pros::screen::draw_line(360, 0, 360, 240);
- pros::screen::draw_line(360, 120, 480, 120);
- pros::screen::draw_circle(420, 60, 46);
- pros::screen::draw_circle(420, 180, 46);
- pros::screen::draw_circle(300, 60, 46);
- pros::screen::draw_circle(180, 60, 46);
- pros::screen::draw_circle(60, 60, 46);
- pros::screen::draw_circle(60, 180, 46);
- pros::screen::draw_circle(180, 180, 46);
- pros::screen::draw_circle(300, 180, 46);
- pros::screen::set_pen(get_temp(motor_list[6]));
- pros::screen::fill_circle(420, 60, 45);
- pros::screen::set_pen(get_temp(motor_list[7]));
- pros::screen::fill_circle(420, 180, 45);
- pros::screen::set_pen(get_temp(motor_list[2]));
- pros::screen::fill_circle(300, 60, 45);
- pros::screen::set_pen(get_temp(motor_list[5]));
- pros::screen::fill_circle(300, 180, 45);
- pros::screen::set_pen(get_temp(motor_list[1]));
- pros::screen::fill_circle(180, 60, 45);
- pros::screen::set_pen(get_temp(motor_list[4]));
- pros::screen::fill_circle(180, 180, 45);
- pros::screen::set_pen(get_temp(motor_list[0]));
- pros::screen::fill_circle(60, 60, 45);
- pros::screen::set_pen(get_temp(motor_list[3]));
- pros::screen::fill_circle(60, 180, 45);
- pros::screen::set_eraser(pros::Color::black);
- pros::screen::set_pen(pros::Color::white_smoke);
- pros::screen::print(pros::E_TEXT_SMALL, 17, 55, "L M 1 (%i)", motor_list[0].get_port());
- pros::screen::print(pros::E_TEXT_SMALL, 137, 55, "L M 2 (%i)", motor_list[1].get_port());
- pros::screen::print(pros::E_TEXT_SMALL, 257, 55, "L M 3 (%i)", motor_list[2].get_port());
- pros::screen::print(pros::E_TEXT_SMALL, 17, 175, "R M 1 (%i)", motor_list[3].get_port());
- pros::screen::print(pros::E_TEXT_SMALL, 137, 175, "R M 2 (%i)", motor_list[4].get_port());
- pros::screen::print(pros::E_TEXT_SMALL, 257, 175, "R M 3 (%i)", motor_list[5].get_port());
- pros::screen::print(pros::E_TEXT_SMALL, 377, 55, "Lower(%i)", motor_list[6].get_port());
- pros::screen::print(pros::E_TEXT_SMALL, 377, 175, "Upper(%i)", motor_list[7].get_port());
- }
- }
- void press() {
- // a function that looks to see if the screen is being used as a touch screen based on different conditions
- pros::screen_touch_status_s_t status = pros::screen::touch_status();
- int x = status.x + 240;
- int y = status.y + 120;
- if (current_view == 0) {
- if(status.touch_status == pros::E_TOUCH_PRESSED){
- if ((x > (E_IMAGE_WIDTH / 2)) || (x < -(E_IMAGE_WIDTH / 2))) {
- current_view = 1;
- } else {
- if (x < 0 && y > 0) {
- if (selected_auto =! 0) {
- selected_auto = 0;
- elim_awp = 0;
- } else {
- elim_awp = !elim_awp;
- }
- }
- if (x < 0 && y < 0) {
- if (selected_auto =! 1) {
- selected_auto = 1;
- elim_awp = 0;
- } else {
- elim_awp = !elim_awp;
- }
- }
- if (x > 0 && y > 0) {
- if (selected_auto =! 2) {
- selected_auto = 2;
- elim_awp = 0;
- } else {
- elim_awp = !elim_awp;
- }
- }
- if (x > 0 && y < 0) {
- if (selected_auto =! 3) {
- selected_auto = 3;
- elim_awp = 0;
- } else {
- elim_awp = !elim_awp;
- }
- }
- }
- }
- } else {
- if (status.touch_status == pros::E_TOUCH_PRESSED) {
- current_view = 1;
- }
- }
- while (status == pros::E_TOUCH_PRESSED) {
- status = pros::screen::touch_status();
- pros::delay(100);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement