Javascript wrappers for LSM6DSL Sensor library

Dependencies:   LSM6DSL

Dependents:   ST_SENSOR_JS

Revision:
1:7e5e76bf3efe
Parent:
0:7eb29414734d
Child:
3:87ac9fb0d287
--- a/LSM6DSL_JS.cpp	Tue Oct 10 11:52:24 2017 +0200
+++ b/LSM6DSL_JS.cpp	Wed Oct 11 10:11:19 2017 +0200
@@ -154,16 +154,15 @@
  * @retval Accleremeter value in JSON string form
  */
 
-unsigned char *LSM6DSL_JS::get_accelerometer_axes_json(){
+char *LSM6DSL_JS::get_accelerometer_axes_json(char *data){
 	int32_t axes[3];
   	acc_gyro->get_x_axes(axes);
     //printf("LSM6DSL [acc/mg]:        %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]);
 	
 	char axes_labels[3] = {'x', 'y', 'z'};
-	char *data = new char[128];
 	make_json(data, axes, axes_labels, 3);
 	
-	return (unsigned char *)data;
+	return data;
 }
 
 
@@ -182,14 +181,13 @@
  * @brief  Get the gyroscope reading from LSM6DSL
  * @retval Gyroscope value
  */
-unsigned char *LSM6DSL_JS::get_gyroscope_axes_json(){
+char *LSM6DSL_JS::get_gyroscope_axes_json(char * data){
 	int32_t axes[3];
     acc_gyro->get_g_axes(axes);
     //printf("LSM6DSL [gyro/mdps]:     %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]);
     
 	char axes_labels[3] = {'x', 'y', 'z'};
-	char *data = new char[128];
 	make_json(data, axes, axes_labels, 3);
 	
-	return (unsigned char *)data;
+	return data;
 }