2021-03-29 17:05:06 +01:00
|
|
|
#include "pico_wireless.hpp"
|
2021-05-13 12:06:01 +01:00
|
|
|
#include "drivers/esp32spi/spi_drv.hpp"
|
2021-03-29 17:05:06 +01:00
|
|
|
|
|
|
|
namespace pimoroni {
|
|
|
|
|
|
|
|
bool PicoWireless::init() {
|
|
|
|
bool success = parent::init();
|
|
|
|
|
|
|
|
// setup button input
|
|
|
|
gpio_init(A);
|
|
|
|
gpio_set_dir(A, GPIO_IN);
|
|
|
|
gpio_pull_up(A);
|
|
|
|
|
|
|
|
set_led(0, 0, 0);
|
|
|
|
|
2021-04-19 16:44:11 +01:00
|
|
|
pin_mode(ESP_SD_DETECT, Esp32Spi::INPUT_PULLUP);
|
|
|
|
|
2021-03-29 17:05:06 +01:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PicoWireless::set_led(uint8_t r, uint8_t g, uint8_t b) {
|
|
|
|
analog_write(ESP_LED_R, 255 - r);
|
|
|
|
analog_write(ESP_LED_G, 255 - g);
|
|
|
|
analog_write(ESP_LED_B, 255 - b);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PicoWireless::is_pressed(uint8_t button) {
|
|
|
|
return !gpio_get(button);
|
|
|
|
}
|
|
|
|
|
2021-04-19 16:44:11 +01:00
|
|
|
bool PicoWireless::is_sdcard_detected() {
|
|
|
|
return digital_read(ESP_SD_DETECT);
|
|
|
|
}
|
|
|
|
|
2021-03-29 17:05:06 +01:00
|
|
|
}
|