Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
HTTPScriptTiltAngle.cpp
00001 /* 00002 * HTTPScriptTiltAngle.cpp 00003 * Copyright (c) 2020, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 #include "HTTPScriptTiltAngle.h" 00008 00009 using namespace std; 00010 00011 inline string float2String(float f) { 00012 00013 char buffer[32]; 00014 sprintf(buffer, "%.3f", f); 00015 00016 return string(buffer); 00017 } 00018 00019 /** 00020 * Create and initialize this http script. 00021 * @param tiltAngle a reference to the tiltAngle objetct to read data from. 00022 */ 00023 HTTPScriptTiltAngle::HTTPScriptTiltAngle(TiltAngle& tiltAngle) : tiltAngle(tiltAngle) {} 00024 00025 HTTPScriptTiltAngle::~HTTPScriptTiltAngle() {} 00026 00027 /** 00028 * This method gets called by the http server, when an object of this class is 00029 * registered with the server, and the corresponding script is called 00030 * by an http client. 00031 */ 00032 string HTTPScriptTiltAngle::call(vector<string> names, vector<string> values) { 00033 00034 string response; 00035 00036 response += " <tiltAngle>\r\n"; 00037 response += " <a><float>"+float2String(tiltAngle.readTiltAngleA())+"</float></a>\r\n"; 00038 response += " <g><float>"+float2String(tiltAngle.readTiltAngleG())+"</float></g>\r\n"; 00039 response += " <k><float>"+float2String(tiltAngle.readTiltAngleK())+"</float></k>\r\n"; 00040 response += " <c><float>"+float2String(tiltAngle.readTiltAngleC())+"</float></c>\r\n"; 00041 response += " </tiltAngle>\r\n"; 00042 00043 return response; 00044 } 00045
Generated on Fri Jul 29 2022 01:28:48 by
1.7.2