-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
#include "main.h" | ||
|
||
namespace ez | ||
{ | ||
extern pros::ADIDigitalIn* left_limit_switch; | ||
extern pros::ADIDigitalIn* right_limit_switch; | ||
/** | ||
* Initialize two limitswithces to change pages on the lcd | ||
* | ||
* @param left_limit_port | ||
* port for the left limit switch | ||
* @param right_limit_port | ||
* port for the right limit switch | ||
*/ | ||
void limit_switch_lcd_initialize(int left_limit_port, int right_limit_port); | ||
|
||
/** | ||
* pre_auto_task | ||
*/ | ||
extern pros::Task limit_switch_task; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "pre_auto_selector.hpp" | ||
|
||
namespace ez | ||
{ | ||
pros::ADIDigitalIn* left_limit_switch = nullptr; | ||
pros::ADIDigitalIn* right_limit_switch = nullptr; | ||
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); | ||
limit_switch_task.resume(); | ||
} | ||
|
||
void limitSwitchTask() | ||
{ | ||
while(true) | ||
{ | ||
if(left_limit_switch || right_limit_switch) | ||
{ | ||
if(left_limit_switch->get_new_press()) | ||
{ | ||
ez::as::page_down(); | ||
} | ||
else if(right_limit_switch->get_new_press()) | ||
{ | ||
ez::as::page_up(); | ||
} | ||
} | ||
pros::delay(20); | ||
} | ||
} | ||
pros::Task limit_switch_task(limitSwitchTask, nullptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21da733
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#34