BLE Accel
Dependencies: BLE_API MMA8452Q mbed nRF51822
Fork of AAAatest_copy by
Diff: main.cpp
- Revision:
- 3:7dc284221369
- Parent:
- 2:e78a5ce9f1d7
diff -r e78a5ce9f1d7 -r 7dc284221369 main.cpp --- a/main.cpp Sun Apr 10 17:47:09 2016 +0000 +++ b/main.cpp Sun Apr 10 19:05:36 2016 +0000 @@ -1,47 +1,34 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - #include "mbed.h" #include "ble/BLE.h" #include "MMA8452Q.h" #include "Service.h" -MMA8452Q accel(P0_0, P0_1, 0x1D); +MMA8452Q accel(P0_0, P0_1, 0x1D); //deklaracja obiektu akcelerometru (P0_0 -> SDA, P0_1 -> SCL, 0x1D -> ID urzadzenia) Ticker ticker; -float x,y,z; +float x,y,z; //zmienne do których przypisywane są wartosci odczytu x y z z akcelerometru -const static char DEVICE_NAME[] = "BLE_Accel"; +const static char DEVICE_NAME[] = "BLE_Accel"; static const uint16_t uuid16_list[] = {Service::SERVICE_UUID}; static Service *ServicePtr; -void f(){ - //printf("cykabliat\n"); +void f(){ + /* + * Odczyt x y z + */ + x=accel.readX(); + y=accel.readY(); + z=accel.readZ(); - x=accel.readX(); - y=accel.readY(); - z=accel.readZ(); - - ServicePtr->updateXState(x); - ServicePtr->updateYState(y); - ServicePtr->updateZState(z); - ServicePtr->updateALLState(x,y,z); - printf("%f;%f;%f; \r\n",x,y,z); - } + /* + * Update wartosci w charakterystykach x y z i all + */ + ServicePtr->updateXState(x); + ServicePtr->updateYState(y); + ServicePtr->updateZState(z); + ServicePtr->updateALLState(x,y,z); +} void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)