add printChipInfo()
This commit is contained in:
		
							parent
							
								
									44bcd1c895
								
							
						
					
					
						commit
						c1dc21a3ba
					
				
							
								
								
									
										50
									
								
								index.html
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								index.html
									
									
									
									
									
								
							| @ -4,10 +4,8 @@ | |||||||
|     <title>MBC Bootjes</title> |     <title>MBC Bootjes</title> | ||||||
|     <meta name="viewport" content="user-scalable=no"> |     <meta name="viewport" content="user-scalable=no"> | ||||||
| </head> | </head> | ||||||
| <body  style="position: fixed; font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif ; | <body style="position:fixed;margin:0;font-family:'GillSans','GillSansMT',Calibri,'TrebuchetMS',sans-serif;color:rgb(128,128,128);font-size:xx-large;"> | ||||||
| color:rgb(128, 128, 128); |     <h1 style="text-align:center;width:100vw">MBC Het Groote Dok</h1> | ||||||
| font-size: xx-large;"> |  | ||||||
|     <h1 style="text-align:center">MBC Het Groote Dok</h1> |  | ||||||
|     <div id="boats"></div> |     <div id="boats"></div> | ||||||
|     <canvas id="canvas" name="game" style="display:none"></canvas> |     <canvas id="canvas" name="game" style="display:none"></canvas> | ||||||
|     <div id="clientId"></div> |     <div id="clientId"></div> | ||||||
| @ -81,9 +79,8 @@ font-size: xx-large;"> | |||||||
|             boatListEl.style.display  = 'none'; |             boatListEl.style.display  = 'none'; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         function send(x,y,speed,angle){ |         function send(x,y,angle){ | ||||||
|             var data = clientId + ";d;" + x.toString() + "," + y.toString(); //{"x":x,"y":y,"speed":speed,"angle":angle}; |             var data = clientId + ";d;" + x.toString() + "," + y.toString(); | ||||||
|             //data = JSON.stringify(data); |  | ||||||
|             connection.send(data); |             connection.send(data); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -95,7 +92,7 @@ font-size: xx-large;"> | |||||||
|         window.addEventListener('load', () => { |         window.addEventListener('load', () => { | ||||||
| 
 | 
 | ||||||
|             canvas = document.getElementById('canvas'); |             canvas = document.getElementById('canvas'); | ||||||
|             ctx = canvas.getContext('2d');           |             ctx = canvas.getContext('2d'); | ||||||
|             resize();  |             resize();  | ||||||
| 
 | 
 | ||||||
|             document.addEventListener('mousedown', startDrawing); |             document.addEventListener('mousedown', startDrawing); | ||||||
| @ -116,16 +113,16 @@ font-size: xx-large;"> | |||||||
|         function resize() { |         function resize() { | ||||||
|             width = window.innerWidth; |             width = window.innerWidth; | ||||||
|             radius = 200; |             radius = 200; | ||||||
|             height = radius * 6.5; |             height = radius * 4.5; | ||||||
|             ctx.canvas.width = width; |             ctx.canvas.width = width; | ||||||
|             ctx.canvas.height = height; |             ctx.canvas.height = height; | ||||||
|             background(); |             background(); | ||||||
|             joystick(width / 2, height / 3); |             joystick(width / 2, height / 2); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         function background() { |         function background() { | ||||||
|             x_orig = width / 2; |             x_orig = width / 2; | ||||||
|             y_orig = height / 3; |             y_orig = height / 2; | ||||||
| 
 | 
 | ||||||
|             ctx.beginPath(); |             ctx.beginPath(); | ||||||
|             ctx.arc(x_orig, y_orig, radius + 20, 0, Math.PI * 2, true); |             ctx.arc(x_orig, y_orig, radius + 20, 0, Math.PI * 2, true); | ||||||
| @ -176,45 +173,30 @@ font-size: xx-large;"> | |||||||
|             paint = false; |             paint = false; | ||||||
|             ctx.clearRect(0, 0, canvas.width, canvas.height); |             ctx.clearRect(0, 0, canvas.width, canvas.height); | ||||||
|             background(); |             background(); | ||||||
|             joystick(width / 2, height / 3); |             joystick(width / 2, height / 2); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         function Draw(event) { |         function Draw(event) { | ||||||
| 
 | 
 | ||||||
|             if (paint) { |             if (paint) { | ||||||
|  |                 getPosition(event); | ||||||
|                 ctx.clearRect(0, 0, canvas.width, canvas.height); |                 ctx.clearRect(0, 0, canvas.width, canvas.height); | ||||||
|                 background(); |                 background(); | ||||||
|                 var angle_in_degrees,x, y, speed; |                 var angle_in_degrees, x, y, speed; | ||||||
|                 var angle = Math.atan2((coord.y - y_orig), (coord.x - x_orig)); |                 var angle = Math.atan2((coord.y - y_orig), (coord.x - x_orig)); | ||||||
| 
 | 
 | ||||||
|                 if (Math.sign(angle) == -1) { |                 if (Math.sign(angle) == -1) { | ||||||
|                     angle_in_degrees = Math.round(-angle * 180 / Math.PI); |                     angle_in_degrees = Math.round(-angle * 180 / Math.PI); | ||||||
|                 } |                 } | ||||||
|                 else { |                 else { | ||||||
|                     angle_in_degrees =Math.round( 360 - angle * 180 / Math.PI); |                     angle_in_degrees = Math.round(360 - angle * 180 / Math.PI); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|  |                 x = Math.max(-radius, Math.min(radius, coord.x - x_orig)); | ||||||
|  |                 y = Math.max(-radius, Math.min(radius, coord.y - y_orig)); | ||||||
|  |                 joystick(x + x_orig, y + y_orig); | ||||||
| 
 | 
 | ||||||
|                 if (is_it_in_the_circle()) { |                 send(x, y, angle_in_degrees); | ||||||
|                     joystick(coord.x, coord.y); |  | ||||||
|                     x = coord.x; |  | ||||||
|                     y = coord.y; |  | ||||||
|                 } |  | ||||||
|                 else { |  | ||||||
|                     x = radius * Math.cos(angle) + x_orig; |  | ||||||
|                     y = radius * Math.sin(angle) + y_orig; |  | ||||||
|                     joystick(x, y); |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|              |  | ||||||
|                 getPosition(event); |  | ||||||
| 
 |  | ||||||
|                 var speed =  Math.round(100 * Math.sqrt(Math.pow(x - x_orig, 2) + Math.pow(y - y_orig, 2)) / radius); |  | ||||||
| 
 |  | ||||||
|                 var x_relative = Math.round(x - x_orig); |  | ||||||
|                 var y_relative = Math.round(y - y_orig); |  | ||||||
| 
 |  | ||||||
|                 send( x_relative,y_relative,speed,angle_in_degrees); |  | ||||||
|             } |             } | ||||||
|         }  |         }  | ||||||
|     </script> |     </script> | ||||||
|  | |||||||
| @ -82,6 +82,8 @@ void app_main() { | |||||||
| 		ret = nvs_flash_init(); | 		ret = nvs_flash_init(); | ||||||
| 	} | 	} | ||||||
| 	ESP_ERROR_CHECK(ret); | 	ESP_ERROR_CHECK(ret); | ||||||
|  | 
 | ||||||
|  | 	printChipInfo(); | ||||||
| 	 | 	 | ||||||
| 	s_wifi_event_group = xEventGroupCreate(); | 	s_wifi_event_group = xEventGroupCreate(); | ||||||
| 
 | 
 | ||||||
| @ -144,6 +146,12 @@ void app_main() { | |||||||
| 		ESP_LOGE(TAG, "UNEXPECTED EVENT"); | 		ESP_LOGE(TAG, "UNEXPECTED EVENT"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	while(true) | ||||||
|  | 	{ | ||||||
|  | 		ESP_LOGI(TAG, ":3"); | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	// running = true;
 | 	// running = true;
 | ||||||
| 
 | 
 | ||||||
| 	// cmdList = getCMDList();
 | 	// cmdList = getCMDList();
 | ||||||
|  | |||||||
| @ -3,10 +3,15 @@ | |||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| 
 | 
 | ||||||
|  | #include "esp_system.h" | ||||||
|  | #include "esp_chip_info.h" | ||||||
|  | #include "esp_flash.h" | ||||||
|  | 
 | ||||||
| char* getNextArg(char* args) | char* getNextArg(char* args) | ||||||
| { | { | ||||||
| 	uint8_t step = 0; | 	uint8_t step = 0; | ||||||
| 	int end = 0; | 	uint8_t end = 0; | ||||||
|  | 	// find next argument separator
 | ||||||
| 	while (end == 0) | 	while (end == 0) | ||||||
| 	{ | 	{ | ||||||
| 		if (step < 255) | 		if (step < 255) | ||||||
| @ -15,10 +20,12 @@ char* getNextArg(char* args) | |||||||
| 			{ | 			{ | ||||||
| 				case ';': | 				case ';': | ||||||
| 					end = 1; // found
 | 					end = 1; // found
 | ||||||
|  | 					break; | ||||||
| 				case '\n': | 				case '\n': | ||||||
| 				case '\r': | 				case '\r': | ||||||
| 				case '\0': | 				case '\0': | ||||||
| 					end = 2; // end of line
 | 					end = 2; // end of line
 | ||||||
|  | 					break; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		else  | 		else  | ||||||
| @ -28,12 +35,73 @@ char* getNextArg(char* args) | |||||||
| 		step++; | 		step++; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (end != 3) | 	if (end == 1) | ||||||
| 	{ | 	{ // argument separator found
 | ||||||
| 		return args + step; | 		end = 0; | ||||||
|  | 		// find first char of argument
 | ||||||
|  | 		while (end == 0) | ||||||
|  | 		{ | ||||||
|  | 			step++; | ||||||
|  | 			if (step < 255) | ||||||
|  | 			{ | ||||||
|  | 				switch (*(args + step)) | ||||||
|  | 				{ | ||||||
|  | 					case ';': | ||||||
|  | 					case '\n': | ||||||
|  | 					case '\r': | ||||||
|  | 					case '\0': | ||||||
|  | 						break; | ||||||
|  | 					default: | ||||||
|  | 						end = 1; | ||||||
|  | 						break; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			else  | ||||||
|  | 			{ | ||||||
|  | 				end = 3; // line to long
 | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if (end == 1) | ||||||
|  | 		{ // start of next argument found
 | ||||||
|  | 			return args + step; | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ // no new argument found
 | ||||||
|  | 			return NULL; | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 	else  | 	else  | ||||||
| 	{ | 	{ // is was the last argument (or the arguments is longer then 254 bytes)
 | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | void printChipInfo() | ||||||
|  | { | ||||||
|  | 	esp_chip_info_t chip_info; | ||||||
|  | 	uint32_t flash_size; | ||||||
|  | 	esp_chip_info(&chip_info); | ||||||
|  | 	printf("This is %s chip with %d CPU core(s), %s%s%s%s, ", | ||||||
|  | 		CONFIG_IDF_TARGET, | ||||||
|  | 		chip_info.cores, | ||||||
|  | 		(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "", | ||||||
|  | 		(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "", | ||||||
|  | 		(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "", | ||||||
|  | 		(chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "" | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
|  | 	unsigned major_rev = chip_info.revision / 100; | ||||||
|  | 	unsigned minor_rev = chip_info.revision % 100; | ||||||
|  | 	printf("silicon revision v%d.%d, ", major_rev, minor_rev); | ||||||
|  | 	if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) { | ||||||
|  | 		printf("Get flash size failed"); | ||||||
|  | 		return; | ||||||
|  | 	}     | ||||||
|  | 	 | ||||||
|  | 	printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024), | ||||||
|  | 		(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external" | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
|  | 	printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size()); | ||||||
|  | } | ||||||
|  | |||||||
| @ -2,5 +2,6 @@ | |||||||
| #define UTILS_H | #define UTILS_H | ||||||
| 
 | 
 | ||||||
| char* getNextArg(char* args); | char* getNextArg(char* args); | ||||||
|  | void printChipInfo(); | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user