/** @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); } } } }
/// @param[in] str: User supplied command line /// /// @return 1 The return code indicates a command matched. /// @return 0 if no rules matched MEMSPACE int user_tests(int argc, char *argv[]) { char *ptr; time_t t; double freq; extern int connections; int ind; if(argc < 2) return(0); ind = 1; ptr = argv[ind++]; if (MATCHARGS(ptr,"help", (ind+0),argc )) { user_help(); return(1); } #ifdef POSIX_TESTS if(posix_tests(argc,argv)) return(1); #endif #ifdef FATFS_TESTS if(fatfs_tests(argc,argv)) return(1); #endif #ifdef ADF4351 if (MATCHARGS(ptr,"adf4351", (ind + 1) ,argc)) { adf4351_cmd(argc,argv); return(1); } #endif if (MATCHARGS(ptr,"setdate", (ind + 1) ,argc)) { setdate_r(argv[ind++]); return(1); } if (MATCHARGS(ptr,"display_clock", (ind + 0) ,argc)) { display_clock(); return(1); } if (MATCHARGS(ptr,"time", (ind + 0) ,argc)) { t = time(0); printf("TIME:%s\n", ctime(&t)); return(1); } if (MATCHARGS(ptr,"connection", (ind + 0) ,argc)) { printf("connections:%d\n", connections); return(1); } if (MATCHARGS(ptr,"mem", (ind + 0) ,argc)) { PrintRam(); return(1); } if (MATCHARGS(ptr,"timetest", (ind + 1) ,argc)) { timetests(argv[ind++],0); return(1); } #ifdef DISPLAY if (MATCHARGS(ptr,"calibrate", (ind + 1) ,argc)) { int ret = atoi(argv[ind++]); tft_setRotation(ret); tft_touch_calibrate(master); MatWrite("/tft_calX",tft_calX); MatWrite("/tft_calY",tft_calY); setup_windows(ret & 3,0); return(1); } if (MATCHARGS(ptr,"calibrate_test", (ind + 1) ,argc)) { int ret = atoi(argv[ind++]); tft_setRotation(ret); tft_touch_calibrate(master); MatWrite("/tft_calX",tft_calX); MatWrite("/tft_calY",tft_calY); tft_map_test(master, 10); setup_windows(ret & 3,0); return(1); } if (MATCHARGS(ptr,"rotate", (ind + 1) ,argc)) { // FIXME rotate calibration data ??? int ret = atoi(argv[ind++]); tft_setRotation(ret); setup_windows(ret & 3,0); return(1); } #ifdef VFONTS if (MATCHARGS(ptr,"draw", (ind + 1) ,argc)) { char *ptr = argv[ind++]; int c = *ptr++; int n = *ptr++; if( n == '1') drawSVG(winmsg, 8, 24, c, 0.08, ILI9341_WHITE, 1); else drawSVG(winmsg, 8, 24, c, 0.08, ILI9341_WHITE, 0); return(1); } #endif if (MATCHARGS(ptr,"pixel", (ind + 0) ,argc)) { int c; int x,y; tft_drawPixel(winmsg, 8, 24, ILI9341_WHITE); for(y=24;y<26;++y) { for(x=8;x<10;++x) { c = tft_readPixel(winmsg, x, y); printf("pixel(%d,%d): %04x\n", x,y,c); } } return(1); } #endif //DISPLAY return(0); }