int main(void) { user_tests(); queue_tests(); user_t user1 = user_new(1); user_t user2 = user_new(2); queue_t pQueue = queue_new(); clock_t start; fflush(stdout); char c = 'f'; while(c != '-') { start = clock(); while(clock() - start < CLOCKS_PER_SEC/30) { user_checkComm(user1, user2, pQueue); } queue_print(pQueue); printf("\n"); queue_countNull(pQueue); c = getch(); } user_delete(user1); user_delete(user2); queue_delete(pQueue); return 0; }
user_tasks() { char buffer[260]; int argc; char *argv[10]; if(kbhiteol(0)) /// second argument 1 = only report when an EOL is detectedEOL { fgets(buffer,255,stdin); printf("Command:[%s]\n",buffer); argc = split_args(buffer, argv, 10); if(!user_tests(argc,argv)) printf("unknown command:[%s]\n", buffer); } }
/** @brief test task Runs corrected cube demo from Sem Optionally wireframe Earh viewer @return void */ LOCAL void user_task(void) { uint32_t time1,time2; uint8_t red, blue,green; long timer = 0; uint16 system_adc_read(void); extern uint8_t ip_msg[]; time_t sec; char buffer[256]; #ifdef WIRECUBE V.x = degree; V.y = degree; V.z = degree; // Cube points were defined with sides of 1.0 // We want a scale of +/- w/2 wire_draw(windemo, cube_points, cube_edges, &V, windemo->w/2, windemo->h/2, dscale, 0); //wire_draw(windemo, cube_points, cube_edges, &V, windemo->w/2, windemo->h/2, dscale, 0); #endif #ifdef CIRCLE rad = dscale; // +/- 90 tft_drawCircle(windemo, windemo->w/2, windemo->h/2, rad ,0); Display bounding circle that changes color around the cube if(dscale_inc < 0.0) { red = 255; blue = 0; green = 0; } else { red = 0; blue = 255; green = 0; } // RGB - YELLOW tft_drawCircle(windemo, windemo->w/2, windemo->h/2, dscale, tft_color565(red,green,blue)); #endif degree += deg_inc; dscale += dscale_inc; if(degree <= -360) deg_inc = 4; if(degree >= 360) deg_inc = -4; if(dscale < dscale_max/2) { dscale_inc = -dscale_inc; } if(dscale > dscale_max) { dscale_inc = -dscale_inc; } #ifdef WIRECUBE V.x = degree; V.y = degree; V.z = degree; //time1 = system_get_time(); wire_draw(windemo, cube_points, cube_edges, &V, windemo->w/2, windemo->h/2, dscale, ILI9341_WHITE); //wire_draw(windemo, cube_points, cube_edges, &V, windemo->w/2, windemo->h/2, dscale, ILI9341_WHITE); //time2 = system_get_time(); #endif // Get system voltage 33 = 3.3 volts adc_sum += system_adc_read(); //adc_sum += system_get_vdd33(); // FIXME atomic access if(++adc_count == 10) { voltage = ((double) adc_sum / 100.0); adc_count = 0; adc_sum = 0; } // DEBUG_PRINTF("Degree: %d \r\n",(int)degree); // cube redraw count count += 1; tft_set_font(winstats,0); tft_setpos(winstats,ip_xpos,ip_ypos); tft_printf(winstats,"%-26s\n", ip_msg); if(!signal_loop--) { signal_loop = 100; tft_printf(winstats,"CH:%02d, DB:-%02d\n", wifi_get_channel(), wifi_station_get_rssi()); signal_loop = 0; } tft_setpos(winstats,xpos,ypos); tft_printf(winstats,"Heap: %d\n", system_get_free_heap_size()); tft_printf(winstats,"Iter:% 9ld, %+7.2f\n", count, degree); // NTP state machine ntp_setup(); // get current time time(&sec); tft_printf(winstats,"Volt:%2.2f\n%s\n", (float)voltage, ctime(&sec)); #ifdef NETWORK_TEST poll_network_message(wintest); #endif // Buffered get line uses interrupts and queues if(uart0_gets(buffer,255)) { DEBUG_PRINTF("Command:%s\n",buffer); if(!fatfs_tests(buffer)) { if(!user_tests(buffer)) { DEBUG_PRINTF("unknow command: %s\n", buffer); } } } }