Pico Explorer: Use Motor.

This commit is contained in:
Phil Howard 2022-05-30 11:51:38 +01:00
parent 7068217ccb
commit 751916e7b9
2 changed files with 8 additions and 10 deletions

View File

@ -81,6 +81,8 @@ void sprite(uint8_t *p, int x, int y, bool flip, uint16_t c) {
int main() {
msa301.init();
motor1.init();
motor2.init();
struct pt {
float x;
@ -143,9 +145,8 @@ int main() {
display.set_pen(display.create_pen(0, 0, bv * 255));
display.circle(Point(bv * 140 + 50, 210), 15);
// TODO Find the correct way to translate these in terms of motor
// display.set_motor(display.MOTOR1, display.FORWARD, bv);
// display.set_motor(display.MOTOR2, display.FORWARD, rv);
motor1.speed(bv);
motor2.speed(rv);
// TODO make this work
// display.set_tone(440, 0.5);

View File

@ -108,7 +108,6 @@ Button button_x(PicoExplorer::X);
Button button_y(PicoExplorer::Y);
Motor motor1(PicoExplorer::MOTOR1_PINS);
Motor motor2(PicoExplorer::MOTOR2_PINS);
Encoder enc(pio0, 0, ENCODER_PINS, ENCODER_COMMON_PIN, NORMAL_DIR, COUNTS_PER_REV, COUNT_MICROSTEPS, FREQ_DIVIDER);
@ -232,6 +231,7 @@ void setup() {
gpio_pull_down(ENCODER_SWITCH_PIN);
}
motor1.init();
enc.init();
bool_pair state = enc.state();
@ -287,16 +287,13 @@ int main() {
// Spin Motor 1 either clockwise or counterclockwise depending on if B or Y are pressed
if(button_b.read() && !button_y.read()) {
// TODO Fix motors
//display.set_motor(PicoExplorer::MOTOR1, PicoExplorer::FORWARD, 1.0f);
motor1.speed(1.0f); // Full forward
}
else if(button_y.read() && !button_b.read()) {
// TODO Fix motors
//display.set_motor(PicoExplorer::MOTOR1, PicoExplorer::REVERSE, 0.2f);
motor1.speed(-0.2f); // Reverse
}
else {
// TODO Fix motors
//display.set_motor(PicoExplorer::MOTOR1, PicoExplorer::STOP);
motor1.speed(0.0f); // Stop
}
// If A has been pressed, zoom the view out to a min of x1