// initialize the file for output void TachyonDisplayDevice::write_header() { fprintf(outfile, "# \n"); fprintf(outfile, "# Molecular graphics exported from VMD %s\n", VMDVERSION); fprintf(outfile, "# http://www.ks.uiuc.edu/Research/vmd/\n"); fprintf(outfile, "# \n"); fprintf(outfile, "# Requires Tachyon version 0.99.0 or newer\n"); fprintf(outfile, "# \n"); fprintf(outfile, "# Default tachyon rendering command for this scene:\n"); fprintf(outfile, "# tachyon %s\n", TACHYON_RUN_STRING); fprintf(outfile, "# \n"); // NOTE: the vmd variable "Aspect" has absolutely *nothing* to do // with aspect ratio correction, it is only the ratio of the // width of the graphics window to its height, and so it should // be used only to cause the ray tracer to generate a similarly // proportioned image. fprintf(outfile, "Begin_Scene\n"); fprintf(outfile, "Resolution %d %d\n", (int) xSize, (int) ySize); // Emit shading mode information fprintf(outfile, "Shader_Mode "); // change shading mode depending on whether the user wants shadows // or ambient occlusion lighting. if (shadows_enabled() || ao_enabled()) { fprintf(outfile, "Full\n"); } else { fprintf(outfile, "Medium\n"); } // For VMD we always want to enable flags that preserve a more WYSIWYG // type of output, although in some cases doing things in Tachyon's // preferred way might be nicer. The user can override these with // command line flags still if they want radial fog or other options. fprintf(outfile, " Trans_VMD\n"); fprintf(outfile, " Fog_VMD\n"); // render with ambient occlusion lighting if required if (ao_enabled()) { fprintf(outfile, " Ambient_Occlusion\n"); fprintf(outfile, " Ambient_Color %g %g %g\n", get_ao_ambient(), get_ao_ambient(), get_ao_ambient()); fprintf(outfile, " Rescale_Direct %g\n", get_ao_direct()); fprintf(outfile, " Samples %d\n", aosamples); } fprintf(outfile, "End_Shader_Mode\n"); write_camera(); // has to be first thing in the file. write_lights(); // could be anywhere. write_materials(); // has to be before objects that use them. }
int main (void) { int ch = 0; int i = 0; // are we ready to relay scribbler output // by default we wait until we get a scribbler request from // the user before relaying scribbler messages via bluetooth int relay_scrib_messages = 0; // is the current command a scribbler command int scribbler_cmd = 0; // are we processing a get_info packet int get_info = 0; // setup the directionality of the pins setup_pins(); // setup the PLL - 60 MHz setup_pll(); // setup the instruction prefetch setup_mam(); // give some time to let everything settle msleep(100); // The scribbler UART(0) is 38400 8N1 uart0Init(B38400, UART_8N1, UART_FIFO_8); // setup UART 0 // The CM-5 UART (0) is 57600 8N1 // uart0Init(B57600, UART_8N1, UART_FIFO_8); // setup UART 0 // The Robonova UART (0) is 9600 or 115200 8N1 // uart0Init(B115200, UART_8N1, UART_FIFO_8); // setup UART 0 // The bluetooth UART(1) #if (VERSION_OF_BOARD == 3) uart1Init(B57600, UART_8N1, UART_FIFO_8); // setup UART 1 #else uart1Init(B460800, UART_8N1, UART_FIFO_8); // setup UART 1 #endif // synchronize with autobaud for (i = 1; i < 512; i++) { uart1Putch(i); } // Set up VIC and enable interrupts vic_init(); //set timer0 prescalaer to around 1 usec TIMER0_PR = 0x39; // Start timer0 for benchmarking TIMER0_TCR = 1; // Set up the transmit queue uart1_queue_init(); // setup interrupts for receiving IR messages ir_rx_init(); // set back configurable LED off set_led(0); // set front LED off led_off(); // turn IR power to 135 set_ir(135); // set external bluetooth to max; internal amplifier is throttled via pskeys set_bluetooth(255); // slow camera down write_camera(OV_CLKRC, 1); // turn off auto white balance //write_camera(OV_COMA, 0x14 & ~(1<<2)); // turn off auto gain and auto exposure //write_camera(OV_COMB, 0xA3 & ~(0x3)); //flush out any old characters for (i = 0; i < 200; i++) { getch(); } /* read in scribbler orientation * * - scribbler forward is stored as 0xDF in serial memory to avoid * coincidental settings */ read_mem(0, 0, &scribbler_orientation, 1); if (scribbler_orientation == 0xDF) { scribbler_orientation = 0; } else { scribbler_orientation = 1; } while (1) { //led_on(); ch = getch(); //led_off(); // body of the firmware - process the byte code sent over bluetooth if (ch != -1) { cur_rqst[rqst_idx] = ch; // process the cmd if its intended for the fluke if (rqst_idx == 0) { scribbler_cmd = 0; if (ch == SET_WINDOW) serve_set_window(); else if (ch == SET_RLE) serve_set_rle(); else if (ch == GET_RLE) serve_rle(); else if (ch == GET_BLOB) serve_blob(); else if (ch == GET_BLOB_WINDOW) serve_blob_window(); else if (ch == GET_IMAGE) serve_image(); else if (ch == GET_WINDOW) serve_image_window(); else if (ch == GET_WINDOW_LIGHT) serve_image_window_sum(); else if (ch == GET_BATTERY) serve_battery(); else if (ch == SET_DONGLE_LED_ON) led_on(); else if (ch == SET_DONGLE_LED_OFF) led_off(); else if (ch == SET_DIMMER_LED) serve_back_led(); else if (ch == SET_DONGLE_IR) serve_ir_power(); else if (ch == SET_RESET_SCRIBBLER) serve_reset_scribbler(); else if (ch == SET_RESET_SCRIBBLER2) serve_reset_scribbler2(); else if (ch == GET_SERIAL_MEM) serve_get_serial_mem(); else if (ch == SET_SERIAL_MEM) serve_set_serial_mem(); else if (ch == SET_SERIAL_ERASE) serve_erase_serial_mem(); else if (ch == GET_DONGLE_R_IR) serve_ir(0x1); else if (ch == GET_DONGLE_L_IR) serve_ir(0x2); else if (ch == GET_DONGLE_C_IR) serve_ir(0x4); else if (ch == SET_SCRIB_PROGRAM) serve_set_scrib_program(); else if (ch == SET_SCRIB_BATCH) serve_set_scrib_program_batch(); else if (ch == GET_SCRIB_PROGRAM) serve_get_scrib_program(); else if (ch == SET_START_PROGRAM) serve_start_scrib_program(); else if (ch == SET_START_PROGRAM2) serve_start_scrib2_program(); else if (ch == SET_UART0) serve_set_uart0(); else if (ch == SET_PASS_BYTE) serve_send_byte(); else if (ch == SET_PASSTHROUGH) serve_set_passthrough(); else if (ch == SET_PASS_N_BYTES) serve_set_pass_n_bytes(); else if (ch == SET_PASSTHROUGH_ON) relay_scrib_messages = 1; else if (ch == SET_PASSTHROUGH_OFF) relay_scrib_messages = 0; else if (ch == GET_PASS_N_BYTES) serve_get_pass_n_bytes(); else if (ch == GET_PASS_BYTES_UNTIL) serve_get_pass_bytes_until(); else if (ch == SET_FORWARDNESS) serve_set_forwardness(); else if (ch == SET_WHITE_BALANCE) serve_set_wb(); else if (ch == SET_NO_WHITE_BALANCE) serve_unset_wb(); else if (ch == GET_CAM_PARAM) serve_read_camera(); else if (ch == SET_CAM_PARAM) serve_write_camera(); else if (ch == SAVE_EEPROM) serve_save_eeprom(); else if (ch == RESTORE_EEPROM) serve_restore_eeprom(); else if (ch == UPDATE_FIRMWARE) serve_update_firmware(); else if (ch == WATCHDOG_RESET) serve_fluke_reset(); else if (ch == GET_JPEG_GRAY_HEADER) serve_jpeg_gray_header(); else if (ch == GET_JPEG_COLOR_HEADER)serve_jpeg_color_header(); else if (ch == GET_JPEG_GRAY_SCAN) serve_jpeg_gray_scan(); else if (ch == GET_JPEG_COLOR_SCAN) serve_jpeg_color_scan(); else if (ch == GET_VERSION) serve_version(); else if (ch == GET_IR_MESSAGE) serve_get_ir_message(); else if (ch == SEND_IR_MESSAGE) serve_send_ir_message(); else if (ch == SET_IR_EMITTERS) serve_set_ir_emitters(); else if (ch == GET_ROBOT_ID) serve_identify_robot(); else scribbler_cmd = 1; } if (scribbler_cmd) { // Flush if this is the first time we have talked to the scribbler if (relay_scrib_messages == 0) { for (i = 0; i < 100; i++) { uart0Getch(); } } relay_scrib_messages = 1; // we just got a GET_INFO request; pass it on to the scribbler if ((rqst_idx == 0) && (ch == GET_INFO)) { get_info = 1; } // scribbler should now have the whole GET_INFO request else if ((rqst_idx == 8) && get_info == 1) { get_info = 2; } // flip motors forward to backwards if ((cur_rqst[0] == SET_MOTORS) && scribbler_orientation && rqst_idx < 3) { // now send the packet with left/right swapped if ((rqst_idx == 2)) { uart0Putch(cur_rqst[0]); //msleep(10); uart0Putch(200-cur_rqst[2]); //msleep(10); uart0Putch(200-cur_rqst[1]); } } // pass on character to the scribbler else { uart0Putch(ch); } // take care of scribbler packet indexing rqst_idx ++; if (rqst_idx > 8) { rqst_idx = 0; } } } /* end if it received a request */ /* * if we are talking to the scribbler see if it has anything * for us to relay over the bluetooth link */ if (relay_scrib_messages) { ch = uart0Getch(); if (ch != -1) { // Process GET_INFO request we got the last character if (get_info > 500 && ch == 0x0A) { get_info = 0; } // Process GET_INFO we just sent our GET_INFO string if (get_info >= 500 && get_info < 50000) { putch(','); get_info = 50000; } putch(ch); } } /* * send our GET_INFO information * * the GET_INFO handling is pretty hideous to preserve backward * compatibility with other bluetooth serial and serial links. */ if (get_info > 1) { get_info ++; if (get_info == 400) { putstr(VERSION); get_info = 500; } if (get_info == 100000) { putch(0x0A); get_info = 0; } } update_low_battery_light(); } }