void tg_repeater() { // uint8_t full_duplex = false; uint8_t full_duplex = true; unsigned char tx = 'Z'; unsigned char rx; while (true) { tx = _nextchar(tx); xio_putc(XIO_DEV_RS485, tx); // write to RS485 port if (full_duplex) { while ((rx = xio_getc(XIO_DEV_RS485)) == -1); // blocking read xio_putc(XIO_DEV_USB, rx); // echo RX to USB port } else { xio_putc(XIO_DEV_USB, tx); // write TX to USB port } // gpio_toggle_port(1); // _delay_ms(10); } }
void tg_receiver() { // tg_controller(); // this node executes gcode blocks received via RS485 // int getc_code = 0; int rx; xio_queue_RX_string_usart(XIO_DEV_RS485, "Z"); // simulate an RX char while (true) { while ((rx = xio_getc(XIO_DEV_RS485)) == -1); xio_putc(XIO_DEV_RS485, rx); // write to RS485 port // xio_putc_rs485(rx, fdev_rs485); // alternate form of above // gpio_toggle_port(1); } }
int uih_save_enable(struct uih_context *uih, xio_file f, int mode) { struct uih_savedcontext *s; int i; last = 0; if (uih->save) { uih_error(uih, "Recording is already enabled"); return 0; } s = (struct uih_savedcontext *) calloc(1, sizeof(*s)); if (f == NULL || s == NULL) { uih_error(uih, "File could not be opended or out of memory"); return 0; } uih->savec = s; s->fcontext = make_fractalc(1, uih->image->pixelwidth * uih->image->width, uih->image->pixelheight * uih->image->height); if (s->fcontext == NULL) { uih_error(uih, "File could not be opended or out of memory"); return 0; } s->mode = mode; /*Invalidate context to force save everything first */ s->speedup = STEP; s->maxstep = MAXSTEP; s->xcenter = INT_MAX; s->fastmode = 2; s->juliamode = 0; s->cycling = 0; for (i = 0; i < uih_nfilters; i++) s->filter[i] = 0; s->pressed = 0; s->firsttime = 1; uih->palettechanged = 1; s->cyclingspeed = 30; s->fcontext->pre = s->fcontext->pim = 0; s->fcontext->bre = s->fcontext->bim = 0; s->fcontext->currentformula = NULL; s->fcontext->periodicity = 1; s->fcontext->maxiter = 170; s->fcontext->bailout = 4; s->fcontext->coloringmode = 0; s->fcontext->incoloringmode = 0; s->fcontext->outtcolor = 0; s->fcontext->intcolor = 0; s->fcontext->mandelbrot = 1; s->fcontext->plane = 0; s->fcontext->range = 3; s->fcontext->angle = 0; s->rotatepressed = 0; s->autorotate = 0; s->fastrotate = 0; s->rotationspeed = 10; s->clearscreen = 0; s->color = 0; s->xtextpos = 1; s->ytextpos = 1; s->file = f; s->timer = tl_create_timer(); s->synctimer = tl_create_timer(); uih->viewchanged = 1; uih->palettechanged = 1; uih->save = 1; uih_emulatetimers(uih); tl_reset_timer(s->timer); uih->moved = 0; #ifndef _plan9_ if (mode == UIH_SAVEANIMATION) myputs(";Animation file automatically generated by XaoS " XaoS_VERSION "\n" "; - a realtime interactive fractal zoomer\n" ";Use xaos -play <filename> to replay it\n"); else if (mode == UIH_SAVEPOS) myputs(";Position file automatically generated by XaoS " XaoS_VERSION "\n" "; - a realtime interactive fractal zoomer\n" ";Use xaos -load <filename> to display it\n"); #endif uih_saveframe(uih); uih_updatemenus(uih, "save"); xio_putc('\n', f); return 1; }