ESP32TensorFlowLiteSample/src/main.cpp
// Logic loop for taking user input and outputting the sine
Logic loop for taking user input and outputting the sine
Logic loop for taking user input and outputting the sine
void loop() { 
	if(Serial.available() > 0) {
    	float user_input = Serial.parseFloat();
		if(user_input < 0.0f || user_input > (float)(2*M_PI)) {
			Serial.println("Your number must be greater than 0 and less than 2*PI");
			return;
		}
    	input->data.f[0] = user_input;
    	Serial.println("Running inference on inputted data...");
    	if(interpreter->Invoke() != kTfLiteOk) {
    		Serial.println("There was an error invoking the interpreter!");
    		return;
    	}
    	Serial.print("Input: ");
    	Serial.println(user_input);
    	Serial.print("Output: ");
    	Serial.println(output->data.f[0]);
    	Serial.println("");
    }
}
void loop ( ) { if ( Serial . available ( ) > 0 ) { float user_input = Serial . parseFloat ( ) ; if ( user_input < 0.0f || user_input > ( float ) ( 2 * M_PI ) ) { Serial . println ( " " ) ; return ; } input -> data . f [ 0 ] = user_input ; Serial . println ( " " ) ; if ( interpreter -> Invoke ( ) != kTfLiteOk ) { Serial . println ( " " ) ; return ; } Serial . print ( " " ) ; Serial . println ( user_input ) ; Serial . print ( " " ) ; Serial . println ( output -> data . f [ 0 ] ) ; Serial . println ( " " ) ; } }
Logic loop for taking user input and outputting the sine
Logic loop for taking user input and outputting the sine
// Wait for serial input to be made available and parse it as a float /* The sample model is only trained for values between 0 and 2*PI
    	 * This will keep the user from inputting bad numbers. 
    	 */ // Set the input node to the user input // Run inference on the input data // Print the output of the model.