Skip to content

Commit

Permalink
trying to fix limt switch lcd
Browse files Browse the repository at this point in the history
  • Loading branch information
HakopZ committed Jan 7, 2022
1 parent 21da733 commit 2b7b192
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions include/EZ-Template/pre_auto_selector.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once
#include "main.h"

#include <memory.h>
namespace ez
{
extern pros::ADIDigitalIn* left_limit_switch;
extern pros::ADIDigitalIn* right_limit_switch;
extern pros::ADIDigitalIn left_limit_switch;
extern pros::ADIDigitalIn right_limit_switch;
/**
* Initialize two limitswithces to change pages on the lcd
*
Expand Down
19 changes: 11 additions & 8 deletions src/EZ-Template/pre_auto_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@

namespace ez
{
pros::ADIDigitalIn* left_limit_switch = nullptr;
pros::ADIDigitalIn* right_limit_switch = nullptr;
bool limitSwitchesExist = false;
pros::ADIDigitalIn left_limit_switch(-1);
pros::ADIDigitalIn right_limit_switch(-1);
void limit_switch_lcd_initialize(int left_limit_port, int right_limit_port)
{
if(left_limit_port == -1 || right_limit_port == -1)
{
limit_switch_task.suspend();
return;
}
left_limit_switch = new pros::ADIDigitalIn(left_limit_port);
right_limit_switch = new pros::ADIDigitalIn(right_limit_port);
limitSwitchesExist = true;
left_limit_switch = pros::ADIDigitalIn(left_limit_port);
right_limit_switch = pros::ADIDigitalIn(right_limit_port);
limit_switch_task.resume();
}

void limitSwitchTask()
{
while(true)
{
if(left_limit_switch || right_limit_switch)
if(limitSwitchesExist)
{
if(left_limit_switch->get_new_press())
if(left_limit_switch.get_new_press())
{
ez::as::page_down();
}
else if(right_limit_switch->get_new_press())
else if(right_limit_switch.get_new_press())
{
ez::as::page_up();
}
}

pros::delay(20);
}
}
}
pros::Task limit_switch_task(limitSwitchTask, nullptr);
}

1 comment on commit 2b7b192

@ssejrog
Copy link
Member

@ssejrog ssejrog commented on 2b7b192 Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#34

Please sign in to comment.