Pixy&Usb work with the new folder structure now.
This commit is contained in:
@@ -4,11 +4,14 @@
|
||||
#include "pixy.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
bool pixy_connected = false;
|
||||
|
||||
void app_init() {
|
||||
system_init();
|
||||
tft_init();
|
||||
|
||||
pixy_init();
|
||||
pixy_connected = (pixy_init()==0); //try to connect to pixy
|
||||
|
||||
//only testwise
|
||||
tft_clear(WHITE);
|
||||
@@ -21,18 +24,33 @@ void app_init() {
|
||||
|
||||
|
||||
|
||||
void pixy_led_test();
|
||||
void pixy_frame_test();
|
||||
int pixy_led_test();
|
||||
int pixy_frame_test();
|
||||
|
||||
//app event loop
|
||||
void app_process() {
|
||||
pixy_service(); //send/receive event data
|
||||
//Note: The only way to detect that pixy has been disconnected is if a command fails. There's no pixy_is_connected method yet :'(
|
||||
|
||||
//Code for tests see below
|
||||
pixy_led_test();
|
||||
pixy_frame_test();
|
||||
|
||||
//system_delay(500);
|
||||
if(!pixy_connected) { //Pixy not connected
|
||||
pixy_close(); //Ensure that all pixy resources are freed (failsafe)
|
||||
if(pixy_init()==0) { //try to connect to pixy
|
||||
pixy_connected=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(pixy_connected) {
|
||||
pixy_service(); //Send/receive event data from/to pixy failed
|
||||
|
||||
//Code for tests see below
|
||||
if(pixy_led_test()!=0) {
|
||||
pixy_connected=false;
|
||||
}
|
||||
|
||||
/*if(pixy_frame_test()!=0) {
|
||||
pixy_connected=false;
|
||||
}*/
|
||||
system_delay(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +60,7 @@ int colorind;
|
||||
const uint32_t colors [] = {0xFF0000, 0x00FF00,0x0000FF,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF,0x000000};
|
||||
const int num_colors = sizeof(colors)/sizeof(uint32_t);
|
||||
|
||||
void pixy_led_test() {
|
||||
int pixy_led_test() {
|
||||
if(colorind==0) {
|
||||
pixy_led_set_max_current(5);
|
||||
}
|
||||
@@ -51,6 +69,12 @@ void pixy_led_test() {
|
||||
int return_value;
|
||||
return_value = pixy_command("led_set", INT32(colors[colorind++]), END_OUT_ARGS, &response, END_IN_ARGS);
|
||||
colorind%=num_colors;
|
||||
|
||||
if(return_value!=0) {
|
||||
colorind=0; //reset color ind, to start at zero when plugging pixy in again
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -58,7 +82,7 @@ void pixy_led_test() {
|
||||
int renderBA81(uint8_t renderFlags, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame);
|
||||
|
||||
|
||||
void pixy_frame_test() {
|
||||
int pixy_frame_test() {
|
||||
|
||||
uint8_t* videodata;
|
||||
int32_t response;
|
||||
@@ -88,7 +112,8 @@ void pixy_frame_test() {
|
||||
|
||||
if(return_value==0) {
|
||||
return_value = renderBA81(renderflags,xwidth,ywidth,size,videodata);
|
||||
}
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user