pygamer and pybadge boards were not resetting neopixels

This commit is contained in:
Dan Halbert 2020-01-24 09:32:28 -05:00
parent 68f9aee992
commit 6f13979c9b
9 changed files with 22 additions and 2 deletions

View File

@ -31,6 +31,7 @@
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "supervisor/shared/board.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;
@ -118,4 +119,5 @@ bool board_requests_safe_mode(void) {
}
void reset_board(void) {
board_reset_user_neopixels();
}

View File

@ -14,6 +14,8 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
#define USER_NEOPIXELS_PIN (&pin_PA15)
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)

View File

@ -31,6 +31,7 @@
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "supervisor/shared/board.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;
@ -96,4 +97,5 @@ bool board_requests_safe_mode(void) {
}
void reset_board(void) {
board_reset_user_neopixels();
}

View File

@ -14,6 +14,8 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
#define USER_NEOPIXELS_PIN (&pin_PA15)
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)

View File

@ -31,6 +31,7 @@
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "supervisor/shared/board.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;
@ -118,4 +119,5 @@ bool board_requests_safe_mode(void) {
}
void reset_board(void) {
board_reset_user_neopixels();
}

View File

@ -13,6 +13,8 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
#define USER_NEOPIXELS_PIN (&pin_PA15)
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)

View File

@ -31,6 +31,7 @@
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "supervisor/shared/board.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;
@ -96,4 +97,5 @@ bool board_requests_safe_mode(void) {
}
void reset_board(void) {
board_reset_user_neopixels();
}

View File

@ -13,6 +13,8 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
#define USER_NEOPIXELS_PIN (&pin_PA15)
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)

View File

@ -31,14 +31,18 @@
#ifdef USER_NEOPIXELS_PIN
// The maximum number of user neopixels right now is 10, on Circuit Playgrounds.
// PyBadge and PyGamer have max 5
#define USER_NEOPIXELS_MAX_COUNT 10
void board_reset_user_neopixels(void) {
// Turn off on-board NeoPixel string
uint8_t empty[30] = { 0 };
uint8_t empty[USER_NEOPIXELS_MAX_COUNT * 3] = { 0 };
digitalio_digitalinout_obj_t neopixel_pin;
common_hal_digitalio_digitalinout_construct(&neopixel_pin, USER_NEOPIXELS_PIN);
common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false,
DRIVE_MODE_PUSH_PULL);
common_hal_neopixel_write(&neopixel_pin, empty, 30);
common_hal_neopixel_write(&neopixel_pin, empty, USER_NEOPIXELS_MAX_COUNT * 3);
common_hal_digitalio_digitalinout_deinit(&neopixel_pin);
}