controller work with pad, color picker

has issue with stream sensor data
This commit is contained in:
hathach committed 2017-01-09 17:15:46 +07:00
1 parent 7b77fe8595
commit 7ffc7c717b
3 files changed
+51 -16

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
/**************************************************************************/
/*!
@file rtos.c
@author hathach
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2017, Adafruit Industries (adafruit.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**************************************************************************/
#include "Arduino.h"
void yield(void)
{
taskYIELD();
}
@@ -17,7 +17,7 @@
BLEUart bleuart;
// function prototypes over in packetparser.cpp
uint8_t readPacket(Adafruit_BLE *ble, uint16_t timeout);
uint8_t readPacket(BLEUart *ble_uart, uint16_t timeout);
float parsefloat(uint8_t *buffer);
void printHex(const uint8_t * data, const uint32_t numBytes);
@@ -34,11 +34,11 @@ extern uint8_t packetbuffer[];
void setup(void)
{
Serial.begin(115200);
Serial.println(F("Adafruit Bluefruit App Controller Example"));
Serial.println(F("-----------------------------------------"));
Serial.println(F("Adafruit Bluefruit52 App Controller Example"));
Serial.println(F("-------------------------------------------"));
Bluefruit.begin();
Bluefruit.setName("Bluefruit");
Bluefruit.setName("Bluefruit52");
// Configure and Start BLE Uart Service
bleuart.start();
@@ -72,7 +72,7 @@ void setupAdv(void)
void loop(void)
{
/* Wait for new data to arrive */
uint8_t len = readPacket(&ble, BLE_READPACKET_TIMEOUT);
uint8_t len = readPacket(&bleuart, 500);
if (len == 0) return;
/* Got a packet! */
@@ -1,13 +1,6 @@
#include <string.h>
#include <Arduino.h>
#include <SPI.h>
#if not defined (_VARIANT_ARDUINO_DUE_X_) && not defined (_VARIANT_ARDUINO_ZERO_)
#include <SoftwareSerial.h>
#endif
#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"
#include <bluefruit.h>
#define PACKET_ACC_LEN (15)
@@ -74,7 +67,7 @@ void printHex(const uint8_t * data, const uint32_t numBytes)
@brief Waits for incoming data and parses it
*/
/**************************************************************************/
uint8_t readPacket(Adafruit_BLE *ble, uint16_t timeout)
uint8_t readPacket(BLEUart *ble_uart, uint16_t timeout)
{
uint16_t origtimeout = timeout, replyidx = 0;
@@ -97,8 +90,8 @@ uint8_t readPacket(Adafruit_BLE *ble, uint16_t timeout)
if ((packetbuffer[1] == 'L') && (replyidx == PACKET_LOCATION_LEN))
break;
while (ble->available()) {
char c = ble->read();
while (ble_uart->available()) {
char c = ble_uart->read();
if (c == '!') {
replyidx = 0;
}