У меня есть массив 3x3 WS2811, который я пытаюсь запрограммировать для активации при нажатии кнопки.Тем не менее, я не могу заставить его ответить на 0'd Out.Кто-нибудь имеет опыт работы с этим оборудованием и может дать несколько советов о том, как заставить эти вещи работать лучше?Я также могу предоставить код для light_matrix.wr_pix (), если это необходимо.Вот мой код:
/**********************************************************************
file: main_ws2812_basic.cpp - basic ws2812 test
Copyright (C) 2018 p. chu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**********************************************************************/
/*****************************************************************//**
* @note neo8 is an 8-led strip
* @note ws2812 is very bright (25% power is enough)
* @note ws2812 specifies 5-V control signal
********************************************************************/
#include "de10_baseline.h"
#include "ws2812_core.h"
Ws2812Core light_matrix(get_slot_addr(BRIDGE_BASE,14),3,3);
int main() {
// rgb values of a rain bow (red, orange, yellow, ..., purple)
const int rainbow[] = { 0xff0000, 0xc04000, 0x808000, 0x00ff00,
0x008080, 0x0000ff, 0x4000c0, 0x800080 };
// for (int i = 0; i < 4; i++){
// }
int i = 0;
int j = 0;
for(i = 0; i<3; i++){
for(j=0; j<3; j++){
light_matrix.wr_pix(i,j,0x000000);
}
}
while (1) {
light_matrix.wr_pix(0,0,0x000000); //green
light_matrix.wr_pix(0,1,0x000000); //green
light_matrix.wr_pix(0,2,0x000000); //green
light_matrix.wr_pix(1,0,0x000000); //blue
light_matrix.wr_pix(1,1,0x000000); //blue
light_matrix.wr_pix(1,2,0x000000); //blue
light_matrix.wr_pix(2,0,0x000000); //green
light_matrix.wr_pix(2,1,0x000000); //green
light_matrix.wr_pix(2,2,0x000000); //green
// 8 shades of blue
// neopixel.set_brightness(0.5);
// //int blue = 0x000007;
//
// for (int i = 0; i < 8; i++) {
// blue = blue + 31;
// neopixel.wr_pix(i, 0, blue);
// }
//
// sleep_ms(3000);
// // brightness control (increasing exponentially to 25%)
// // 100^(1/1000)= 1.0233; i.e., 1.0233^1000 = 100
// double b = 0.0025;
// for (int n = 0; n < 1000; n++) {
// b = b * 1.0046;
// neopixel.set_brightness(b);
// // set rainbow color
// for (int i = 0; i < 8; i++) {
// neopixel.wr_pix(i, 0, rainbow[0]);
// }
// sleep_ms(5);
// }
// sleep_ms(3000);
// // animation
// for (int n = 0; n < 160; n++) {
// for (int i = 0; i < 8; i++) {
// int k = (i + n) % 8;
// neopixel.wr_pix(i, 0, rainbow[0]);
// sleep_ms(10);
// }
// }
// sleep_ms(2000);
}//while
}//main