//***************************************************************************** // 関数名 : calibration // 引数 : *black (黒、最小値),*white(白、最大値) // 返り値 : 無し // 概要 : 光センサの手動キャリブレーション // 黒白の順でタッチする。 //***************************************************************************** void calibration(int *black,int *white,int angle) { while(1) { tail_control(angle); if (ecrobot_get_touch_sensor(NXT_PORT_S4) == 1) { ecrobot_sound_tone(440, 170, 100); *black = ecrobot_get_light_sensor(NXT_PORT_S3); display_clear(0); /* 画面表示 */ display_goto_xy(0, 1); display_string("BLACK:"); display_int(*black, 4); break; }//if systick_wait_ms(100); /* 10msecウェイト */ }//while display_update(); while(ecrobot_get_touch_sensor(NXT_PORT_S4)); ecrobot_sound_tone(880, 170, 100); while(1) { tail_control(angle); if (ecrobot_get_touch_sensor(NXT_PORT_S4) == 1) { ecrobot_sound_tone(880, 170, 100); *white = ecrobot_get_light_sensor(NXT_PORT_S3); //display_clear(0); /* 画面表示 */ display_goto_xy(0, 2); display_string("WHITE:"); display_int(*white, 4); break; }//if systick_wait_ms(100); /* 10msecウェイト */ }//while //display_clear(0); /* 画面表示 */ display_goto_xy(0,4); display_string("TH:"); display_int(TH(*black,*white), 3); display_update(); while(ecrobot_get_touch_sensor(NXT_PORT_S4)); ecrobot_sound_tone(440, 170, 100); }
void KeyInfo::fromProtobuf(const protocol::Handshake_SignedHandshake_KeyInfo& key_info_s){ public_key.setAsBinaryString(key_info_s.ecdsa_key()); th = TH(public_key); expiration_time = std::chrono::system_clock::from_time_t(key_info_s.expiration_time()); lose_time = std::chrono::system_clock::from_time_t(key_info_s.lose_time()); }
int main() { int i; int j; int height=64; int width=64; int data[2][64*64]; char *ca[64]={ /* 0 1 2 3 4 5 6 */ /* 0123456789012345678901234567890123456789012345678901234567890123 */ /*0*/ "################################################################", "################################################################", "################################################################", "################################################################", "################################################################", /*5*/ "################################################################", "################################################################", "################################################################", "################################################################", "##########.#....#######.####.................###################", /*10*/ "##########.####.#...###.####.........######....#################", "##########......#.##....#.....#......#########.####...##########", "#############.###..#.####......#....##########.##...############", "#############.####.#.####...........##########.##..#############", "#########.###.####.....##...........##########.#.......#########", /*15*/ "#########.#...#....###.####........###########.#.#####.#########", "#########.#.###.####.#.####......##########.##...#####.#########", "#########.#..##.####.######......##########.###.######.#########", "#########.##.##...##.#########.############...#.######.#########", "#########....####.##..########.####.#######........###.#########", /*20*/ "#########.##....#.#...#######....##.#######.#####......#########", "#########.#######.#..########....##.################.###########", "#########.##.####.#..########....##...#..#####...###.###########", "#########.##.#....#..###..............#..#####.......###########", "#########.##.#....#...##..............#..#####....##############", /*25*/ "#########.##.###.###..##................######....##############", "#########..#.###.###..##......##........######......############", "#########..#.###.###.......########.....###########.############", "##########.#...............#......#.....###########.############", "##########.#.#....................#.....###########.############", /*30*/ "##########...###.........###...............########.############", "############################......#........########.############", "############################......#........########..###########", "############################......#........########....#########", "############################......#........####........#########", /*35*/ "###################################...........#......###########", "##############################aaaa............#####..###########", "##############################aaa...........#######..###########", "##############################aaa...........#####....###########", "###########################aaaaa............#####....###########", /*40*/ "#############################aa.................#..#############", "#############################..........##.......#..#############", "#########...........########...........##...##..#..#############", "#########...........########......##........##.........#########", "#########...........########.###..##........##.........#########", /*45*/ "#########...........########.###......##....####..###..#########", "#########...........########.#######..##....####..###..#########", "#########...........#...#....#######........####..###..#########", "#########..................#########........####...##..#########", "#########...........#...#..#########..##....####...##..#########", /*50*/ "#########...........################..###...#####..##..#########", "#########...........######################..#####..#############", "#########...........######################.........#############", "#########...........######################.........#############", "#########...........#############################......#########", /*55*/ "################################################################", "################################################################", "################################################################", "################################################################", "################################################################", /*60*/ "################################################################", "################################################################", "################################################################", "################################################################" }; unsigned int top = 1 << 24 ,down = 1 << 8, right = 1 << 16 , left = 1 ; for(i = 0 ;i < 64 ; i++ ){ for(j = 0 ; j < 64 ; j++ ){ switch( ca[i][j] ){ case '#': data[0][j + i*width] = 1; break; case '.': data[0][j + i*width] = 0; break; case 'a': data[0][j+i*width] = 2; break; } } } #define TH( x , y , dat ) data[1][(x)+(y)*width] = (dat); TH(30,18,top ); TH( 28,29,left ); TH( 35,35,down ); TH( 36,35,down ); TH( 37,35,down ); TH( 38,35,down ); TH( 39,35,down ); TH( 40,36,left ); TH( 40,37,left ); TH( 40,38,left); TH( 40,39,left ); TH( 40,40,left ); TH( 39,44,right | top ); TH( 38,44,top ); TH( 37,44,top ); TH( 36,44,top); { FILE *fp; int fwid = htonl( width ); int fhei = htonl( height ); fp = fopen("floor0.binary" , "w");; fwrite( &fwid, 4 , 1 , fp ); fwrite( &fhei, 4 , 1 , fp ); fwrite( data[0] , 4 , 64*64 , fp ); fwrite( data[1] , 4 , 64*64 , fp ); fclose( fp ); } for(i = 0 ; i < 64 ; i++){ fprintf( stderr,"%d " , data[0][i] ); } }
/* tasks.c: the list of threads and processes to run (DO NOT CHANGE) */ #include "scheduler.h" #include "th.h" struct task_info task[] = { /* clock and status thread */ TH(&clock_thread), /* lock and condition variable test threads */ TH(&thread2), TH(&thread3), /* dining philosopher threads, named for the LEDs they used to trigger, before I (David Eisenstat) figured out that they were causing the keyboard controller to choke */ TH(&num), TH(&caps), TH(&scroll_th), /* barrier test threads */ TH(&barrier1), TH(&barrier2), TH(&barrier3), /* plane process */ PROC(PROC1_ADDR), /* calculation process */ PROC(PROC2_ADDR) }; enum { NUM_TASKS = sizeof task / sizeof(struct task_info) };
/* tasks.c: the list of threads and processes to run (DO NOT CHANGE) */ #include "scheduler.h" #include "th.h" struct task_info task[] = { TH(&noop_thread1), PROC(PROC1_ADDR), }; enum { NUM_TASKS = sizeof task / sizeof(struct task_info) };