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.
Fork of rbVectorIQ by
Revision 16:4fca60460b7e, committed 2017-06-19
- Comitter:
- MarkSPA
- Date:
- Mon Jun 19 18:12:42 2017 +0000
- Parent:
- 14:459081f9f70b
- Child:
- 17:123883bbf391
- Commit message:
- Initial commit
Changed in this revision
--- a/BLE_API.lib Wed Apr 19 21:20:31 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#66159681aa21
Binary file img/connection.png has changed
Binary file img/discovery.png has changed
Binary file img/notifications.png has changed
Binary file img/register_to_notifications.png has changed
Binary file img/scan_result.png has changed
Binary file img/start_scan.png has changed
--- a/main.cpp Wed Apr 19 21:20:31 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,395 +0,0 @@
-/*
-
-Copyright (c) 2017 Radiant RVA
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-and associated documentation files (the "Software"), to deal in the Software without restriction,
-including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
-FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-#include "vector_iq.h"
-
-
-void connectionCallback(const Gap::ConnectionCallbackParams_t *params)
-{
- neopixel_init(&m_strip, dig_pin_num, NUM_LEDS);
- neopixel_clear(&m_strip);
- LEDS_ON_FLAG = 0;
-}
-
-void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
-{
- //pc.printf("Disconnected \r\n");
- //pc.printf("Restart advertising \r\n");
- //clear and remove strip
- //neopixel_clear(&m_strip);
- //neopixel_destroy(&m_strip);
- //strcpy(mDeviceName, "RRVA Cntd");
- //setup_advertising();
- BLE::Instance(BLE::DEFAULT_INSTANCE).gap().startAdvertising(); // restart advertising
- //ble.startAdvertising();
-}
-
-void WrittenHandler(const GattWriteCallbackParams *Handler)
-{
- uint8_t buf[TXRX_BUF_LEN];
- uint16_t bytesRead;
-
- if (Handler->handle == txCharacteristic.getValueAttribute().getHandle()) {
- ble.readCharacteristicValue(txCharacteristic.getValueAttribute().getHandle(), buf, &bytesRead);
- memset(txPayload, 0, TXRX_BUF_LEN);
- memcpy(txPayload, buf, TXRX_BUF_LEN);
-
- //for(index=0; index<bytesRead; index++)
- //pc.putc(buf[index]);
-
- if(buf[0] == ONOFF_HEADER) {
- //pc.printf("LED value received \r\n");
- if(buf[1] == LEDS_ON) {
- LEDS_ON_FLAG = 1;
- } else if(buf[1] == LEDS_OFF) {
- LEDS_ON_FLAG = 0;
- neopixel_init(&m_strip, dig_pin_num, NUM_LEDS);
- neopixel_clear(&m_strip);
- }
- } else if(buf[0] == COLOR_HEADER) {
- red = buf[1];
- green = buf[2];
- blue = buf[3];
- pattern = buf[5];
- } else if(buf[0] == PIEZO_HEADER) {
- mPiezoOn = buf[1];
- //mPiezoDur = buf[2];
- mPiezoPattern = buf[2];
- } else if(buf[0] == HAPTIC_HEADER) {
- mHapticOn = buf[1];
- mHapticDur = buf[2];
- mHapticPattern = buf[3];
- } else if(buf[0] == ALARM_HEADER) {
- mAlarmOn = buf[1];
- //mAlarmStart = buf[2];
- mAlarmDur = buf[2];
- mAlarmPiezoOn = buf[4];
- mAlarmTone = buf[5];
- mAlarmPattern = buf[6];
- pattern = mAlarmPattern;
- if (mAlarmOn == ALARM_ON) {
- // Setup the timer
- t_alarm.start();
- mBeginAlarm = t_alarm.read();
- mEndAlarm = mBeginAlarm + mAlarmDur;
- mPiezoOn = mAlarmPiezoOn;
- LEDS_ON_FLAG = 1;
- } else if (mAlarmOn == ALARM_OFF) {
- // Stop the timer
- t_alarm.stop();
- // Kill all the effects
- mHapticOn = HAPTIC_OFF;
- mPiezoOn = PIEZO_OFF;
- LEDS_ON_FLAG = 0;
- }
- }
- else
- {
- LEDS_ON_FLAG = 1;
- red = buf[1];
- green = buf[2];
- blue = buf[3];
- pattern = buf[5];
- }
- }
-}
-
-// pb Interrupt routine - is interrupt activated by a falling edge of pb input
-void pb_hit_interrupt (void) {
- pattern++;
- if (pattern >= PATTERN_MEM)
- pattern = PATTERN_ON;
-}
-
-void m_status_check_handle(void)
-{
- //uint8_t buf[3];
-
- //if (BUTTON == 1) {
- // Cycle through display patterns
- pattern++;
- if (pattern >= PATTERN_MEM)
- pattern = PATTERN_NONE;
- //}
-
- /* if (BUTTON == 1)
- LEDS_ON_FLAG = 0;
- else if (BUTTON == 0)
- LEDS_ON_FLAG = 1; */
-
- /*if (BUTTON != old_state) {
- old_state = BUTTON;
- if (LEDS_ON_FLAG)
- LEDS_ON_FLAG = 0;
- else
- LEDS_ON_FLAG = 1;
-
- if (BUTTON == 1) {
- buf[0] = (0x0A);
- buf[1] = (0x01);
- buf[2] = (0x00);
- ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 3);
- } else {
- buf[0] = (0x0A);
- buf[1] = (0x00);
- buf[2] = (0x00);
- ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 3);
- }
- } */
-}
-
-void ble_on_radio_active_evt(bool radio_active)
-{
- if (radio_active == false) {
- if (mAlarmOn == ALARM_ON) {
- if (t_alarm.read() > mEndAlarm) {
- // end alarm
- t_alarm.stop();
- mHapticOn = HAPTIC_OFF;
- mPiezoOn = PIEZO_OFF;
- LEDS_ON_FLAG = 0;
- }
- }
- if (mHapticOn == HAPTIC_ON) {
- BUZZER = 1;
- wait_ms(1000);
- } else {
- BUZZER = 0;
- //wait_ms(1000);
- }
- if (mPiezoOn == PIEZO_ON) {
- for (int i = 0; i < (sizeof(freq_coll) / sizeof(int)); i++) {
- // Keep checking for an "Off"
- //if (mPiezoOn == PIEZO_OFF)
- //break;
- PIEZO.period(1.0 / freq_coll[i]);
- PIEZO.write(0.9);
- wait(1.0 / beat_coll[i]);
- PIEZO.write(0);
- wait(0.05);
- }
- wait_ms(500);
- }
- if (LEDS_ON_FLAG == 1) {
- if (pattern == PATTERN_ON) {
- for (uint8_t i = 0; i <= NUM_LEDS; i++)
- neopixel_set_color(&m_strip, i, red, green, blue);
- neopixel_show(&m_strip);
-
- } else if (pattern == PATTERN_FAST) {
- //neopixel_clear(&m_strip);
- for (uint8_t i = 0; i <= NUM_LEDS; i++)
- neopixel_set_color(&m_strip, i, 0, 0, 0);
- if (led_to_enable > NUM_LEDS)
- led_to_enable = 0;
- neopixel_set_color(&m_strip, led_to_enable, red, green, blue);
- neopixel_show(&m_strip);
- led_to_enable++;
- } else if (pattern == PATTERN_SLOW) {
- for (uint8_t i = 0; i <= NUM_LEDS; i++)
- neopixel_set_color(&m_strip, i, 0, 0, 0);
- if (led_to_enable > NUM_LEDS)
- led_to_enable = 0;
- neopixel_set_color(&m_strip, led_to_enable, red, green, blue);
- neopixel_show(&m_strip);
- led_to_enable++;
- wait_ms(1000);
-
- } else if (pattern == PATTERN_CHASE) {
- for (uint8_t i = 0; i <= NUM_LEDS; i++)
- neopixel_set_color(&m_strip, i, 0, 0, 0);
- if (led_to_enable > NUM_LEDS)
- led_to_enable = 0;
- for (uint8_t i = 0; i <= NUM_LEDS; i++)
- neopixel_set_color(&m_strip, led_to_enable, red, green, blue);
- neopixel_show(&m_strip);
- led_to_enable++;
- wait_ms(100);
-
- } else if (pattern == PATTERN_MRB) {
- //neopixel_clear(&m_strip);
- for (uint8_t i = 0; i <= NUM_LEDS; i++)
- neopixel_set_color(&m_strip, i, 0, 0, 0);
- led_to_enable = rand()%NUM_LEDS;
- neopixel_set_color(&m_strip, led_to_enable, red, green, blue);
- neopixel_show(&m_strip);
- }
-
- else if (pattern == PATTERN_RAINBOW)
- rainbowCycle(20, NUM_LEDS, m_strip);
-
- else if (pattern == PATTERN_CANDY)
- candyChase(100, NUM_LEDS, m_strip);
-
- else if (pattern == PATTERN_SNOW)
- snowflakes(250, NUM_LEDS, m_strip);
-
- else if (pattern == PATTERN_ICE)
- iceflakes(150, NUM_LEDS, m_strip);
-
- else if (pattern == PATTERN_XMAS)
- xmas(200, NUM_LEDS, m_strip);
-
- else if (pattern == PATTERN_COL)
- collegiate(100, NUM_LEDS, m_strip);
-
- else if (pattern == PATTERN_IRON)
- irondude(250, NUM_LEDS, m_strip);
-
- else if (pattern == PATTERN_EASTER)
- easter(250, NUM_LEDS, m_strip);
-
- else if (pattern == PATTERN_SPRING)
- spring(250, NUM_LEDS, m_strip);
-
- else if (pattern == PATTERN_MEM)
- memorial(250, NUM_LEDS, m_strip);
-
- else
- neopixel_clear(&m_strip);
- }
- }
-}
-
-static void radio_notification_init(void)
-{
- //uint32_t err_code;
- ble_radio_notification_init(NRF_APP_PRIORITY_LOW,
- NRF_RADIO_NOTIFICATION_DISTANCE_800US,
- ble_on_radio_active_evt);
- //APP_ERROR_CHECK(err_code);
-}
-
-void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
-{
- BLE &ble = params->ble;
- ble_error_t error = params->error;
-
- if (error != BLE_ERROR_NONE) {
- return;
- }
- int length = strlen(mDeviceName);
-
- ble.gap().onDisconnection(disconnectionCallback);
-
- /* Setup primary (UART) service */
- ble.gattServer().addService(uartService);
-
- /* Setup auxiliary service. */
- deviceInfo = new DeviceInformationService(ble, "RRVA", "VectorIQ", "SN1", "hw-rev1", "fw-rev1-1-0", "soft-rev1");
- //deviceInfo = new DeviceInformationService(ble, "RRVA", "VIQ", "", "", "1-0-0", "");
-
- // setup advertising
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); // | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS,
- (uint8_t *)uuid16_list, sizeof(uuid16_list));
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,
- (const uint8_t *)uart_base_uuid_rev, sizeof(uart_base_uuid));
- ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
- (const uint8_t *)&mDeviceName, mLength);
- ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
- ble.gap().setAdvertisingInterval(500); /* ms */
- ble.gap().startAdvertising();
- //ble.startAdvertising();
- //pc.printf("Advertising Start \r\n");
-}
-
-int main(void)
-{
- //uint8_t led_error;
- //BUTTON.mode(PullDown);
- //Ticker ticker;
- //ticker.attach_us(m_status_check_handle, 200000);
-
- // Use internal pullup for pushbutton
- //pb.mode(PullDown);
- // Delay for initial pullup to take effect
- //wait(.01);
- // Attach the address of the interrupt handler routine for pushbutton
- //pb.fall(&pb_hit_interrupt);
-
- set_time(1256729737 ); // Set RTC time to Wed, 28 Oct 2009 11:35:37
-
- strcpy(mDeviceName, "VIQ");
- mLength = strlen(mDeviceName);
-
- //pc.printf("neoPixel Init \r\n");
- neopixel_init(&m_strip, dig_pin_num, NUM_LEDS);
- neopixel_clear(&m_strip);
-
- BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE);
- ble.init(bleInitComplete);
-
- /* Explicitly enable over-the-air firmware updates. Instantiating DFUSservice introduces a
- * control characteristic which can be used to trigger the application to
- * handover control to a resident bootloader. */
- //DFUService dfu(ble);
-
- //ble.init();
- //ble.onDisconnection(disconnectionCallback);
- ble.onConnection(connectionCallback);
- ble.onDataWritten(WrittenHandler);
- radio_notification_init();
- //pc.baud(9600);
- //pc.format(8, SerialBase::None, 1);
- //pc.printf("rbChromaBand Init \r\n");
- //pc.attach( uartCB , pc.RxIrq);
-
- /* SpinWait for initialization to complete. This is necessary because the
- * BLE object is used in the main loop below. */
- //while (ble.hasInitialized() == false) { /* spin loop */ }
-
- //setup_advertising();
-
- while(1) {
- //pc.putc(pc.getc());
- ble.waitForEvent();
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Jun 19 18:12:42 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#fc1836545dcc2fc86f03b01292b62bf2089f67c3
--- a/mbed.bld Wed Apr 19 21:20:31 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://mbed.org/users/mbed_official/code/mbed/builds/97feb9bacc10 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json Mon Jun 19 18:12:42 2017 +0000
@@ -0,0 +1,12 @@
+{
+ "target_overrides": {
+ "K64F": {
+ "target.features_add": ["BLE"],
+ "target.extra_labels_add": ["ST_BLUENRG"]
+ },
+ "NUCLEO_F401RE": {
+ "target.features_add": ["BLE"],
+ "target.extra_labels_add": ["ST_BLUENRG"]
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/module.json Mon Jun 19 18:12:42 2017 +0000
@@ -0,0 +1,16 @@
+{
+ "name": "ble-heartrate",
+ "version": "0.0.1",
+ "description": "BLE Heartreate example, building with yotta",
+ "licenses": [
+ {
+ "url": "https://spdx.org/licenses/Apache-2.0",
+ "type": "Apache-2.0"
+ }
+ ],
+ "dependencies": {
+ "ble": "^2.0.0"
+ },
+ "targetDependencies": {},
+ "bin": "./source"
+}
--- a/nRF51822.lib Wed Apr 19 21:20:31 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#f7faad332abc
--- a/neopixel.cpp Wed Apr 19 21:20:31 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-/* Lava
- *
- * WS2812B Tricolor LED (neopixel) controller
- *
- *
- * Example code:
-
- neopixel_strip_t m_strip;
- uint8_t dig_pin_num = 6;
- uint8_t leds_per_strip = 24;
- uint8_t error;
- uint8_t led_to_enable = 10;
- uint8_t red = 255;
- uint8_t green = 0;
- uint8_t blue = 159;
-
- neopixel_init(&m_strip, dig_pin_num, leds_per_strip);
- neopixel_clear(&m_strip);
- error = neopixel_set_color_and_show(&m_strip, led_to_enable, red, green, blue);
- if (error) {
- //led_to_enable was not within number leds_per_strip
- }
- //clear and remove strip
- neopixel_clear(&m_strip);
- neopixel_destroy(&m_strip);
-
-
- * For use with BLE stack, see information below:
- - Include in main.c
- #include "ble_radio_notification.h"
- - Call (see nrf_soc.h: NRF_RADIO_NOTIFICATION_DISTANCES and NRF_APP_PRIORITIES)
- ble_radio_notification_init(NRF_APP_PRIORITY_xxx,
- NRF_RADIO_NOTIFICATION_DISTANCE_xxx,
- your_radio_callback_handler);
- - Create
- void your_radio_callback_handler(bool radio_active)
- {
- if (radio_active == false)
- {
- neopixel_show(&strip1);
- neopixel_show(&strip2);
- //...etc
- }
- }
- - Do not use neopixel_set_color_and_show(...) with BLE, instead use uint8_t neopixel_set_color(...);
- */
-
-#include "mbed.h" // remove line if not using mbed
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include "nrf_delay.h"
-#include "nrf_gpio.h"
-#include "neopixel.h"
-
-
-void neopixel_init(neopixel_strip_t *strip, uint8_t pin_num, uint16_t num_leds)
-{
- strip->leds = (color_t*) malloc(sizeof(color_t) * num_leds);
- strip->pin_num = pin_num;
- strip->num_leds = num_leds;
- nrf_gpio_cfg_output(pin_num);
- NRF_GPIO->OUTCLR = (1UL << pin_num);
- for (int i = 0; i < num_leds; i++)
- {
- strip->leds[i].simple.g = 0;
- strip->leds[i].simple.r = 0;
- strip->leds[i].simple.b = 0;
- }
-}
-
-void neopixel_clear(neopixel_strip_t *strip)
-{
- for (int i = 0; i < strip->num_leds; i++)
- {
- strip->leds[i].simple.g = 0;
- strip->leds[i].simple.r = 0;
- strip->leds[i].simple.b = 0;
- }
- neopixel_show(strip);
-}
-
-void neopixel_show(neopixel_strip_t *strip)
-{
- const uint8_t PIN = strip->pin_num;
- NRF_GPIO->OUTCLR = (1UL << PIN);
- nrf_delay_us(50);
- for (int i = 0; i < strip->num_leds; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- if ((strip->leds[i].grb[j] & 128) > 0) {NEOPIXEL_SEND_ONE}
- else {NEOPIXEL_SEND_ZERO}
-
- if ((strip->leds[i].grb[j] & 64) > 0) {NEOPIXEL_SEND_ONE}
- else {NEOPIXEL_SEND_ZERO}
-
- if ((strip->leds[i].grb[j] & 32) > 0) {NEOPIXEL_SEND_ONE}
- else {NEOPIXEL_SEND_ZERO}
-
- if ((strip->leds[i].grb[j] & 16) > 0) {NEOPIXEL_SEND_ONE}
- else {NEOPIXEL_SEND_ZERO}
-
- if ((strip->leds[i].grb[j] & 8) > 0) {NEOPIXEL_SEND_ONE}
- else {NEOPIXEL_SEND_ZERO}
-
- if ((strip->leds[i].grb[j] & 4) > 0) {NEOPIXEL_SEND_ONE}
- else {NEOPIXEL_SEND_ZERO}
-
- if ((strip->leds[i].grb[j] & 2) > 0) {NEOPIXEL_SEND_ONE}
- else {NEOPIXEL_SEND_ZERO}
-
- if ((strip->leds[i].grb[j] & 1) > 0) {NEOPIXEL_SEND_ONE}
- else {NEOPIXEL_SEND_ZERO}
- }
- }
-}
-
-uint8_t neopixel_set_color(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue )
-{
- if (index < strip->num_leds)
- {
- strip->leds[index].simple.r = red;
- strip->leds[index].simple.g = green;
- strip->leds[index].simple.b = blue;
- }
- else
- return 1;
- return 0;
-}
-
-uint8_t neopixel_set_color_and_show(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue)
-{
- if (index < strip->num_leds)
- {
- strip->leds[index].simple.r = red;
- strip->leds[index].simple.g = green;
- strip->leds[index].simple.b = blue;
- neopixel_show(strip);
- }
- else
- return 1;
- return 0;
-}
-
-void neopixel_destroy(neopixel_strip_t *strip)
-{
- free(strip->leds);
- strip->num_leds = 0;
- strip->pin_num = 0;
-}
-/*
-int main() {
- DigitalOut mypin(D4);
- neopixel_strip_t m_strip;
- uint8_t dig_pin_num = P0_21;
- uint8_t leds_per_strip = 30;
- uint8_t error;
- uint8_t led_to_enable = 30;
- uint8_t red = 0;
- uint8_t green = 128;
- uint8_t blue = 128;
-
- neopixel_init(&m_strip, dig_pin_num, leds_per_strip);
- neopixel_clear(&m_strip);
- //error = neopixel_set_color_and_show(&m_strip, led_to_enable, red, green, blue);
- for (int cv=0; cv < 60; cv++) {
-
- neopixel_set_color_and_show(&m_strip, cv, red, green, blue);
- wait_ms(500);
- }
-
- if (error) {
- //led_to_enable was not within number leds_per_strip
- }
-
- //error = neopixel_set_color_and_show(&m_strip, 1, red, green, blue);
- while (1) {
- wait_ms(500);
- }
- //clear and remove strip
- //neopixel_clear(&m_strip);
- //neopixel_destroy(&m_strip);
-}
-*/
\ No newline at end of file
--- a/neopixel.h Wed Apr 19 21:20:31 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-/* Copyright (c) 2015 bickster, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- #ifndef NEOPIXEL_H
- #define NEOPIXEL_H
-
-#include <stdbool.h>
-#include <stdint.h>
-
-
-//These defines are timed specific to a series of if statements and will need to be changed
-//to compensate for different writing algorithms than the one in neopixel.c
-#define NEOPIXEL_SEND_ONE NRF_GPIO->OUTSET = (1UL << PIN); \
- NRF_GPIO->OUTSET = (1UL << PIN); \
- NRF_GPIO->OUTSET = (1UL << PIN); \
- NRF_GPIO->OUTCLR = (1UL << PIN);
-
-#define NEOPIXEL_SEND_ZERO NRF_GPIO->OUTSET = (1UL << PIN); \
- NRF_GPIO->OUTCLR = (1UL << PIN); \
- NRF_GPIO->OUTCLR = (1UL << PIN); \
- NRF_GPIO->OUTCLR = (1UL << PIN); \
- NRF_GPIO->OUTCLR = (1UL << PIN);
-
-typedef union {
- struct {
- uint8_t g, r, b;
- }simple;
- uint8_t grb[3];
-} color_t;
-
-typedef struct {
- uint8_t pin_num;
- uint16_t num_leds;
- color_t *leds;
-} neopixel_strip_t;
-
-/**
- @brief Initialize GPIO and data location
- @param[in] pointer to Strip structure
- @param[in] pin number for GPIO
-*/
-void neopixel_init(neopixel_strip_t *strip, uint8_t pin_num, uint16_t num_leds);
-
-/**
- @brief Turn all LEDs off
- @param[in] pointer to Strip structure
-*/
-void neopixel_clear(neopixel_strip_t *strip);
-
-/**
- @brief Update strip with structure data
- @param[in] pointer to Strip structure
-*/
-void neopixel_show(neopixel_strip_t *strip);
-
-/**
- @brief Write RGB value to LED structure
- @param[in] pointer to Strip structure
- @param[in] red value
- @param[in] green value
- @param[in] blue value
- @param[in] LED number (starting at 1)
- @retval 0 Successful write
- @retval 1 LED number is out of bounds
-*/
-uint8_t neopixel_set_color(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue );
-
-
-/**
- @brief Write RGB value to LED structure and update LED
- @param[in] pointer to Strip structure
- @param[in] red value
- @param[in] green value
- @param[in] blue value
- @param[in] LED number (starting at 1)
- @retval 0 Successful write
- @retval 1 LED number is out of bounds
-*/
-uint8_t neopixel_set_color_and_show(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue);
-
-/**
- @brief Clears structure data
- @param[in] pointer to Strip structure
-*/
-void neopixel_destroy(neopixel_strip_t *strip);
-
-#endif
\ No newline at end of file
--- a/patterns.cpp Wed Apr 19 21:20:31 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-#include "mbed.h" // remove line if not using mbed
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include "nrf_delay.h"
-#include "nrf_gpio.h"
-#include "neopixel.h"
-
-// Input a value 0 to 255 to get a color value.
-// The colours are a transition r - g - b - back to r.
-uint32_t Wheel(uint8_t WheelPos, neopixel_strip_t m_strip, uint8_t led_to_enable) {
- WheelPos = 255 - WheelPos;
- if(WheelPos < 85) {
- return neopixel_set_color(&m_strip, led_to_enable, 255 - WheelPos * 3, 0, WheelPos * 3);
- }
- if(WheelPos < 170) {
- WheelPos -= 85;
- return neopixel_set_color(&m_strip, 0, led_to_enable, WheelPos * 3, 255 - WheelPos * 3);
- }
- WheelPos -= 170;
- return neopixel_set_color(&m_strip, led_to_enable, WheelPos * 3, 255 - WheelPos * 3, 0);
-}
-
-void rainbowCycle(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
- uint16_t i, j;
- uint32_t ret;
-
- for(j=0; j<256; j++) {
- for(i=0; i<numLEDs; i++) {
- //neopixel_set_color(&m_strip, i, Wheel((i+j) & 255));
- ret = Wheel((i+j) & 255, m_strip, i);
- }
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
-}
-
-void candyChase(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
-
- for (int i=0; i < numLEDs; i++)
- neopixel_set_color(&m_strip, i, 255,255,255); //turn every pixel white
-
- for (int i=0; i < numLEDs-1; i++) {
- neopixel_set_color(&m_strip, i, 255,255,255);
- neopixel_set_color(&m_strip, i+1, 255,0,0); //turn on a red pixel and move it
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
- wait_ms(delay);
-
- for (int i=0; i < numLEDs; i++)
- neopixel_set_color(&m_strip, i, 255,0,0); //turn every pixel red
-
- for (int i=0; i < numLEDs-1; i++) {
- neopixel_set_color(&m_strip, i, 255,0,0);
- neopixel_set_color(&m_strip, i+1, 255,255,255); //turn on a white pixel and move it
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
-}
-
-void snowflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
-
- for (int i=0; i < numLEDs; i++)
- neopixel_set_color(&m_strip, i, 0,0,235); //turn every pixel blue
-
- for (int i=0; i < numLEDs-1; i++) {
- neopixel_set_color(&m_strip, i, 0,0,235);
- neopixel_set_color(&m_strip, i+1, 255,255,255); //turn on a white pixel and move it
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
-}
-
-void collegiate(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
-
- for (int i=0; i < numLEDs; i++)
- neopixel_set_color(&m_strip, i, 224,193,36); //turn every pixel gold
-
- for (int i=0; i < numLEDs-1; i++) {
- neopixel_set_color(&m_strip, i, 224,193,36);
- neopixel_set_color(&m_strip, i+1, 0,255,0); //turn on a green pixel and move it
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
- wait_ms(delay);
-
- for (int i=0; i < numLEDs; i++)
- neopixel_set_color(&m_strip, i, 0,255,0); //turn every pixel green
-
- for (int i=0; i < numLEDs-1; i++) {
- neopixel_set_color(&m_strip, i, 0,255,0);
- neopixel_set_color(&m_strip, i+1, 224,193,36); //turn on a gold pixel and move it
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
-}
-
-void iceflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
- uint8_t led;
-
- for (uint8_t i=0; i < numLEDs; i++)
- neopixel_set_color(&m_strip, i, 235,235,235); //turn every pixel white
-
- led = rand()%numLEDs;
- neopixel_set_color(&m_strip, led, 0, 0, 235); // set random blue
- neopixel_show(&m_strip);
- wait_ms(delay);
-}
-
-void xmas(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
- //All green
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 0,255,0);
- neopixel_show(&m_strip);
- wait_ms(1000);
- //All red
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 255,0,0);
- neopixel_show(&m_strip);
- wait_ms(1000);
- //Green with a red mover
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 0,255,0);
- neopixel_show(&m_strip);
- wait_ms(500);
- for (int j=0; j<numLEDs; j++)
- {
- neopixel_set_color(&m_strip, j, 255,0,0);
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
- //Red with a green mover
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 255,0,0);
- neopixel_show(&m_strip);
- wait_ms(delay);
- for (int j=0; j<numLEDs; j++)
- {
- neopixel_set_color(&m_strip, j, 0,255,0);
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
-}
-
-void irondude(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
-
- for (int i=0; i < numLEDs; i++)
- neopixel_set_color(&m_strip, i, 255,255,255); //turn every pixel white
-
- for (int i=0; i < numLEDs; i++) {
- neopixel_set_color(&m_strip, i, 255,0,0); //change whites to reds
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
- wait_ms(delay);
-
- for (int i=0; i <= numLEDs; i++) {
- neopixel_set_color(&m_strip, numLEDs - i, 255,255,255); //change reds to white, in reverse
- neopixel_show(&m_strip);
- wait_ms(delay);
- }
-}
-
-void easter(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
- //All purple
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 102,0,102);
- neopixel_show(&m_strip);
- wait_ms(1000);
- //All white
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 255,255,255);
- neopixel_show(&m_strip);
- wait_ms(1000);
- //All gold
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 255,204,0);
- neopixel_show(&m_strip);
- wait_ms(1000);
-}
-
-void spring(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
- //All pink
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 255,102,255);
- neopixel_show(&m_strip);
- wait_ms(1000);
- //All blue
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 153,204,255);
- neopixel_show(&m_strip);
- wait_ms(1000);
- //All green
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 153,255,153);
- neopixel_show(&m_strip);
- wait_ms(1000);
- //All yellow
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 255,255,153);
- neopixel_show(&m_strip);
- wait_ms(1000);
-}
-
-void memorial(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
- //All red
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 255,0,0);
- neopixel_show(&m_strip);
- wait_ms(1000);
- //All white
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 255,255,255);
- neopixel_show(&m_strip);
- wait_ms(1000);
- //All blue
- for (int j=0; j<numLEDs; j++)
- neopixel_set_color(&m_strip, j, 0,0,255);
- neopixel_show(&m_strip);
- wait_ms(1000);
-}
\ No newline at end of file
--- a/pitches.h Wed Apr 19 21:20:31 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/************************************************* - * Public Constants - *************************************************/ - -#define NOTE_B0 31 -#define NOTE_C1 33 -#define NOTE_CS1 35 -#define NOTE_D1 37 -#define NOTE_DS1 39 -#define NOTE_E1 41 -#define NOTE_F1 44 -#define NOTE_FS1 46 -#define NOTE_G1 49 -#define NOTE_GS1 52 -#define NOTE_A1 55 -#define NOTE_AS1 58 -#define NOTE_B1 62 -#define NOTE_C2 65 -#define NOTE_CS2 69 -#define NOTE_D2 73 -#define NOTE_DS2 78 -#define NOTE_E2 82 -#define NOTE_F2 87 -#define NOTE_FS2 93 -#define NOTE_G2 98 -#define NOTE_GS2 104 -#define NOTE_A2 110 -#define NOTE_AS2 117 -#define NOTE_B2 123 -#define NOTE_C3 131 -#define NOTE_CS3 139 -#define NOTE_D3 147 -#define NOTE_DS3 156 -#define NOTE_E3 165 -#define NOTE_F3 175 -#define NOTE_FS3 185 -#define NOTE_G3 196 -#define NOTE_GS3 208 -#define NOTE_A3 220 -#define NOTE_AS3 233 -#define NOTE_B3 247 -#define NOTE_C4 262 -#define NOTE_CS4 277 -#define NOTE_D4 294 -#define NOTE_DS4 311 -#define NOTE_E4 330 -#define NOTE_F4 349 -#define NOTE_FS4 370 -#define NOTE_G4 392 -#define NOTE_GS4 415 -#define NOTE_A4 440 -#define NOTE_AS4 466 -#define NOTE_B4 494 -#define NOTE_C5 523 -#define NOTE_CS5 554 -#define NOTE_D5 587 -#define NOTE_DS5 622 -#define NOTE_E5 659 -#define NOTE_F5 698 -#define NOTE_FS5 740 -#define NOTE_G5 784 -#define NOTE_GS5 831 -#define NOTE_A5 880 -#define NOTE_AS5 932 -#define NOTE_B5 988 -#define NOTE_C6 1047 -#define NOTE_CS6 1109 -#define NOTE_D6 1175 -#define NOTE_DS6 1245 -#define NOTE_E6 1319 -#define NOTE_F6 1397 -#define NOTE_FS6 1480 -#define NOTE_G6 1568 -#define NOTE_GS6 1661 -#define NOTE_A6 1760 -#define NOTE_AS6 1865 -#define NOTE_B6 1976 -#define NOTE_C7 2093 -#define NOTE_CS7 2217 -#define NOTE_D7 2349 -#define NOTE_DS7 2489 -#define NOTE_E7 2637 -#define NOTE_F7 2794 -#define NOTE_FS7 2960 -#define NOTE_G7 3136 -#define NOTE_GS7 3322 -#define NOTE_A7 3520 -#define NOTE_AS7 3729 -#define NOTE_B7 3951 -#define NOTE_C8 4186 -#define NOTE_CS8 4435 -#define NOTE_D8 4699 -#define NOTE_DS8 4978 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shields/TARGET_ST_BLUENRG.lib Mon Jun 19 18:12:42 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/ble-x-nucleo-idb0xa1/#1aa28edf81b86bdfe691cd46ee3f7101693ef066
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main.cpp Mon Jun 19 18:12:42 2017 +0000
@@ -0,0 +1,328 @@
+/*
+
+Copyright (c) 2017 Radiant RVA
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+and associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+*/
+//#define DK_52
+
+#include <events/mbed_events.h>
+#include "vector_iq.h"
+
+#ifdef DK_52
+ DigitalOut led1(LED1, 1);
+#endif
+
+static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE);
+
+void connectionCallback(const Gap::ConnectionCallbackParams_t *params)
+{
+#ifdef VIQ
+ neopixel_init(&m_strip, dig_pin_num, NUM_LEDS);
+ neopixel_clear(&m_strip);
+ LEDS_ON_FLAG = 0;
+#endif
+}
+
+void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
+{
+ BLE::Instance().gap().startAdvertising(); // restart advertising
+}
+
+void WrittenHandler(const GattWriteCallbackParams *Handler)
+{
+#ifdef VIQ
+ uint8_t buf[TXRX_BUF_LEN];
+ uint16_t bytesRead;
+
+ if (Handler->handle == txCharacteristic.getValueAttribute().getHandle()) {
+ ble.readCharacteristicValue(txCharacteristic.getValueAttribute().getHandle(), buf, &bytesRead);
+ memset(txPayload, 0, TXRX_BUF_LEN);
+ memcpy(txPayload, buf, TXRX_BUF_LEN);
+
+ //for(index=0; index<bytesRead; index++)
+ //pc.putc(buf[index]);
+
+ if(buf[0] == ONOFF_HEADER) {
+ //pc.printf("LED value received \r\n");
+ if(buf[1] == LEDS_ON) {
+ LEDS_ON_FLAG = 1;
+ } else if(buf[1] == LEDS_OFF) {
+ LEDS_ON_FLAG = 0;
+ neopixel_init(&m_strip, dig_pin_num, NUM_LEDS);
+ neopixel_clear(&m_strip);
+ }
+ } else if(buf[0] == COLOR_HEADER) {
+ red = buf[1];
+ green = buf[2];
+ blue = buf[3];
+ pattern = buf[5];
+ } else if(buf[0] == PIEZO_HEADER) {
+ mPiezoOn = buf[1];
+ //mPiezoDur = buf[2];
+ mPiezoPattern = buf[2];
+ } else if(buf[0] == HAPTIC_HEADER) {
+ mHapticOn = buf[1];
+ mHapticDur = buf[2];
+ mHapticPattern = buf[3];
+ } else if(buf[0] == ALARM_HEADER) {
+ mAlarmOn = buf[1];
+ //mAlarmStart = buf[2];
+ mAlarmDur = buf[2];
+ mAlarmPiezoOn = buf[4];
+ mAlarmTone = buf[5];
+ mAlarmPattern = buf[6];
+ pattern = mAlarmPattern;
+ if (mAlarmOn == ALARM_ON) {
+ // Setup the timer
+ t_alarm.start();
+ mBeginAlarm = t_alarm.read();
+ mEndAlarm = mBeginAlarm + mAlarmDur;
+ mPiezoOn = mAlarmPiezoOn;
+ LEDS_ON_FLAG = 1;
+ } else if (mAlarmOn == ALARM_OFF) {
+ // Stop the timer
+ t_alarm.stop();
+ // Kill all the effects
+ mHapticOn = HAPTIC_OFF;
+ mPiezoOn = PIEZO_OFF;
+ LEDS_ON_FLAG = 0;
+ }
+ }
+ else
+ {
+ LEDS_ON_FLAG = 1;
+ red = buf[1];
+ green = buf[2];
+ blue = buf[3];
+ pattern = buf[5];
+ }
+ }
+#endif
+}
+
+// pb Interrupt routine - is interrupt activated by a falling edge of pb input
+void pb_hit_interrupt (void) {
+ pattern++;
+ if (pattern >= PATTERN_MEM)
+ pattern = PATTERN_ON;
+}
+
+void m_status_check_handle(void)
+{
+ //uint8_t buf[3];
+
+ //if (BUTTON == 1) {
+ // Cycle through display patterns
+ //pattern++;
+ //if (pattern >= PATTERN_MEM)
+ // pattern = PATTERN_NONE;
+ //}
+}
+
+void updateLEDs()
+{
+#ifdef VIQ
+ if (mAlarmOn == ALARM_ON) {
+ if (t_alarm.read() > mEndAlarm) {
+ // end alarm
+ t_alarm.stop();
+ mHapticOn = HAPTIC_OFF;
+ mPiezoOn = PIEZO_OFF;
+ LEDS_ON_FLAG = 0;
+ }
+ }
+ if (mHapticOn == HAPTIC_ON) {
+ BUZZER = 1;
+ wait_ms(1000);
+ } else {
+ BUZZER = 0;
+ //wait_ms(1000);
+ }
+ if (mPiezoOn == PIEZO_ON) {
+ for (int i = 0; i < (sizeof(freq_coll) / sizeof(int)); i++) {
+ // Keep checking for an "Off"
+ //if (mPiezoOn == PIEZO_OFF)
+ //break;
+ PIEZO.period(1.0 / freq_coll[i]);
+ PIEZO.write(0.9);
+ wait(1.0 / beat_coll[i]);
+ PIEZO.write(0);
+ wait(0.05);
+ }
+ wait_ms(500);
+ }
+ if (LEDS_ON_FLAG == 1) {
+ if (pattern == PATTERN_ON) {
+ for (uint8_t i = 0; i <= NUM_LEDS; i++)
+ neopixel_set_color(&m_strip, i, red, green, blue);
+ neopixel_show(&m_strip);
+
+ } else if (pattern == PATTERN_FAST) {
+ //neopixel_clear(&m_strip);
+ for (uint8_t i = 0; i <= NUM_LEDS; i++)
+ neopixel_set_color(&m_strip, i, 0, 0, 0);
+ if (led_to_enable > NUM_LEDS)
+ led_to_enable = 0;
+ neopixel_set_color(&m_strip, led_to_enable, red, green, blue);
+ neopixel_show(&m_strip);
+ led_to_enable++;
+ } else if (pattern == PATTERN_SLOW) {
+ for (uint8_t i = 0; i <= NUM_LEDS; i++)
+ neopixel_set_color(&m_strip, i, 0, 0, 0);
+ if (led_to_enable > NUM_LEDS)
+ led_to_enable = 0;
+ neopixel_set_color(&m_strip, led_to_enable, red, green, blue);
+ neopixel_show(&m_strip);
+ led_to_enable++;
+ wait_ms(1000);
+
+ } else if (pattern == PATTERN_CHASE) {
+ for (uint8_t i = 0; i <= NUM_LEDS; i++)
+ neopixel_set_color(&m_strip, i, 0, 0, 0);
+ if (led_to_enable > NUM_LEDS)
+ led_to_enable = 0;
+ for (uint8_t i = 0; i <= NUM_LEDS; i++)
+ neopixel_set_color(&m_strip, led_to_enable, red, green, blue);
+ neopixel_show(&m_strip);
+ led_to_enable++;
+ wait_ms(100);
+
+ } else if (pattern == PATTERN_MRB) {
+ //neopixel_clear(&m_strip);
+ for (uint8_t i = 0; i <= NUM_LEDS; i++)
+ neopixel_set_color(&m_strip, i, 0, 0, 0);
+ led_to_enable = rand()%NUM_LEDS;
+ neopixel_set_color(&m_strip, led_to_enable, red, green, blue);
+ neopixel_show(&m_strip);
+ }
+
+ else if (pattern == PATTERN_RAINBOW)
+ rainbowCycle(20, NUM_LEDS, m_strip);
+
+ else if (pattern == PATTERN_CANDY)
+ candyChase(100, NUM_LEDS, m_strip);
+
+ else if (pattern == PATTERN_SNOW)
+ snowflakes(250, NUM_LEDS, m_strip);
+
+ else if (pattern == PATTERN_ICE)
+ iceflakes(150, NUM_LEDS, m_strip);
+
+ else if (pattern == PATTERN_XMAS)
+ xmas(200, NUM_LEDS, m_strip);
+
+ else if (pattern == PATTERN_COL)
+ collegiate(100, NUM_LEDS, m_strip);
+
+ else if (pattern == PATTERN_IRON)
+ irondude(250, NUM_LEDS, m_strip);
+
+ else if (pattern == PATTERN_EASTER)
+ easter(250, NUM_LEDS, m_strip);
+
+ else if (pattern == PATTERN_SPRING)
+ spring(250, NUM_LEDS, m_strip);
+
+ else if (pattern == PATTERN_MEM)
+ memorial(250, NUM_LEDS, m_strip);
+
+ else
+ neopixel_clear(&m_strip);
+ }
+ #endif
+}
+
+void periodicCallback(void)
+{
+#ifdef DK_52
+ led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
+#endif
+ if (BLE::Instance().getGapState().connected) {
+ eventQueue.call(updateLEDs);
+ }
+}
+
+void onBleInitError(BLE &ble, ble_error_t error)
+{
+ (void)ble;
+ (void)error;
+ /* Initialization error handling should go here */
+}
+
+void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
+{
+
+ BLE& ble = params->ble;
+ ble_error_t error = params->error;
+
+ if (error != BLE_ERROR_NONE) {
+ onBleInitError(ble, error);
+ return;
+ }
+
+ if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) {
+ return;
+ }
+
+ ble.gap().onDisconnection(disconnectionCallback);
+
+ /* Setup primary (UART) service */
+ ble.gattServer().addService(uartService);
+
+ /* Setup auxiliary service. */
+ deviceInfo = new DeviceInformationService(ble, "RRVA", "VectorIQ", "SN1", "hw-rev1", "fw-rev1-1-0", "soft-rev1");
+ //deviceInfo = new DeviceInformationService(ble, "RRVA", "VIQ", "", "", "1-0-0", "");
+
+ // setup advertising
+ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); // | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
+ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS,
+ (uint8_t *)uuid16_list, sizeof(uuid16_list));
+ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,
+ (const uint8_t *)uart_base_uuid_rev, sizeof(uart_base_uuid));
+ ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
+ (const uint8_t *)&mDeviceName, mLength);
+ ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
+ ble.gap().setAdvertisingInterval(500); /* ms */
+ ble.gap().startAdvertising();
+ //ble.startAdvertising();
+ //pc.printf("Advertising Start \r\n");
+}
+
+void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {
+ BLE &ble = BLE::Instance();
+ eventQueue.call(Callback<void()>(&ble, &BLE::processEvents));
+}
+
+int main(void)
+{
+ set_time(1256729737 ); // Set RTC time to Wed, 28 Oct 2009 11:35:37
+
+ strcpy(mDeviceName, "VIQ");
+ mLength = strlen(mDeviceName);
+
+ //pc.printf("neoPixel Init \r\n");
+#ifdef VIQ
+ neopixel_init(&m_strip, dig_pin_num, NUM_LEDS);
+ neopixel_clear(&m_strip);
+#endif
+ eventQueue.call_every(500, periodicCallback);
+
+ BLE &ble = BLE::Instance();
+ ble.onEventsToProcess(scheduleBleEventsProcessing);
+ ble.init(bleInitComplete);
+
+ eventQueue.dispatch_forever();
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/neopixel.cpp Mon Jun 19 18:12:42 2017 +0000
@@ -0,0 +1,186 @@
+/* Lava
+ *
+ * WS2812B Tricolor LED (neopixel) controller
+ *
+ *
+ * Example code:
+
+ neopixel_strip_t m_strip;
+ uint8_t dig_pin_num = 6;
+ uint8_t leds_per_strip = 24;
+ uint8_t error;
+ uint8_t led_to_enable = 10;
+ uint8_t red = 255;
+ uint8_t green = 0;
+ uint8_t blue = 159;
+
+ neopixel_init(&m_strip, dig_pin_num, leds_per_strip);
+ neopixel_clear(&m_strip);
+ error = neopixel_set_color_and_show(&m_strip, led_to_enable, red, green, blue);
+ if (error) {
+ //led_to_enable was not within number leds_per_strip
+ }
+ //clear and remove strip
+ neopixel_clear(&m_strip);
+ neopixel_destroy(&m_strip);
+
+
+ * For use with BLE stack, see information below:
+ - Include in main.c
+ #include "ble_radio_notification.h"
+ - Call (see nrf_soc.h: NRF_RADIO_NOTIFICATION_DISTANCES and NRF_APP_PRIORITIES)
+ ble_radio_notification_init(NRF_APP_PRIORITY_xxx,
+ NRF_RADIO_NOTIFICATION_DISTANCE_xxx,
+ your_radio_callback_handler);
+ - Create
+ void your_radio_callback_handler(bool radio_active)
+ {
+ if (radio_active == false)
+ {
+ neopixel_show(&strip1);
+ neopixel_show(&strip2);
+ //...etc
+ }
+ }
+ - Do not use neopixel_set_color_and_show(...) with BLE, instead use uint8_t neopixel_set_color(...);
+ */
+
+#include "mbed.h" // remove line if not using mbed
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "nrf_delay.h"
+#include "nrf_gpio.h"
+#include "neopixel.h"
+
+
+void neopixel_init(neopixel_strip_t *strip, uint8_t pin_num, uint16_t num_leds)
+{
+ strip->leds = (color_t*) malloc(sizeof(color_t) * num_leds);
+ strip->pin_num = pin_num;
+ strip->num_leds = num_leds;
+ nrf_gpio_cfg_output(pin_num);
+ NRF_GPIO->OUTCLR = (1UL << pin_num);
+ for (int i = 0; i < num_leds; i++)
+ {
+ strip->leds[i].simple.g = 0;
+ strip->leds[i].simple.r = 0;
+ strip->leds[i].simple.b = 0;
+ }
+}
+
+void neopixel_clear(neopixel_strip_t *strip)
+{
+ for (int i = 0; i < strip->num_leds; i++)
+ {
+ strip->leds[i].simple.g = 0;
+ strip->leds[i].simple.r = 0;
+ strip->leds[i].simple.b = 0;
+ }
+ neopixel_show(strip);
+}
+
+void neopixel_show(neopixel_strip_t *strip)
+{
+ const uint8_t PIN = strip->pin_num;
+ NRF_GPIO->OUTCLR = (1UL << PIN);
+ nrf_delay_us(50);
+ for (int i = 0; i < strip->num_leds; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ if ((strip->leds[i].grb[j] & 128) > 0) {NEOPIXEL_SEND_ONE}
+ else {NEOPIXEL_SEND_ZERO}
+
+ if ((strip->leds[i].grb[j] & 64) > 0) {NEOPIXEL_SEND_ONE}
+ else {NEOPIXEL_SEND_ZERO}
+
+ if ((strip->leds[i].grb[j] & 32) > 0) {NEOPIXEL_SEND_ONE}
+ else {NEOPIXEL_SEND_ZERO}
+
+ if ((strip->leds[i].grb[j] & 16) > 0) {NEOPIXEL_SEND_ONE}
+ else {NEOPIXEL_SEND_ZERO}
+
+ if ((strip->leds[i].grb[j] & 8) > 0) {NEOPIXEL_SEND_ONE}
+ else {NEOPIXEL_SEND_ZERO}
+
+ if ((strip->leds[i].grb[j] & 4) > 0) {NEOPIXEL_SEND_ONE}
+ else {NEOPIXEL_SEND_ZERO}
+
+ if ((strip->leds[i].grb[j] & 2) > 0) {NEOPIXEL_SEND_ONE}
+ else {NEOPIXEL_SEND_ZERO}
+
+ if ((strip->leds[i].grb[j] & 1) > 0) {NEOPIXEL_SEND_ONE}
+ else {NEOPIXEL_SEND_ZERO}
+ }
+ }
+}
+
+uint8_t neopixel_set_color(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue )
+{
+ if (index < strip->num_leds)
+ {
+ strip->leds[index].simple.r = red;
+ strip->leds[index].simple.g = green;
+ strip->leds[index].simple.b = blue;
+ }
+ else
+ return 1;
+ return 0;
+}
+
+uint8_t neopixel_set_color_and_show(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue)
+{
+ if (index < strip->num_leds)
+ {
+ strip->leds[index].simple.r = red;
+ strip->leds[index].simple.g = green;
+ strip->leds[index].simple.b = blue;
+ neopixel_show(strip);
+ }
+ else
+ return 1;
+ return 0;
+}
+
+void neopixel_destroy(neopixel_strip_t *strip)
+{
+ free(strip->leds);
+ strip->num_leds = 0;
+ strip->pin_num = 0;
+}
+/*
+int main() {
+ DigitalOut mypin(D4);
+ neopixel_strip_t m_strip;
+ uint8_t dig_pin_num = P0_21;
+ uint8_t leds_per_strip = 30;
+ uint8_t error;
+ uint8_t led_to_enable = 30;
+ uint8_t red = 0;
+ uint8_t green = 128;
+ uint8_t blue = 128;
+
+ neopixel_init(&m_strip, dig_pin_num, leds_per_strip);
+ neopixel_clear(&m_strip);
+ //error = neopixel_set_color_and_show(&m_strip, led_to_enable, red, green, blue);
+ for (int cv=0; cv < 60; cv++) {
+
+ neopixel_set_color_and_show(&m_strip, cv, red, green, blue);
+ wait_ms(500);
+ }
+
+ if (error) {
+ //led_to_enable was not within number leds_per_strip
+ }
+
+ //error = neopixel_set_color_and_show(&m_strip, 1, red, green, blue);
+ while (1) {
+ wait_ms(500);
+ }
+ //clear and remove strip
+ //neopixel_clear(&m_strip);
+ //neopixel_destroy(&m_strip);
+}
+*/
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/neopixel.h Mon Jun 19 18:12:42 2017 +0000
@@ -0,0 +1,101 @@
+/* Copyright (c) 2015 bickster, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+ #ifndef NEOPIXEL_H
+ #define NEOPIXEL_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+
+//These defines are timed specific to a series of if statements and will need to be changed
+//to compensate for different writing algorithms than the one in neopixel.c
+#define NEOPIXEL_SEND_ONE NRF_GPIO->OUTSET = (1UL << PIN); \
+ NRF_GPIO->OUTSET = (1UL << PIN); \
+ NRF_GPIO->OUTSET = (1UL << PIN); \
+ NRF_GPIO->OUTCLR = (1UL << PIN);
+
+#define NEOPIXEL_SEND_ZERO NRF_GPIO->OUTSET = (1UL << PIN); \
+ NRF_GPIO->OUTCLR = (1UL << PIN); \
+ NRF_GPIO->OUTCLR = (1UL << PIN); \
+ NRF_GPIO->OUTCLR = (1UL << PIN); \
+ NRF_GPIO->OUTCLR = (1UL << PIN);
+
+typedef union {
+ struct {
+ uint8_t g, r, b;
+ }simple;
+ uint8_t grb[3];
+} color_t;
+
+typedef struct {
+ uint8_t pin_num;
+ uint16_t num_leds;
+ color_t *leds;
+} neopixel_strip_t;
+
+/**
+ @brief Initialize GPIO and data location
+ @param[in] pointer to Strip structure
+ @param[in] pin number for GPIO
+*/
+void neopixel_init(neopixel_strip_t *strip, uint8_t pin_num, uint16_t num_leds);
+
+/**
+ @brief Turn all LEDs off
+ @param[in] pointer to Strip structure
+*/
+void neopixel_clear(neopixel_strip_t *strip);
+
+/**
+ @brief Update strip with structure data
+ @param[in] pointer to Strip structure
+*/
+void neopixel_show(neopixel_strip_t *strip);
+
+/**
+ @brief Write RGB value to LED structure
+ @param[in] pointer to Strip structure
+ @param[in] red value
+ @param[in] green value
+ @param[in] blue value
+ @param[in] LED number (starting at 1)
+ @retval 0 Successful write
+ @retval 1 LED number is out of bounds
+*/
+uint8_t neopixel_set_color(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue );
+
+
+/**
+ @brief Write RGB value to LED structure and update LED
+ @param[in] pointer to Strip structure
+ @param[in] red value
+ @param[in] green value
+ @param[in] blue value
+ @param[in] LED number (starting at 1)
+ @retval 0 Successful write
+ @retval 1 LED number is out of bounds
+*/
+uint8_t neopixel_set_color_and_show(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue);
+
+/**
+ @brief Clears structure data
+ @param[in] pointer to Strip structure
+*/
+void neopixel_destroy(neopixel_strip_t *strip);
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/patterns.cpp Mon Jun 19 18:12:42 2017 +0000
@@ -0,0 +1,223 @@
+#include "mbed.h" // remove line if not using mbed
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "nrf_delay.h"
+#include "nrf_gpio.h"
+#include "neopixel.h"
+
+// Input a value 0 to 255 to get a color value.
+// The colours are a transition r - g - b - back to r.
+uint32_t Wheel(uint8_t WheelPos, neopixel_strip_t m_strip, uint8_t led_to_enable) {
+ WheelPos = 255 - WheelPos;
+ if(WheelPos < 85) {
+ return neopixel_set_color(&m_strip, led_to_enable, 255 - WheelPos * 3, 0, WheelPos * 3);
+ }
+ if(WheelPos < 170) {
+ WheelPos -= 85;
+ return neopixel_set_color(&m_strip, 0, led_to_enable, WheelPos * 3, 255 - WheelPos * 3);
+ }
+ WheelPos -= 170;
+ return neopixel_set_color(&m_strip, led_to_enable, WheelPos * 3, 255 - WheelPos * 3, 0);
+}
+
+void rainbowCycle(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+ uint16_t i, j;
+ uint32_t ret;
+
+ for(j=0; j<256; j++) {
+ for(i=0; i<numLEDs; i++) {
+ //neopixel_set_color(&m_strip, i, Wheel((i+j) & 255));
+ ret = Wheel((i+j) & 255, m_strip, i);
+ }
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+}
+
+void candyChase(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+
+ for (int i=0; i < numLEDs; i++)
+ neopixel_set_color(&m_strip, i, 255,255,255); //turn every pixel white
+
+ for (int i=0; i < numLEDs-1; i++) {
+ neopixel_set_color(&m_strip, i, 255,255,255);
+ neopixel_set_color(&m_strip, i+1, 255,0,0); //turn on a red pixel and move it
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+ wait_ms(delay);
+
+ for (int i=0; i < numLEDs; i++)
+ neopixel_set_color(&m_strip, i, 255,0,0); //turn every pixel red
+
+ for (int i=0; i < numLEDs-1; i++) {
+ neopixel_set_color(&m_strip, i, 255,0,0);
+ neopixel_set_color(&m_strip, i+1, 255,255,255); //turn on a white pixel and move it
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+}
+
+void snowflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+
+ for (int i=0; i < numLEDs; i++)
+ neopixel_set_color(&m_strip, i, 0,0,235); //turn every pixel blue
+
+ for (int i=0; i < numLEDs-1; i++) {
+ neopixel_set_color(&m_strip, i, 0,0,235);
+ neopixel_set_color(&m_strip, i+1, 255,255,255); //turn on a white pixel and move it
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+}
+
+void collegiate(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+
+ for (int i=0; i < numLEDs; i++)
+ neopixel_set_color(&m_strip, i, 224,193,36); //turn every pixel gold
+
+ for (int i=0; i < numLEDs-1; i++) {
+ neopixel_set_color(&m_strip, i, 224,193,36);
+ neopixel_set_color(&m_strip, i+1, 0,255,0); //turn on a green pixel and move it
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+ wait_ms(delay);
+
+ for (int i=0; i < numLEDs; i++)
+ neopixel_set_color(&m_strip, i, 0,255,0); //turn every pixel green
+
+ for (int i=0; i < numLEDs-1; i++) {
+ neopixel_set_color(&m_strip, i, 0,255,0);
+ neopixel_set_color(&m_strip, i+1, 224,193,36); //turn on a gold pixel and move it
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+}
+
+void iceflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+ uint8_t led;
+
+ for (uint8_t i=0; i < numLEDs; i++)
+ neopixel_set_color(&m_strip, i, 235,235,235); //turn every pixel white
+
+ led = rand()%numLEDs;
+ neopixel_set_color(&m_strip, led, 0, 0, 235); // set random blue
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+}
+
+void xmas(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+ //All green
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 0,255,0);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+ //All red
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 255,0,0);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+ //Green with a red mover
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 0,255,0);
+ neopixel_show(&m_strip);
+ wait_ms(500);
+ for (int j=0; j<numLEDs; j++)
+ {
+ neopixel_set_color(&m_strip, j, 255,0,0);
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+ //Red with a green mover
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 255,0,0);
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ for (int j=0; j<numLEDs; j++)
+ {
+ neopixel_set_color(&m_strip, j, 0,255,0);
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+}
+
+void irondude(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+
+ for (int i=0; i < numLEDs; i++)
+ neopixel_set_color(&m_strip, i, 255,255,255); //turn every pixel white
+
+ for (int i=0; i < numLEDs; i++) {
+ neopixel_set_color(&m_strip, i, 255,0,0); //change whites to reds
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+ wait_ms(delay);
+
+ for (int i=0; i <= numLEDs; i++) {
+ neopixel_set_color(&m_strip, numLEDs - i, 255,255,255); //change reds to white, in reverse
+ neopixel_show(&m_strip);
+ wait_ms(delay);
+ }
+}
+
+void easter(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+ //All purple
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 102,0,102);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+ //All white
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 255,255,255);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+ //All gold
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 255,204,0);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+}
+
+void spring(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+ //All pink
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 255,102,255);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+ //All blue
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 153,204,255);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+ //All green
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 153,255,153);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+ //All yellow
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 255,255,153);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+}
+
+void memorial(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
+ //All red
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 255,0,0);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+ //All white
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 255,255,255);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+ //All blue
+ for (int j=0; j<numLEDs; j++)
+ neopixel_set_color(&m_strip, j, 0,0,255);
+ neopixel_show(&m_strip);
+ wait_ms(1000);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/pitches.h Mon Jun 19 18:12:42 2017 +0000 @@ -0,0 +1,93 @@ +/************************************************* + * Public Constants + *************************************************/ + +#define NOTE_B0 31 +#define NOTE_C1 33 +#define NOTE_CS1 35 +#define NOTE_D1 37 +#define NOTE_DS1 39 +#define NOTE_E1 41 +#define NOTE_F1 44 +#define NOTE_FS1 46 +#define NOTE_G1 49 +#define NOTE_GS1 52 +#define NOTE_A1 55 +#define NOTE_AS1 58 +#define NOTE_B1 62 +#define NOTE_C2 65 +#define NOTE_CS2 69 +#define NOTE_D2 73 +#define NOTE_DS2 78 +#define NOTE_E2 82 +#define NOTE_F2 87 +#define NOTE_FS2 93 +#define NOTE_G2 98 +#define NOTE_GS2 104 +#define NOTE_A2 110 +#define NOTE_AS2 117 +#define NOTE_B2 123 +#define NOTE_C3 131 +#define NOTE_CS3 139 +#define NOTE_D3 147 +#define NOTE_DS3 156 +#define NOTE_E3 165 +#define NOTE_F3 175 +#define NOTE_FS3 185 +#define NOTE_G3 196 +#define NOTE_GS3 208 +#define NOTE_A3 220 +#define NOTE_AS3 233 +#define NOTE_B3 247 +#define NOTE_C4 262 +#define NOTE_CS4 277 +#define NOTE_D4 294 +#define NOTE_DS4 311 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_FS4 370 +#define NOTE_G4 392 +#define NOTE_GS4 415 +#define NOTE_A4 440 +#define NOTE_AS4 466 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define NOTE_CS5 554 +#define NOTE_D5 587 +#define NOTE_DS5 622 +#define NOTE_E5 659 +#define NOTE_F5 698 +#define NOTE_FS5 740 +#define NOTE_G5 784 +#define NOTE_GS5 831 +#define NOTE_A5 880 +#define NOTE_AS5 932 +#define NOTE_B5 988 +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define NOTE_C7 2093 +#define NOTE_CS7 2217 +#define NOTE_D7 2349 +#define NOTE_DS7 2489 +#define NOTE_E7 2637 +#define NOTE_F7 2794 +#define NOTE_FS7 2960 +#define NOTE_G7 3136 +#define NOTE_GS7 3322 +#define NOTE_A7 3520 +#define NOTE_AS7 3729 +#define NOTE_B7 3951 +#define NOTE_C8 4186 +#define NOTE_CS8 4435 +#define NOTE_D8 4699 +#define NOTE_DS8 4978 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/vector_iq.h Mon Jun 19 18:12:42 2017 +0000
@@ -0,0 +1,175 @@
+/*
+
+Copyright (c) 2017 Radiant RVA
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+and associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+*/
+
+#include "mbed.h"
+#include "neopixel.h"
+#include "ble/BLE.h"
+#include "GattCallbackParamTypes.h"
+#include "DFUService.h"
+#include "pitches.h"
+#include <DeviceInformationService.h>
+extern "C" {
+#include "ble_radio_notification.h"
+}
+#define BLE_UUID_TXRX_SERVICE 0x0000 /**< The UUID of the Nordic UART Service. */
+#define BLE_UUID_TX_CHARACTERISTIC 0x0002 /**< The UUID of the TX Characteristic. */
+#define BLE_UUIDS_RX_CHARACTERISTIC 0x0003 /**< The UUID of the RX Characteristic. */
+
+#define TXRX_BUF_LEN 20
+#ifdef VIQ
+ #define DIGITAL_OUT_PIN P0_17
+ #define BOARD_LED P0_19
+ #define DIGITAL_IN_PIN P0_9
+ #define PWM_PIN P0_16
+ #define SERVO_PIN P0_14
+ #define ANALOG_IN_PIN P0_6
+ #define LED_DIG_OUT_PIN P0_8 //RTS
+ #define HAPTIC_PIN P0_5
+ #define PIEZO_PIN P0_4
+#endif
+#define LED_HEADER 0x01
+#define ONOFF_HEADER 0x11
+#define COLOR_HEADER 0x22
+#define PATTERN_HEADER 0x33
+#define HAPTIC_HEADER 0x44
+#define PIEZO_HEADER 0x55
+#define ALARM_HEADER 0x66
+
+#define NUM_LEDS 7
+
+#define PATTERN_NONE 0x00
+#define PATTERN_ON 0x01
+#define PATTERN_FAST 0x02
+#define PATTERN_SLOW 0x03
+#define PATTERN_CHASE 0x04
+#define PATTERN_MRB 0x05
+#define PATTERN_RAINBOW 0x06
+#define PATTERN_CANDY 0x07
+#define PATTERN_SNOW 0x08
+#define PATTERN_XMAS 0x09
+#define PATTERN_ICE 0x0A
+#define PATTERN_COL 0x0B
+#define PATTERN_IRON 0x0C
+#define PATTERN_SPRING 0x0D
+#define PATTERN_EASTER 0x0E
+#define PATTERN_MEM 0x0F
+
+#define LEDS_ON 0x01
+#define LEDS_OFF 0x02
+#define PIEZO_ON 0x01
+#define PIEZO_OFF 0x02
+#define ALARM_ON 0x01
+#define ALARM_OFF 0x02
+#define HAPTIC_ON 0x01
+#define HAPTIC_OFF 0x02
+
+#define RINGTONE_COL 0x70
+#define RINGTONE_ONE 0x71
+#define RINGTONE_TWO 0x72
+#define RINGTONE_THREE 0x73
+#define RINGTONE_NONE 0x74
+
+#define HAPTIC_10 0x10
+#define HAPTIC_30 0x30
+#define HAPTIC_60 0x60
+#define BUZZ_LEVEL1 0x51
+#define BUZZ_LEVEL2 0x52
+#define BUZZ_LEVEL3 0x53
+
+BLE ble;
+#ifdef VIQ
+ DigitalOut LED_SET(BOARD_LED);
+ DigitalIn BUTTON(DIGITAL_IN_PIN);
+ DigitalOut BUZZER(HAPTIC_PIN);
+ PwmOut PIEZO(PIEZO_PIN);
+ PwmOut PWM(PWM_PIN);
+ AnalogIn ANALOG(ANALOG_IN_PIN);
+
+ InterruptIn pb(DIGITAL_IN_PIN);
+ uint8_t dig_pin_num = LED_DIG_OUT_PIN;
+#endif
+//Serial pc(USBTX, USBRX);
+static uint8_t old_state = 0;
+neopixel_strip_t m_strip;
+
+uint8_t slow_count = 0;
+//uint8_t error;
+uint8_t led_to_enable = 2; //10;
+uint8_t red = 255;
+uint8_t green = 0;
+uint8_t blue = 0;
+uint8_t pattern = 0;
+uint8_t mPiezoOn = 0;
+uint8_t mHapticOn = 0;
+uint8_t mAlarmOn = 0;
+uint8_t mHapticDur, mHapticPattern;
+uint8_t mPiezoDur, mPiezoPattern;
+uint8_t mAlarmDur, mAlarmPiezoOn, mAlarmTone, mAlarmPattern;
+
+char mDeviceName[128];
+int mLength;
+
+uint8_t LEDS_ON_FLAG = 0;
+
+Timer t_alarm;
+float mBeginAlarm, mEndAlarm;
+
+/* Setup auxiliary services. */
+//const static char DEVICE_NAME[] = "RRVA BLE";
+static const uint16_t uuid16_list[] = {GattService::UUID_DEVICE_INFORMATION_SERVICE};
+DeviceInformationService *deviceInfo;
+
+// The Nordic UART Service
+static const uint8_t uart_base_uuid[] = {0x71, 0x3D, 0, 0, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
+static const uint8_t uart_tx_uuid[] = {0x71, 0x3D, 0, 3, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
+static const uint8_t uart_rx_uuid[] = {0x71, 0x3D, 0, 2, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
+static const uint8_t uart_base_uuid_rev[] = {0x1E, 0x94, 0x8D, 0xF1, 0x48, 0x31, 0x94, 0xBA, 0x75, 0x4C, 0x3E, 0x50, 0, 0, 0x3D, 0x71};
+
+int freq_shave[] = {NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 1, NOTE_B3, NOTE_C4};
+int beat_shave[] = {4, 8, 8, 4, 4, 4, 4, 4 };
+int freq_coll[] = {NOTE_C4, NOTE_B4, NOTE_B4, NOTE_A4, NOTE_G4, NOTE_A4, NOTE_G4, NOTE_G4,
+ NOTE_F4, NOTE_E4, NOTE_D3, NOTE_E4, NOTE_F4, NOTE_G4, NOTE_A4, NOTE_F4,
+ NOTE_D4, NOTE_C3, NOTE_E4, NOTE_G4, NOTE_C4, NOTE_E5, NOTE_D4, NOTE_C4,
+ NOTE_G4, NOTE_G4, NOTE_C4, NOTE_G4};
+int beat_coll[] = {6, 2, 2, 2, 4, 6, 2, 2, 2, 4, 4, 2, 2, 2,
+ 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 2, 2};
+
+uint8_t txPayload[TXRX_BUF_LEN] = {0,};
+uint8_t rxPayload[TXRX_BUF_LEN] = {0,};
+
+GattCharacteristic txCharacteristic (uart_tx_uuid, txPayload, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE);
+GattCharacteristic rxCharacteristic (uart_rx_uuid, rxPayload, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
+GattCharacteristic *uartChars[] = {&txCharacteristic, &rxCharacteristic};
+GattService uartService(uart_base_uuid, uartChars, sizeof(uartChars) / sizeof(GattCharacteristic *));
+void setup_advertising(void);
+
+void rainbowCycle(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
+void candyChase(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
+void snowflakes(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
+void iceflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip);
+void xmas(int delay, uint8_t numLEDs, neopixel_strip_t m_strip);
+void collegiate(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
+void irondude(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
+void easter(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
+void spring(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
+void memorial(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
+
+//extern uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority,
+// nrf_radio_notification_distance_t distance,
+// ble_radio_notification_evt_handler_t evt_handler);
\ No newline at end of file
--- a/vector_iq.h Wed Apr 19 21:20:31 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-/*
-
-Copyright (c) 2017 Radiant RVA
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-and associated documentation files (the "Software"), to deal in the Software without restriction,
-including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
-FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-
-#include "mbed.h"
-#include "neopixel.h"
-#include "ble/BLE.h"
-#include "GattCallbackParamTypes.h"
-#include "DFUService.h"
-#include "pitches.h"
-#include <DeviceInformationService.h>
-extern "C" {
-#include "ble_radio_notification.h"
-}
-#define BLE_UUID_TXRX_SERVICE 0x0000 /**< The UUID of the Nordic UART Service. */
-#define BLE_UUID_TX_CHARACTERISTIC 0x0002 /**< The UUID of the TX Characteristic. */
-#define BLE_UUIDS_RX_CHARACTERISTIC 0x0003 /**< The UUID of the RX Characteristic. */
-
-#define TXRX_BUF_LEN 20
-
-#define DIGITAL_OUT_PIN P0_17
-#define BOARD_LED P0_19
-#define DIGITAL_IN_PIN P0_9
-#define PWM_PIN P0_16
-#define SERVO_PIN P0_14
-#define ANALOG_IN_PIN P0_6
-#define LED_DIG_OUT_PIN P0_8 //RTS
-#define HAPTIC_PIN P0_5
-#define PIEZO_PIN P0_4
-
-#define LED_HEADER 0x01
-#define ONOFF_HEADER 0x11
-#define COLOR_HEADER 0x22
-#define PATTERN_HEADER 0x33
-#define HAPTIC_HEADER 0x44
-#define PIEZO_HEADER 0x55
-#define ALARM_HEADER 0x66
-
-#define NUM_LEDS 7
-
-#define PATTERN_NONE 0x00
-#define PATTERN_ON 0x01
-#define PATTERN_FAST 0x02
-#define PATTERN_SLOW 0x03
-#define PATTERN_CHASE 0x04
-#define PATTERN_MRB 0x05
-#define PATTERN_RAINBOW 0x06
-#define PATTERN_CANDY 0x07
-#define PATTERN_SNOW 0x08
-#define PATTERN_XMAS 0x09
-#define PATTERN_ICE 0x0A
-#define PATTERN_COL 0x0B
-#define PATTERN_IRON 0x0C
-#define PATTERN_SPRING 0x0D
-#define PATTERN_EASTER 0x0E
-#define PATTERN_MEM 0x0F
-
-#define LEDS_ON 0x01
-#define LEDS_OFF 0x02
-#define PIEZO_ON 0x01
-#define PIEZO_OFF 0x02
-#define ALARM_ON 0x01
-#define ALARM_OFF 0x02
-#define HAPTIC_ON 0x01
-#define HAPTIC_OFF 0x02
-
-#define RINGTONE_COL 0x70
-#define RINGTONE_ONE 0x71
-#define RINGTONE_TWO 0x72
-#define RINGTONE_THREE 0x73
-#define RINGTONE_NONE 0x74
-
-#define HAPTIC_10 0x10
-#define HAPTIC_30 0x30
-#define HAPTIC_60 0x60
-#define BUZZ_LEVEL1 0x51
-#define BUZZ_LEVEL2 0x52
-#define BUZZ_LEVEL3 0x53
-
-BLE ble;
-
-DigitalOut LED_SET(BOARD_LED);
-DigitalIn BUTTON(DIGITAL_IN_PIN);
-DigitalOut BUZZER(HAPTIC_PIN);
-PwmOut PIEZO(PIEZO_PIN);
-PwmOut PWM(PWM_PIN);
-AnalogIn ANALOG(ANALOG_IN_PIN);
-
-InterruptIn pb(DIGITAL_IN_PIN);
-
-//Serial pc(USBTX, USBRX);
-static uint8_t old_state = 0;
-neopixel_strip_t m_strip;
-uint8_t dig_pin_num = LED_DIG_OUT_PIN;
-uint8_t slow_count = 0;
-//uint8_t error;
-uint8_t led_to_enable = 2; //10;
-uint8_t red = 255;
-uint8_t green = 0;
-uint8_t blue = 0;
-uint8_t pattern = 0;
-uint8_t mPiezoOn = 0;
-uint8_t mHapticOn = 0;
-uint8_t mAlarmOn = 0;
-uint8_t mHapticDur, mHapticPattern;
-uint8_t mPiezoDur, mPiezoPattern;
-uint8_t mAlarmDur, mAlarmPiezoOn, mAlarmTone, mAlarmPattern;
-
-char mDeviceName[128];
-int mLength;
-
-uint8_t LEDS_ON_FLAG = 0;
-
-Timer t_alarm;
-float mBeginAlarm, mEndAlarm;
-
-/* Setup auxiliary services. */
-//const static char DEVICE_NAME[] = "RRVA BLE";
-static const uint16_t uuid16_list[] = {GattService::UUID_DEVICE_INFORMATION_SERVICE};
-DeviceInformationService *deviceInfo;
-
-// The Nordic UART Service
-static const uint8_t uart_base_uuid[] = {0x71, 0x3D, 0, 0, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
-static const uint8_t uart_tx_uuid[] = {0x71, 0x3D, 0, 3, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
-static const uint8_t uart_rx_uuid[] = {0x71, 0x3D, 0, 2, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
-static const uint8_t uart_base_uuid_rev[] = {0x1E, 0x94, 0x8D, 0xF1, 0x48, 0x31, 0x94, 0xBA, 0x75, 0x4C, 0x3E, 0x50, 0, 0, 0x3D, 0x71};
-
-int freq_shave[] = {NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 1, NOTE_B3, NOTE_C4};
-int beat_shave[] = {4, 8, 8, 4, 4, 4, 4, 4 };
-int freq_coll[] = {NOTE_C4, NOTE_B4, NOTE_B4, NOTE_A4, NOTE_G4, NOTE_A4, NOTE_G4, NOTE_G4,
- NOTE_F4, NOTE_E4, NOTE_D3, NOTE_E4, NOTE_F4, NOTE_G4, NOTE_A4, NOTE_F4,
- NOTE_D4, NOTE_C3, NOTE_E4, NOTE_G4, NOTE_C4, NOTE_E5, NOTE_D4, NOTE_C4,
- NOTE_G4, NOTE_G4, NOTE_C4, NOTE_G4};
-int beat_coll[] = {6, 2, 2, 2, 4, 6, 2, 2, 2, 4, 4, 2, 2, 2,
- 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 2, 2};
-
-uint8_t txPayload[TXRX_BUF_LEN] = {0,};
-uint8_t rxPayload[TXRX_BUF_LEN] = {0,};
-
-GattCharacteristic txCharacteristic (uart_tx_uuid, txPayload, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE);
-GattCharacteristic rxCharacteristic (uart_rx_uuid, rxPayload, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
-GattCharacteristic *uartChars[] = {&txCharacteristic, &rxCharacteristic};
-GattService uartService(uart_base_uuid, uartChars, sizeof(uartChars) / sizeof(GattCharacteristic *));
-void setup_advertising(void);
-
-void rainbowCycle(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
-void candyChase(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
-void snowflakes(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
-void iceflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip);
-void xmas(int delay, uint8_t numLEDs, neopixel_strip_t m_strip);
-void collegiate(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
-void irondude(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
-void easter(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
-void spring(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
-void memorial(int wait, uint8_t numLEDs, neopixel_strip_t m_strip);
-
-extern uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority,
- nrf_radio_notification_distance_t distance,
- ble_radio_notification_evt_handler_t evt_handler);
\ No newline at end of file
