void main() { uns16 tick_marker = 0; uns16 test_tick; configure_system(); delay_ms(100); #ifdef USB_SERIAL_DEBUG serial_print_str("USB here we go..."); #endif delay_ms(100); usb_enable_module(); while (usb_configured == 0) { #ifdef USB_SERIAL_DEBUG serial_print_str("<wait>"); #endif delay_ms(250); delay_ms(250); delay_ms(250); delay_ms(250); } #ifdef USB_SERIAL_DEBUG serial_print_str("\nGreat! Now trying to print\n"); #endif usb_cdc_print_str("\n\nPIC USB Serial demo\n"); usb_cdc_print_str( "\n<"); usb_cdc_print_str(__TIME__); usb_cdc_putc(' '); usb_cdc_print_str(__DATE__); usb_cdc_print_str(">\n"); usb_cdc_print_str("Commands: a attach to USB bus\n"); while(1) { if (usb_cdc_rx_avail()) { process_rx(); } handle_tasks(); } // while (1) // main }
int main(int argc, char* argv[]) { try { Cli_parser cli_args(argc, argv); // get -v if (cli_args.has("-v") || cli_args.has("--version")) { #ifdef VERBOSE std::cout<<"Pollux'NZ City Gateway module -- "<<POLLUX_VERSION<<" -- +verbose"<<std::endl; #else std::cout<<"Pollux'NZ City Gateway module -- "<<POLLUX_VERSION<<std::endl; #endif } // get -h if (cli_args.has("-h") || cli_args.has("--help")) { #ifdef VERBOSE std::cout<<"Pollux'NZ City Gateway module -- "<<POLLUX_VERSION<<" -- +verbose"<<std::endl; #else std::cout<<"Pollux'NZ City Gateway module -- "<<POLLUX_VERSION<<std::endl; #endif std::cout<<"usage: "<<argv[0]<<"[-h] [-p PATH]"<<std::endl\ <<std::endl\ <<"Pollux'NZ City Gateway module"<<std::endl\ <<std::endl\ <<"optional arguments:"<<std::endl\ <<" -c, --conf PATH Path to the configuration directory (default: /etc/pollux)"<<std::endl\ <<" -e, --ext PATH Path to the plugin base directory (default: /usr/lib/pollux)"<<std::endl\ <<" -s, --superuser Does not fork, and escalates down privileges"<<std::endl\ <<" -v, --version Returns version"<<std::endl\ <<" -h, --help This help screen"<<std::endl\ <<std::endl; ::exit(0); } // get -s if (cli_args.has("-s") || cli_args.has("--superuser")) configure_system_nofork(); else configure_system(); std::string path_conf= "/etc/pollux"; std::string path_ext= "/usr/lib/pollux"; // get -c if (cli_args.has("-c") && !cli_args.has("--conf")) path_conf = cli_args.get("-c"); else if (!cli_args.has("-c") && cli_args.has("--conf")) path_conf = cli_args.get("--conf"); else if (cli_args.has("-c") && cli_args.has("--conf")) { std::cerr<<"Can't have both -c or --conf. Please choose one. Exiting..."<<std::endl; ::exit(1); } // strip trailing '/' at end of path if (path_conf.length() > 0) { std::string::iterator it = path_conf.end() - 1; if (*it == '/') path_conf.erase(it); } // get -e if (cli_args.has("-e") && !cli_args.has("--ext")) path_ext = cli_args.get("-e"); else if (!cli_args.has("-e") && cli_args.has("--ext")) path_ext = cli_args.get("--ext"); else if (cli_args.has("-e") && cli_args.has("--ext")) { std::cerr<<"Can't have both -e or --ext. Please choose one. Exiting..."<<std::endl; ::exit(1); } // strip trailing '/' at end of path if (path_ext.length() > 0) { std::string::iterator it = path_ext.end() - 1; if (*it == '/') path_ext.erase(it); } pollux::Pollux_calibrator pconfig(path_conf, path_ext); try { pconfig.load_configuration(); pconfig.load_datastores(); pconfig.load_sensors(); pconfig.load_geoloc(); } catch (pollux::Pollux_config_exception pce) { std::cerr<<pce.what()<<std::endl; std::cerr<<"Can't load configuration, exiting..."<<std::endl; ::exit(1); } pollux::Pollux_observer s(pconfig); if (s.begin(B9600) >= 0) { for (;;) s.poll(); return 0; } } catch (std::runtime_error e) { std::cerr<<e.what()<<std::endl; } catch (std::exception e) { std::cerr<<e.what()<<std::endl; std::cerr<<"uncaught exception"<<std::endl; } catch (...) { std::cerr<<"unbelievable exception"<<std::endl; } return 2; }
void main() { configure_system(); delay_ms(100); serial_print_str("\n\nPicPack Sure 2416 Led display demo\n"); serial_print_str( "\n<"); serial_print_str(__TIME__); serial_putc(' '); serial_print_str(__DATE__); serial_print_str(">\n"); delay_ms(100); // sure_2416_write(0,0b00001111); uns8 brightness = 0; uns8 my_count = 0; while (1) { //delay_ms(250); //serial_print_str("writing...\n"); //sure_2416_write(0,0b00001111); /*delay_s(5); sure_2416_set_pixel(0,0,1); delay_s(1); sure_2416_set_pixel(23,0,1); delay_s(1); sure_2416_set_pixel(23,15,1); delay_s(1); sure_2416_set_pixel(0,15,1); delay_s(1); sure_2416_set_pixel(0,0,0); delay_s(1); sure_2416_set_pixel(23,0,0); delay_s(1); sure_2416_set_pixel(23,15,0); delay_s(1); sure_2416_set_pixel(0,15,0);*/ /*uns8 x,y; for(x = 0 ; x < 24 ; x++) { for(y = 0 ; y < 16 ; y++) { sure_2416_set_pixel(x, y, 1); } } delay_ms(100); for(x = 0 ; x < 24 ; x++) { for(y = 0 ; y < 16 ; y++) { sure_2416_set_pixel(x, y, 0); } } delay_ms(100); */ sure_2416_fill2(0); delay_ms(100); sure_2416_fill2(1); delay_ms(100); my_count++; if (my_count == 10) { serial_print_str("Setting brightness to "); serial_print_int(brightness); serial_print_nl(); sure_2416_set_brightness(brightness++); if (brightness == 16) { brightness = 0; } my_count = 0; } } } // main
void main() { trisa = 0; flash(); configure_system(); flash(); delay_ms(100); serial_print_str("\n\nPicPack Sure 6432 Led display demo\n"); serial_print_str( "\n<"); serial_print_str(__TIME__); serial_putc(' '); serial_print_str(__DATE__); serial_print_str(">\n"); serial_print_str("total buffer = "); serial_print_int(DRAW_TOTAL_BUFFER_SIZE); serial_print_nl(); serial_print_str("wide = "); serial_print_int(DRAW_PIXELS_WIDE); serial_print_nl(); serial_print_str("high = "); serial_print_int(DRAW_PIXELS_HIGH); serial_print_nl(); serial_print_str("ppb = "); serial_print_int(DRAW_PIXELS_PER_BYTE); serial_print_nl(); while (1) { /*delay_ms(250); draw_set_pixel(0,0,1); draw_paint(); delay_s(1); draw_set_pixel(23,0,1); draw_paint(); delay_s(1); draw_set_pixel(23,15,1); draw_paint(); delay_s(1); draw_set_pixel(0,15,1); draw_paint(); delay_s(1); draw_set_pixel(0,0,0); draw_paint(); delay_s(1); draw_set_pixel(23,0,0); draw_paint(); delay_s(1); draw_set_pixel(23,15,0); draw_paint(); delay_s(1); draw_set_pixel(0,15,0); draw_paint(); delay_s(1); draw_line(0, 0, 23, 15, 1); draw_paint(); delay_s(1); draw_line(0, 15, 23, 0, 1); draw_paint(); delay_s(1); draw_line(0, 0, 23, 15, 0); draw_paint(); delay_s(1); draw_line(0, 15, 23, 0, 0); draw_paint(); delay_s(1); draw_circle(12, 8, 1, 1); draw_paint(); delay_s(1); draw_circle(12, 7, 2, 1); draw_paint(); delay_s(1); draw_circle(12, 7, 3, 1); draw_paint(); delay_s(1); draw_circle(12, 7, 4, 1); draw_paint(); delay_s(1); draw_circle(12, 7, 5, 1); draw_paint(); delay_s(1); draw_circle(12, 7, 6, 1); draw_paint(); delay_s(1); draw_circle(12, 7, 7, 1); draw_paint(); delay_s(1);*/ draw_clear_screen(); serial_print_str("Rectangle\n"); draw_rect(1, 1, DRAW_PIXELS_WIDE - 1 -1 , DRAW_PIXELS_HIGH - 1 - 1, 2); /*draw_set_pixel(0,0,1); draw_set_pixel(DRAW_PIXELS_WIDE - 1, 0, 1); draw_set_pixel(DRAW_PIXELS_WIDE - 1, DRAW_PIXELS_HIGH - 1, 1); draw_set_pixel(0, DRAW_PIXELS_HIGH - 1, 1); */ uns16 countp; for (countp = 0; countp < 200; countp++) { draw_paint(); } draw_clear_screen(); serial_print_str("Rectangle\n"); draw_rect(1, 1, 62, 30, 1); draw_circle(31, 16, 15, 3); for (countp = 0; countp < 1000; countp++) { draw_paint(); } } } // main