static gboolean plugin_load(PurplePlugin *plugin) { PurpleBuddyList *buddy_list; void *conv_handle; if (cc_init_gtk_gl()) return FALSE; cc_init(&cc_info); buddy_list = purple_get_blist(); if (buddy_list) { purple_signal_connect(PIDGIN_BLIST (buddy_list), "drawing-menu", plugin, PURPLE_CALLBACK(cc_buddy_menu), NULL); conv_handle = purple_conversations_get_handle(); purple_signal_connect(conv_handle, "received-im-msg", plugin, PURPLE_CALLBACK(receive_im_cb), &cc_info); purple_signal_connect(conv_handle, "displaying-im-msg", plugin, PURPLE_CALLBACK(display_im_cb), &cc_info); } else { purple_signal_connect (purple_connections_get_handle(), "signed-on", plugin, PURPLE_CALLBACK(cc_signed_on), plugin); } Debug("CrazyChat plugin loaded.\n"); return TRUE; }
static CaptureConfig* cc_new(void) { CaptureConfig* cc; cc = (CaptureConfig*) malloc(sizeof(CaptureConfig)); cc_init(cc); return cc; }
__checkReturn bool ResolveUserEntry() { if (!ResolveUserImports()) return false; SetUserLibc(); cc_init(0); return true; }
// ------------------------------------------------------------------------ // main // ------------------------------------------------------------------------ void c_main() { io_printf (IO_STD, "starting dumped packet bouncer\n"); timer_init (TICK_PERIOD); // setup timer to maybe turn on bouncing cc_init (); // setup comms. cont. interrupt when not full router_init (); // setup router to interrupt when dumping #ifdef DEBUG timer2_init (); // setup timer2 for profiling #endif cpu_sleep (); // Send core to sleep }
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 }
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 GSMTask (void *arg) { static const char fname[] = "GSMTask"; void *msg; phn_syshdr_t *syshdr; boolean release_msg = TRUE; /* * Get the GSM message queue handle * A hack until the tasks in irx are * CPRized. */ gsm_msg_queue = (cprMsgQueue_t) arg; if (!gsm_msg_queue) { GSM_ERR_MSG(GSM_F_PREFIX"invalid input, exiting\n", fname); return; } if (platThreadInit("GSMTask") != 0) { return; } /* * Adjust relative priority of GSM thread. */ (void) cprAdjustRelativeThreadPriority(GSM_THREAD_RELATIVE_PRIORITY); /* * Initialize all the GSM modules */ lsm_init(); fsm_init(); fim_init(); gsm_init(); dcsm_init(); cc_init(); fsmutil_init_shown_calls_ci_map(); /* * On Win32 platform, the random seed is stored per thread; therefore, * each thread needs to seed the random number. It is recommended by * MS to do the following to ensure randomness across application * restarts. */ cpr_srand((unsigned int)time(NULL)); /* * Cache random numbers for SRTP keys */ gsmsdp_cache_crypto_keys(); while (1) { release_msg = TRUE; msg = cprGetMessage(gsm_msg_queue, TRUE, (void **) &syshdr); if (msg) { switch (syshdr->Cmd) { case TIMER_EXPIRATION: gsm_process_timer_expiration(msg); break; case GSM_SIP: case GSM_GSM: release_msg = gsm_process_msg(syshdr->Cmd, msg); break; case DP_MSG_INIT_DIALING: case DP_MSG_DIGIT_STR: case DP_MSG_STORE_DIGIT: case DP_MSG_DIGIT: case DP_MSG_DIAL_IMMEDIATE: case DP_MSG_REDIAL: case DP_MSG_ONHOOK: case DP_MSG_OFFHOOK: case DP_MSG_UPDATE: case DP_MSG_DIGIT_TIMER: case DP_MSG_CANCEL_OFFHOOK_TIMER: dp_process_msg(syshdr->Cmd, msg); break; case SUB_MSG_B2BCNF_SUBSCRIBE_RESP: case SUB_MSG_B2BCNF_NOTIFY: case SUB_MSG_B2BCNF_TERMINATE: sub_process_b2bcnf_msg(syshdr->Cmd, msg); break; case SUB_MSG_FEATURE_SUBSCRIBE_RESP: case SUB_MSG_FEATURE_NOTIFY: case SUB_MSG_FEATURE_TERMINATE: sub_process_feature_msg(syshdr->Cmd, msg); break; case SUB_MSG_KPML_SUBSCRIBE: case SUB_MSG_KPML_TERMINATE: case SUB_MSG_KPML_NOTIFY_ACK: case SUB_MSG_KPML_SUBSCRIBE_TIMER: case SUB_MSG_KPML_DIGIT_TIMER: kpml_process_msg(syshdr->Cmd, msg); break; case REG_MGR_STATE_CHANGE: gsm_reset(); break; case THREAD_UNLOAD: destroy_gsm_thread(); break; default: GSM_ERR_MSG(GSM_F_PREFIX"Unknown message\n", fname); break; } cprReleaseSysHeader(syshdr); if (release_msg == TRUE) { cprReleaseBuffer(msg); } /* Check if there are pending messages for dcsm * if it in the right state perform its operation */ dcsm_process_jobs(); } } }
int main(void) { pixyInit(SRAM3_LOC, &LR0[0], sizeof(LR0)); cc_init(g_chirpUsb); #if 0 uint32_t a = 0xffffffff; uint32_t b = 0; uint32_t c = b - a; printf("*** %d\n", c); #endif #if 0 uint32_t i = 0; uint32_t timer; setTimer(&timer); while(1) { if (getTimer(timer)>1000000) { printf("%d\n", i++); setTimer(&timer); } } #endif #if 1 uint16_t buf[16]; spi_setCallback(transmitCallback); while(1) { if (spi_receive(buf, 1)) { printf("%x\n", buf[0]); if (buf[0]!=0xa5a5) spi_sync(); } } #endif #if 0 // 0 pan, 0 to 1000 clockwise // 1 tilt, 0 to 1000 tilt up while(1) { // bring up servoMove(1, 650, 900, r(800, 50), 0, 550, 450); servoMove(1, 900, 1000, 600, 0, 450, 350); servoMove(1, 1000, 1025, 100, 0, 350, r(320, 20)); servoMove(1, 1025, 1000, 150, 0, 320, r(360, 20)); delayus(2000000); // bring down servoMove(1, 1000, 900, r(600, 50), 0, 350, 460); servoMove(1, 900, 650, r(850, 50), 0, 450, 550); servoMove(1, 650, 670, 100, 0, 550, r(520, 20)); servoMove(1, 670, 650, 150, 0, 520, r(550, 20)); delayus(1500000); // test 1 servoMove(1, 650, 900, r(800, 50), 0, 550, 450); servoMove(1, 900, 1000, 600, 0, 450, 350); servoMove(1, 1000, 1025, 100, 0, 350, r(320, 20)); servoMove(1, 1025, 1000, 150, 0, 320, r(360, 20)); servoMove(1, 1000, 900, r(600, 50), 0, 350, 460); servoMove(1, 900, 650, r(850, 50), 0, 450, 550); servoMove(1, 650, 670, 100, 0, 550, r(520, 20)); servoMove(1, 670, 650, 150, 0, 520, r(550, 20)); // test 2 servoMove(1, 650, 900, r(800, 50), 0, 550, 450); servoMove(1, 900, 1000, 600, 0, 450, 350); servoMove(1, 1000, 1025, 100, 0, 350, r(320, 20)); servoMove(1, 1025, 1000, 150, 0, 320, r(360, 20)); servoMove(1, 1000, 900, r(600, 50), 0, 350, 460); servoMove(1, 900, 650, r(850, 50), 0, 450, 550); servoMove(1, 650, 670, 100, 0, 550, r(520, 20)); servoMove(1, 670, 650, 150, 0, 520, r(550, 20)); delayus(5000000); } #endif #if 0 while(1) { g_chirpUsb->service(); handleButton(); } #endif #if 0 g_chirpM0->getProc("getRLSFrame", (ProcPtr)getRLSFrameCallback); blobProcess(); #endif #if 0 #define SERVO int32_t result, row; uint32_t i, j, numRls, startCol, length, model, xsum, ysum, n, xavg, yavg; uint32_t *qVals = (uint32_t *)RLS_MEMORY; //motor(0, 0); // to switch between servo and motor-- // uncomment servo or motor below, respectively // for motor, change pixy_init.cpp, SCT init // LPC_SCT->MATCH[0].L = 4000; // LPC_SCT->MATCHREL[0].L = 4000; // this will increase the pwm freq and reduce the latency // (these values are normally 20000) // Servo connectors --- black wire down, yellow up. // tilt: edge // pan: inner // note, tilt servo has wire facing forward j = 0; while(1) { g_chirpUsb->service(); handleButton(); if (g_loop) { //cc_getRLSFrame(qVals, RLS_MEMORY_SIZE, LUT_MEMORY, &numRls); cc_getMaxBlob(NULL); #if 0 for (i=0, row=-1, n=0, xsum=0, ysum=0; i<numRls; i++) { if (qVals[i]==0) { row++; continue; } model = qVals[i]&0x03; qVals[i] >>= 3; startCol = qVals[i]&0x1ff; qVals[i] >>= 9; length = qVals[i]&0x1ff; xsum += startCol + (length>>1); ysum += row; n++; } if (n>15) { xavg = xsum/n; yavg = ysum/n; } else { xavg = XCENTER; #ifdef SERVO yavg = YCENTER; #else yavg = YTRACK; #endif } #ifdef SERVO servo(xavg, yavg); #else motor(xavg, yavg); #endif // printf("%d %d\n", xavg, yavg); #endif if (j%50==0) printf("%d\n", j); j++; } } #endif }
__declspec( dllexport ) void LibInit() { // do any setup here cc_init(); }
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 }
int main() { static const char* cubeNames[CC_FACE_NUM] = { "TOP.bmp", "LEFT.bmp", "FRONT.bmp", "RIGHT.bmp", "BACK.bmp", "DOWN.bmp" }; struct cc_context ctx; unsigned int i = 0; unsigned int j = 0; unsigned char rr; unsigned char gg; unsigned char bb; BMP *bmpCube[CC_FACE_NUM]; unsigned int width = 0; unsigned int height = 0; unsigned short depth = 0; BMP *output = NULL; unsigned int pano_width = 0; unsigned int pano_height = 0; const struct cc_coord* coord = NULL; // Read the 6 input images for (i = 0; i < CC_FACE_NUM; ++i) { bmpCube[i] = BMP_ReadFile(cubeNames[i]); if (BMP_GetError() != BMP_OK) { return 1; } } // Get image's dimensions width = (unsigned int)BMP_GetWidth( bmpCube[0]); height = (unsigned int)BMP_GetHeight(bmpCube[0]); depth = BMP_GetDepth( bmpCube[0]); // The input images must be square if (width != height) { return 1; } /* Initialise the algorithm: the width of each input is 640 pixel, the vertical view portion is PI (180 degrees), the horizontal view portion is 2*PI (360 degress). In this case, the output image size will be calculated accordingly. There is another more detailed init function you can play with. */ cc_init(&ctx, width, M_PI*2.0, M_PI); // Generate the mapping from panorama to cubic cc_gen_map(&ctx); // Access the dimension of the panorama image pano_width = ctx.px_pano_h; pano_height = ctx.px_pano_v; // Create the panorama output image output = BMP_Create(pano_width, pano_height, depth); // Map the pixels from the panorama back to the source image for (i = 0; i < pano_width; ++i) { for (j = 0; j < pano_height; ++j) { // Get the corresponding position of (i, j) coord = cc_get_coord(&ctx, i, j); // Access the pixel BMP_GetPixelRGB(bmpCube[coord->face], (unsigned long)coord->x, (unsigned long)coord->y, &rr, &gg, &bb); // Write the pixel to the panorama BMP_SetPixelRGB(output, i, j, rr, gg, bb); } } // Write the output file BMP_WriteFile(output, "PANO.bmp"); // Release memory BMP_Free(output); for (i = 0; i < CC_FACE_NUM; ++i) { BMP_Free(bmpCube[i]); } cc_close(&ctx); return 0; }