![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
IOTIO
Dependencies: Nucleo_BLE_API_IOTIO Nucleo_BLE_BlueNRG Nucleo_BLE_DemoApp Nucleo_Sensor_Shield mbed
Dependents: Nucleo_BLE_Demo_IOTIO
Fork of Nucleo_BLE_Demo by
Diff: main.cpp
- Revision:
- 0:d450c9945f96
- Child:
- 1:4bdfa7d7e8bf
diff -r 000000000000 -r d450c9945f96 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 27 18:59:24 2015 +0000 @@ -0,0 +1,51 @@ +/* Bluetooth low energy demo application + * Copyright (c) 2015 Adam Berlinger + * + * 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 "DemoAppService.h" + + +extern bool user_button_pressed; +bool connected = false; +bool UpdatedEnabled = false; + +DemoAppService *demoService; +PwmOut led(LED1); + +void demoCallback(uint8_t event){ + /* Nastaveni stridy PWM signalu */ + if(event & DemoAppService::EVENT_SLIDER1_CHANGED){ + int x = 1 << (demoService->getSlider1Value() / 10); + led.write((float)(x / (float)(1 << 10))); + } + /* Nastaveni periody PWM signalu */ + if(event & DemoAppService::EVENT_SLIDER2_CHANGED){ + led.period(1.0f / (demoService->getSlider2Value() + 1)); + } +} + +int main(void) +{ + demoService = startDemoBLE("Demo App"); + demoService->setCallback(demoCallback); + + led = 0.0f; + + while (true) + { + demoService->waitForEvent(); + } +}