void rcs_loadParams() { prm_add("S0 lower limit", PRM_FLAG_SIGNED, "@c Servo Sets the lower limit of travel for S0 (default -200)", INT16(-200), END); prm_add("S0 upper limit", PRM_FLAG_SIGNED, "@c Servo Sets the upper limit of travel for S0 (default 200)", INT16(200), END); prm_add("S1 lower limit", PRM_FLAG_SIGNED, "@c Servo Sets the lower limit of travel for S1 (default -200)", INT16(-200), END); prm_add("S1 upper limit", PRM_FLAG_SIGNED, "@c Servo Sets the upper limit of travel for S1 (default 200)", INT16(200), END); prm_add("Servo frequency", PRM_FLAG_ADVANCED, "@c Servo Sets the PWM frequency of the servos (default 100)", UINT16(100), END); int16_t lower, upper, freq; prm_get("S0 lower limit", &lower, END); prm_get("S0 upper limit", &upper, END); rcs_setLimits(0, lower, upper); prm_get("S1 lower limit", &lower, END); prm_get("S1 upper limit", &upper, END); rcs_setLimits(1, lower, upper); prm_get("Servo frequency", &freq, END); rcs_setFreq(freq); }
static void loadParams() { // exec's params added here prm_add("Default program", 0, "@c Expert Selects the program number that's run by default upon power-up. (default 0)", UINT8(0), END); prm_add("Debug", 0, "@c Expert Sets the debug level for the firmware. (default 0)", UINT8(0), END); prm_get("Debug", &g_debug, END); }
void cam_loadParams() { prm_add("Brightness", 0, "Sets the average brightness of the camera, can be between 0 and 255 (default 90)", UINT8(CAM_BRIGHTNESS_DEFAULT), END); uint8_t brightness; prm_get("Brightness", &brightness, END); cam_setBrightness(brightness); }
int32_t prm_setChirp(const char *id, const uint32_t &valLen, const uint8_t *val) { ParamRecord *rec; uint8_t *buf; uint32_t offset; void *sector; int32_t res = 0; rec = prm_find(id); if (rec==NULL) { // Good god this is an ugly hack. But, creating parameters should only be handled from within the firmware, so that the correct // description can be inserted. There may be other parameters like this, such that when these parameters are lost, we want to resave, // in which case, we should formalize this hack somehow. if (strncmp(id, "Signature label", 15)==0) { char desc[100]; sprintf(desc, "@c Signature_Labels Sets the label for objects that match signature%s.", id+15); prm_add(id, 0, desc, val[0], val+1, END); return 0; } return -1; } buf = (uint8_t *)malloc(FLASH_SECTOR_SIZE); if (buf==NULL) return -2; sector = (void *)FLASH_SECTOR_MASK((uint32_t)rec); memcpy(buf, sector, FLASH_SECTOR_SIZE); rec = prm_find(id, buf); if (rec==NULL) { res = -1; goto end; } offset = prm_getDataOffset(rec); if (memcmp((uint8_t *)rec+offset, val, valLen)==0) goto end; memcpy((uint8_t *)rec+offset, val, valLen); rec->len = valLen; rec->crc = prm_crc(rec); flash_erase((uint32_t)sector, FLASH_SECTOR_SIZE); flash_program((uint32_t)sector, buf, FLASH_SECTOR_SIZE); end: free(buf); return res; }
void chaseLoadParams() { prm_add("Translation P gain", 0, "@c Chase_demo tranlational proportional gain (default 500)", INT32(500), END); prm_add("Translation D gain", 0, "@c Chase_demo translational derivative gain (default 800)", INT32(800), END); prm_add("Rotation P gain", 0, "@c Chase_demo rotational proportional gain (default 500)", INT32(500), END); prm_add("Rotation D gain", 0, "@c Chase_demo rotational derivative gain (default 800)", INT32(800), END); int32_t pgain, dgain; prm_get("Translation P gain", &pgain, END); prm_get("Translation D gain", &dgain, END); g_transLoop.setGains(pgain, dgain); prm_get("Rotation P gain", &pgain, END); prm_get("Rotation D gain", &dgain, END); g_rotLoop.setGains(pgain, dgain); }
void ser_loadParams() { prm_add("Data out port", 0, "@c Interface Selects the port that's used to output data, 0=Arduino ICSP SPI, 1=SPI with SS, 2=I2C, 3=UART, 4=analog/digital x, 5=analog/digital y (default 0)", UINT8(0), END); prm_add("I2C address", PRM_FLAG_HEX_FORMAT, "@c Interface Sets the I2C address if you are using I2C data out port. (default 0x54)", UINT8(I2C_DEFAULT_SLAVE_ADDR), END); prm_add("UART baudrate", 0, "@c Interface Sets the UART baudrate if you are using UART data out port. (default 19200)", UINT32(19200), END); uint8_t interface, addr; uint32_t baudrate; prm_get("Data out port", &interface, END); ser_setInterface(interface); prm_get("I2C address", &addr, END); g_i2c0->setSlaveAddr(addr); prm_get("UART baudrate", &baudrate, END); g_uart0->setBaudrate(baudrate); }
void ptLoadParams() { prm_add("Pan P gain", PRM_FLAG_SIGNED, "@c Pan/tilt_Demo Pan axis proportional gain (default 350)", INT32(350), END); prm_add("Pan D gain", PRM_FLAG_SIGNED, "@c Pan/tilt_Demo Pan axis derivative gain (default 600)", INT32(600), END); prm_add("Tilt P gain", PRM_FLAG_SIGNED, "@c Pan/tilt_Demo Tilt axis proportional gain (default 500)", INT32(500), END); prm_add("Tilt D gain", PRM_FLAG_SIGNED, "@c Pan/tilt_Demo Tilt axis derivative gain (default 700)", INT32(700), END); int32_t pgain, dgain; prm_get("Pan P gain", &pgain, END); prm_get("Pan D gain", &dgain, END); g_panLoop.setGains(pgain, dgain); prm_get("Tilt P gain", &pgain, END); prm_get("Tilt D gain", &dgain, END); g_tiltLoop.setGains(pgain, dgain); }
static void loadParams() { #ifndef LEGO int i; char buf[256], buf2[64]; // create program menu strcpy(buf, "Selects the program number that's run upon power-up. @c Expert"); for (i=0; g_progTable[i]; i++) { sprintf(buf2, " @s %d=%s", i, g_progTable[i]->progName); strcat(buf, buf2); } // exec's params added here prm_add("Startup program", 0, buf, UINT8(0), END); #endif prm_add("Debug", 0, "@c Expert Sets the debug level for the firmware. (default 0)", UINT8(0), END); prm_get("Debug", &g_debug, END); }
int main(void) { // pixyInit(SRAM3_LOC, &LR0[0], sizeof(LR0)); #if 0 pixyInit(); cc_init(g_chirpUsb); ser_init(); exec_init(g_chirpUsb); #endif #if 1 /* test loop */ pixyInit(); exec_init(g_chirpUsb); #if 0 int i = 0; cam_setMode(1); while(1) { //uint8_t reg = cam_getRegister(0x0a); g_chirpUsb->service(); cprintf("hello world %d\n", i++); } #endif #if 0 while(1) { uint8_t *frame = (uint8_t *)SRAM1_LOC; int res; res = cam_getFrame(frame, SRAM1_SIZE, CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT); i++; if (i%50==0) { lpc_printf("%d\n", i); } } #endif #endif #if 1 exec_addProg(&g_progBlobs); ptLoadParams(); exec_addProg(&g_progPt); exec_addProg(&g_progVideo, true); exec_loop(); #endif #if 0 //prm_format(); ColorModel model, *model2; uint32_t len; model.m_hue[0].m_slope = 1.0; model.m_hue[0].m_yi = 2.0; model.m_hue[1].m_slope = 3.0; model.m_hue[1].m_yi = 4.0; model.m_sat[0].m_slope = 5.0; model.m_sat[0].m_yi = 6.0; model.m_sat[1].m_slope = 7.0; model.m_sat[1].m_yi = 8.0; prm_add("signature1", "Color signature 1", INTS8(sizeof(ColorModel), &model), END); prm_set("signature1", INTS8(sizeof(ColorModel), &model), END); model.m_hue[0].m_slope = 9.0; model.m_hue[0].m_yi = 10.0; model.m_hue[1].m_slope = 11.0; model.m_hue[1].m_yi = 12.0; model.m_sat[0].m_slope = 13.0; model.m_sat[0].m_yi = 14.0; model.m_sat[1].m_slope = 15.0; model.m_sat[1].m_yi = 16.0; prm_add("signature2", "Color signature 2", INTS8(sizeof(ColorModel), &model), END); prm_set("signature2", INTS8(sizeof(ColorModel), &model), END); prm_get("signature1", &len, &model2, END); model.m_hue[0].m_slope = 17.0; model.m_hue[0].m_yi = 18.0; model.m_hue[1].m_slope = 19.0; model.m_hue[1].m_yi = 20.0; model.m_sat[0].m_slope = 21.0; model.m_sat[0].m_yi = 22.0; model.m_sat[1].m_slope = 23.0; model.m_sat[1].m_yi = 24.0; prm_get("signature1", &len, &model2, END); prm_set("signature1", INTS8(sizeof(ColorModel), &model), END); prm_get("signature1", &len, &model2, END); prm_get("signature2", &len, &model2, END); #endif #if 0 #define DELAY 1000000 rcs_setFreq(100); rcs_setLimits(0, -200, 200); rcs_setLimits(1, -200, 200); while(1) { rcs_setPos(0, 0); delayus(DELAY); rcs_setPos(0, 500); delayus(DELAY); rcs_setPos(0, 1000); delayus(DELAY); rcs_setPos(1, 0); delayus(DELAY); rcs_setPos(1, 500); delayus(DELAY); rcs_setPos(1, 1000); delayus(DELAY); } #endif #if 0 while(1) { g_chirpUsb->service(); handleButton(); } #endif }
static void loadParams() { // exec's params added here prm_add("Default program", 0, "Selects the program number that's run by default upon power-up. (default 0)", UINT8(0), END); }
int main(void) { uint16_t major, minor, build; int i, res, count; // main init of hardware plus a version-dependent number for the parameters that will // force a format of parameter between version numbers. pixyInit(SRAM3_LOC, &LR0[0], sizeof(LR0)); cc_init(g_chirpUsb); ser_init(); exec_init(g_chirpUsb); // load programs exec_addProg(&g_progBlobs); ptLoadParams(); exec_addProg(&g_progPt); #if 0 chaseLoadParams(); exec_addProg(&g_progChase); #endif exec_addProg(&g_progVideo, true); // this code formats if the version has changed for (i=0, count=0; i<25; i++) { res = prm_get("fwver", &major, &minor, &build, END); if (res>=0 && major==FW_MAJOR_VER && minor==FW_MINOR_VER && build==FW_BUILD_VER) count++; } if (count==0) prm_format(); // check version prm_add("fwver", PRM_FLAG_INTERNAL, "", UINT16(FW_MAJOR_VER), UINT16(FW_MINOR_VER), UINT16(FW_BUILD_VER), END); ser_setInterface(SER_INTERFACE_UART); rcs_setLimits(1, -250, 250); // extends servo range to maximum//0x__BBRRGG //28 == full back, 12 == full angle down, 22 == parallel uint8_t WBV_sub = 0x16; uint32_t WBV = WBV_sub | WBV_sub << 8 | WBV_sub << 16; cam_setWBV(WBV); // sets the white balance manually cam_setAEC(0); // turns off auto exposure correction cam_setBrightness(35); // sets the brightness while(1) { //edgeDetect_highres_run(); edgeDetect_run(); // run the main edgeDetect function //exec_loop(); // Debug through pixymon } #if 0 #define DELAY 1000000 rcs_setFreq(100); rcs_setLimits(0, -200, 200); rcs_setLimits(1, -200, 200); while(1) { rcs_setPos(0, 0); delayus(DELAY); rcs_setPos(0, 500); delayus(DELAY); rcs_setPos(0, 1000); delayus(DELAY); rcs_setPos(1, 0); delayus(DELAY); rcs_setPos(1, 500); delayus(DELAY); rcs_setPos(1, 1000); delayus(DELAY); } #endif #if 0 while(1) { g_chirpUsb->service(); handleButton(); } #endif }
void cc_loadParams(void) { int i; ColorModel model; char id[32], desc[32]; // set up signatures, load later for (i=1; i<=NUM_MODELS; i++) { sprintf(id, "signature%d", i); sprintf(desc, "Color signature %d", i); // add if it doesn't exist yet prm_add(id, PRM_FLAG_INTERNAL, desc, INTS8(sizeof(ColorModel), &model), END); } // others ----- // setup prm_add("Max blocks", 0, "Sets the maximum total blocks sent per frame. (default 1000)", UINT16(1000), END); prm_add("Max blocks per signature", 0, "Sets the maximum blocks for each color signature sent for each frame. (default 1000)", UINT16(1000), END); prm_add("Min block area", 0, "Sets the minimum required area in pixels for a block. Blocks with less area won't be sent. (default 20)", UINT32(1), END); //TMS: default 20 prm_add("Min saturation", 0, "@c Signature_creation Sets the minimum allowed color saturation for when generating color signatures. Applies during teaching. (default 15.0)", FLT32(15.0), END); prm_add("Hue spread", 0, "@c Signature_creation Sets how inclusive the color signatures are with respect to hue. Applies during teaching. (default 1.5)", FLT32(1.5), END); prm_add("Saturation spread", 0, "@c Signature_creation Sets how inclusive the color signatures are with respect to saturation. Applies during teaching. (default 1.5)", FLT32(1.5), END); prm_add("CC min saturation", 0, "@c Signature_creation Sets the minimum allowed color saturation for when generating color code (CC) signatures. Applies during teaching. (default 15.0)", FLT32(15.0), END); prm_add("CC hue spread", 0, "@c Signature_creation Sets how inclusive the color code (CC) signatures are with respect to hue. Applies during teaching. (default 3.0)", FLT32(3.0), END); prm_add("CC saturation spread", 0, "@c Signature_creation Sets how inclusive the color code (CC) signatures are with respect to saturation for color codes. Applies during teaching. (default 50.0)", FLT32(50.0), END); prm_add("Color code mode", 0, "Sets the color code mode, 0=disabled, 1=enabled, 2=color codes only, 3=mixed (default 1)", INT8(1), END); // load uint8_t ccMode; uint16_t maxBlobs, maxBlobsPerModel; uint32_t minArea; prm_get("Max blocks", &maxBlobs, END); prm_get("Max blocks per signature", &maxBlobsPerModel, END); prm_get("Min block area", &minArea, END); prm_get("Color code mode", &ccMode, END); g_blobs->setParams(maxBlobs, maxBlobsPerModel, minArea, (ColorCodeMode)ccMode); cc_loadLut(); }
int main(void) { uint16_t major, minor, build; char *type; int i, res, count, count2; volatile uint32_t d; // insert a small delay so power supply can stabilize for (d=0; d<2500000; d++); #ifdef KEIL pixyInit(SRAM3_LOC, &LR0[0], sizeof(LR0)); #else pixyInit(); #endif #if 0 i = 0; char *foo; while(1) { foo = new (std::nothrow) char[128]; if (foo==NULL) { _DBG("full\n"); break; } else { _DBH32((int)foo); _DBG(" "); _DBH32(i); _DBG("\n"); } i++; } while(1); #endif // main init of hardware plus a version-dependent number for the parameters that will // force a format of parameter between version numbers. #ifndef LEGO rcs_init(); #endif cc_init(g_chirpUsb); ser_init(); exec_init(g_chirpUsb); #if 0 exec_addProg(&g_progBlobs); ptLoadParams(); exec_addProg(&g_progPt); exec_addProg(&g_progVideo, true); #if 0 cam_setMode(CAM_MODE1); while(1) periodic(); #endif #endif #if 1 // load programs exec_addProg(&g_progBlobs); #ifndef LEGO // need to call this to get the pan/tilt parameters to display. // We can make some properties modal, meaning they are only diaplayed when the program is running. // We might want to do this here, but this is good for now. ptLoadParams(); exec_addProg(&g_progPt); #endif #if 0 chaseLoadParams(); exec_addProg(&g_progChase); #endif exec_addProg(&g_progVideo, true); #if 1 // this code formats if the version has changed for (i=0, count=0, count2=0; i<25; i++) { res = prm_get("fwver", &major, &minor, &build, END); if (res>=0 && major==FW_MAJOR_VER && minor==FW_MINOR_VER && build==FW_BUILD_VER) count++; res = prm_get("fwtype", &type, END); if (res>=0 && strcmp(type, FW_TYPE)==0) count2++; } if (count==0 || count2==0) prm_format(); #endif // check version prm_add("fwver", PRM_FLAG_INTERNAL, "", UINT16(FW_MAJOR_VER), UINT16(FW_MINOR_VER), UINT16(FW_BUILD_VER), END); prm_add("fwtype", PRM_FLAG_INTERNAL, "", STRING(FW_TYPE), END); exec_loop(); #endif #if 0 #define DELAY 1000000 rcs_setFreq(100); rcs_setLimits(0, -200, 200); rcs_setLimits(1, -200, 200); while(1) { rcs_setPos(0, 0); delayus(DELAY); rcs_setPos(0, 500); delayus(DELAY); rcs_setPos(0, 1000); delayus(DELAY); rcs_setPos(1, 0); delayus(DELAY); rcs_setPos(1, 500); delayus(DELAY); rcs_setPos(1, 1000); delayus(DELAY); } #endif #if 0 while(1) { g_chirpUsb->service(); handleButton(); } #endif }