int main() { int i, off=0, on=1, lports[]=LIGHT_PORTS, pcnt, w=40, m=5; float s; graphics_open(320,240); for(i=0;i<256;i+=5) { graphics_fill(i,i,i); graphics_update(); } SplashBG(320, 240); msleep(1000); graphics_close(); pcnt=NPORTS(lports); for(i=8;i<16;i++) { // change the digital ports to output set_digital_output(i,1); } srand(time(NULL)); // prime random number generation while(1) { table_lights(lports,pcnt,off); // shut off table lights setup(); // team setup (light calibration w/time out option) // setup done, including any time outs so proceed with judge's setup //get_shelf_positions(); // display orange/yellow block set up for judges - 2014 get_bgal_pod_positions(); // display left-right positions for Botgal & pod - 2015 set_a_button_text("QUIT"); set_b_button_text("-"); set_c_button_text("-"); graphics_close(); // close any open graphics graphics_open(3*w,62); display_clear(); display_printf(0,0,"************** BOTBALL 2015 **************"); display_printf(0,1," LIGHTS ON IN"); display_printf(0,2,"******************************************"); display_printf(0,9," Press QUIT to stop count down"); if (countdown_sd(5,1,BLUE,YELLOW,m,w)) continue; s=seconds(); // 2015 table_lights(lports,pcnt,on); // on for 115 seconds display_printf(0,1," GAME CLOCK - LIGHTS ON TILL 5"); if (countdown(120,11,GREEN,BLUE,m,w)) continue; // end 2015 /* // 2014 table_lights(lports,pcnt,on); // on for 15 seconds display_printf(0,1," GAME CLOCK - LIGHTS ON TILL 105"); if (countdown(120,106,GREEN,BLUE,m,w)) continue; table_lights(lports,pcnt,off); // of for 100 seconds display_printf(0,1," GAME CLOCK - LIGHTS OFF TILL 5"); if (countdown(105,11,LTBLUE,RED,m,w)) continue; // end 2014 */ if (countdown(10,6,LTORANGE,BLUE,m,w)) continue; display_printf(0,1," GAME CLOCK - LIGHTS BLINK TILL 0"); i=5+(seconds()-s); if (blinkdown(5,0,RED,YELLOW,m,w,lports,pcnt)) continue; display_printf(0,1," GAME CLOCK - %d ",i); display_printf(0,9," ***** GAME OVER! ***** "); table_lights(lports,pcnt,off); // shut off table lights msleep(5000); // pause display } return 0; }
int main(int argc, char *argv[]) { if(!graphics_open(640, 480)) return 0; while(1) { usleep(1); graphics_rectangle(0, 0, 30, 30, 255, 0, 0); graphics_update(); } graphics_close(); return 0; }
void get_bgal_pod_positions() { // screen size (scols,srows), box size (bxcols,bxcols), separator m pixels // random block positions p1, p2 set by function picks int srows=120,scols=160, bpos, ppos; graphics_close(); // close any existing graphics window display_clear(); // prep screen set_a_button_text("COUNTDOWN"); set_b_button_text("-"); set_c_button_text("-"); graphics_open(scols,srows); graphics_fill(WHITE); bpos=rand()%2; if (bpos==0) ppos=1; else ppos=0; // draw field graphics_rectangle(3,3,157,117,BLACK); // outline graphics_rectangle(3,3,70,50,BLACK); // quads graphics_rectangle(90,3,157,50,BLACK); graphics_rectangle(3,70,70,117,BLACK); graphics_rectangle(90,70,157,117,BLACK); graphics_rectangle_fill(70,3,90,50,LTBROWN); // mesa graphics_rectangle(70,3,90,50,BLACK); graphics_rectangle_fill(70,70,90,117,LTBROWN); graphics_rectangle(70,70,90,117,BLACK); graphics_rectangle_fill(72,50,88,70,LTGRAY); // caldera graphics_rectangle(72,50,88,70,BLACK); graphics_rectangle_fill(20,3,25,50,TEAL); // lines graphics_rectangle_fill(135,3,140,50,TEAL); graphics_rectangle_fill(20,70,25,117,PINK); graphics_rectangle_fill(135,70,140,117,PINK); if (bpos==0) { draw_bg(73,13,0.2); graphics_rectangle_fill(74,87,86,102,GREEN); } else { draw_bg(73,82,0.2); graphics_rectangle_fill(74,18,86,32,GREEN); } graphics_update(); display_printf(2,0,"Set Botgal and Botpod "); while(a_button()==0); while(a_button()==1); // debounce }
int main() { camera_open(); camera_update(); graphics_open(get_camera_width(), get_camera_height()); while(!get_key_state('Q')) { camera_update(); graphics_blit_enc(get_camera_frame(), BGR, 0, 0, get_camera_width(), get_camera_height()); graphics_circle_fill(get_camera_width() / 2, get_camera_height() / 2, get_camera_height() / 20, 255, 0, 0); graphics_update(); } camera_close(); graphics_close(); return 0; }
int main(int argc, char ** argv) { graphics_open(100,100); int x, j; for (j = 0; j < 10; ++j) { for (x = 0; x < 100; ++x) { graphics_clear(); graphics_circle_fill(x, 50, 5, 255, 0, 0); graphics_update(); msleep(10); } } graphics_close(); return 0; }
void blinking_light() { while(BCHK); // debounce graphics_close(); // close any existing window graphics_open(45,45); graphics_fill(WHITE); while(!(BCHK)) { graphics_circle_fill(24, 24, 20, GRAY); graphics_circle_fill(24, 24, 8, YELLOW); graphics_line(6, 24, 42, 24, YELLOW); // horizontal graphics_line(24, 6, 24, 42, YELLOW); // vertical graphics_line(12, 12, 36, 36, YELLOW); // forward slash graphics_line(12, 36, 36, 12, YELLOW); // back slash graphics_update(); msleep(250); if(BCHK) break; graphics_circle_fill(24, 24, 20, GRAY); graphics_update(); msleep(250); } graphics_close(); }
void main (void) { // Connect to our drivers for the TFT, touch sensor. tft_touch = touchscreen_open(TOUCHSCREEN_1); ptr = pointer_open(POINTER_1); display = graphics_open(GRAPHICS_1); canvas = graphics_get_visible_canvas(display); leds = led_open(DRV_LED_1); led_turn_all_off(leds); // Clear screen graphics_fill_canvas(canvas, BLACK); graphics_set_visible_canvas(display, canvas); // Update display and turn off LEDs while(!graphics_visible_canvas_is_set(display)); // Set up and calibrate touch screen. touchscreen_set_callback(tft_touch, draw_mark, canvas); while(!touchscreen_calibrate(tft_touch, 320, 240)) { set_all_leds(0xFF0000); // If Touchscreen can't calibrate RED ALERT! } led_turn_all_off(leds); // Put colormap on TFT graphics_draw_bitmap(canvas, bmp, 0, 0, 320, 240, 0); graphics_set_visible_canvas(display, canvas); // Start picking colors! while(1) { if (pointer_update(ptr, pointer_state)) { set_all_leds(graphics_get_pixel(canvas, pointer_state->x, pointer_state->y)); } } }
int main(int argc, char** argv) { if(!depth_open()) { printf("Unable to open libkipr_link_depth_sensor\n"); return 1; } int depth_image_height = -1; int depth_image_width = -1; int mouse_x; int mouse_y; int last_max_depth = 6000 /* mm */; int max_depth; if(set_depth_camera_resolution(DEPTH_CAMERA_RESOLUTION_640_480) == 0) { printf("Failed to set the depth camera resolution to 640 x 480\n"); return 1; } #ifdef CAMERA_IS_UPSIDE_DOWN if(set_depth_camera_orientation(DEPTH_CAMERA_ORIENTATION_UPSIDE_DOWN) == 0) { printf("Failed to set the depth camera orientation\n"); return 1; } #endif printf("Press 'Q' to stop\n"); while(!get_key_state('Q')) { if(depth_update()) { if(depth_image_height == -1) { // initialize the graphics output depth_image_height = depth_image_get_height(); depth_image_width = depth_image_get_width(); graphics_open(depth_image_width, depth_image_height); } get_mouse_position(&mouse_x, &mouse_y); max_depth = 0; // display depth image for(int y = 0; y < depth_image_height; y++) { for(int x = 0; x < depth_image_width; x++) { int depth = get_depth_value(x, y); // save max depth if(depth > max_depth) { max_depth = depth; } // color invalid depth pixel red if((depth != INVALID_COORDINATE) && last_max_depth) { int r; int g; int b; HSVtoRGB(360*0xFF*depth/last_max_depth, &r, &g, &b); graphics_pixel(x, y, r, g, b); } else { graphics_pixel(x, y, 0xFF, 0xFF, 0xFF); } #ifdef SHOW_DEPTH_UNDER_MOUSE if(mouse_x == x && mouse_y == y) { console_clear(); if(depth != INVALID_COORDINATE) { printf("(%d, %d): Depth: %d mm; World coordinate: (%d, %d, %d)\n", x, y, depth, get_world_x(x, y), get_world_y(x, y), get_world_z(x, y)); } else { printf("(%d, %d): No information available\n", x, y); } } #endif } } last_max_depth = max_depth; graphics_update(); } else { printf("No depth image received yet\n"); msleep(2000); } } graphics_close(); depth_close(); return 0; }