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
vector_iq.h
00001 /* 00002 00003 Copyright (c) 2017 Radiant RVA 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00006 and associated documentation files (the "Software"), to deal in the Software without restriction, 00007 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 00009 subject to the following conditions: 00010 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 00011 00012 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 00013 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 00014 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 00015 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00016 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 00018 */ 00019 00020 #include "mbed.h" 00021 #include "neopixel.h" 00022 #include "ble/BLE.h" 00023 #include "GattCallbackParamTypes.h" 00024 #include "DFUService.h" 00025 #include "pitches.h" 00026 #include <DeviceInformationService.h> 00027 extern "C" { 00028 #include "ble_radio_notification.h" 00029 } 00030 #define BLE_UUID_TXRX_SERVICE 0x0000 /**< The UUID of the Nordic UART Service. */ 00031 #define BLE_UUID_TX_CHARACTERISTIC 0x0002 /**< The UUID of the TX Characteristic. */ 00032 #define BLE_UUIDS_RX_CHARACTERISTIC 0x0003 /**< The UUID of the RX Characteristic. */ 00033 00034 #define TXRX_BUF_LEN 20 00035 00036 #ifdef VIQ 00037 #define DIGITAL_OUT_PIN P0_17 00038 #define BOARD_LED P0_19 00039 #define DIGITAL_IN_PIN P0_9 00040 #define PWM_PIN P0_16 00041 #define SERVO_PIN P0_14 00042 #define ANALOG_IN_PIN P0_6 00043 #define LED_DIG_OUT_PIN P0_28 //RTS 00044 #define HAPTIC_PIN P0_5 00045 #define PIEZO_PIN P0_4 00046 #endif 00047 00048 #define LED_HEADER 0x01 00049 #define ONOFF_HEADER 0x11 00050 #define COLOR_HEADER 0x22 00051 #define PATTERN_HEADER 0x33 00052 #define HAPTIC_HEADER 0x44 00053 #define PIEZO_HEADER 0x55 00054 #define ALARM_HEADER 0x66 00055 00056 #define NUM_LEDS 7 00057 00058 #define PATTERN_NONE 0x00 00059 #define PATTERN_ON 0x01 00060 #define PATTERN_FAST 0x02 00061 #define PATTERN_SLOW 0x03 00062 #define PATTERN_CHASE 0x04 00063 #define PATTERN_MRB 0x05 00064 #define PATTERN_RAINBOW 0x06 00065 #define PATTERN_CANDY 0x07 00066 #define PATTERN_SNOW 0x08 00067 #define PATTERN_XMAS 0x09 00068 #define PATTERN_ICE 0x0A 00069 #define PATTERN_COL 0x0B 00070 #define PATTERN_IRON 0x0C 00071 #define PATTERN_SPRING 0x0D 00072 #define PATTERN_EASTER 0x0E 00073 #define PATTERN_MEM 0x0F 00074 00075 #define LEDS_ON 0x01 00076 #define LEDS_OFF 0x02 00077 #define PIEZO_ON 0x01 00078 #define PIEZO_OFF 0x02 00079 #define ALARM_ON 0x01 00080 #define ALARM_OFF 0x02 00081 #define HAPTIC_ON 0x01 00082 #define HAPTIC_OFF 0x02 00083 00084 #define RINGTONE_COL 0x70 00085 #define RINGTONE_ONE 0x71 00086 #define RINGTONE_TWO 0x72 00087 #define RINGTONE_THREE 0x73 00088 #define RINGTONE_NONE 0x74 00089 00090 #define HAPTIC_10 0x10 00091 #define HAPTIC_30 0x30 00092 #define HAPTIC_60 0x60 00093 #define BUZZ_LEVEL1 0x51 00094 #define BUZZ_LEVEL2 0x52 00095 #define BUZZ_LEVEL3 0x53 00096 00097 BLE ble; 00098 #ifdef VIQ 00099 DigitalOut LED_SET(BOARD_LED); 00100 DigitalIn BUTTON(DIGITAL_IN_PIN); 00101 DigitalOut BUZZER(HAPTIC_PIN); 00102 PwmOut PIEZO(PIEZO_PIN); 00103 PwmOut PWM(PWM_PIN); 00104 AnalogIn ANALOG(ANALOG_IN_PIN); 00105 00106 InterruptIn pb(DIGITAL_IN_PIN); 00107 uint8_t dig_pin_num = LED_DIG_OUT_PIN; 00108 #endif 00109 //Serial pc(USBTX, USBRX); 00110 static uint8_t old_state = 0; 00111 neopixel_strip_t m_strip; 00112 00113 uint8_t slow_count = 0; 00114 //uint8_t error; 00115 uint8_t led_to_enable = 2; //10; 00116 uint8_t red = 255; 00117 uint8_t green = 0; 00118 uint8_t blue = 0; 00119 uint8_t pattern = 0; 00120 uint8_t mPiezoOn = 0; 00121 uint8_t mHapticOn = 0; 00122 uint8_t mAlarmOn = 0; 00123 uint8_t mHapticDur, mHapticPattern; 00124 uint8_t mPiezoDur, mPiezoPattern; 00125 uint8_t mAlarmDur, mAlarmPiezoOn, mAlarmTone, mAlarmPattern; 00126 00127 char mDeviceName[128]; 00128 int mLength; 00129 00130 uint8_t LEDS_ON_FLAG = 0; 00131 00132 Timer t_alarm; 00133 float mBeginAlarm, mEndAlarm; 00134 00135 /* Setup auxiliary services. */ 00136 //const static char DEVICE_NAME[] = "RRVA BLE"; 00137 static const uint16_t uuid16_list[] = {GattService::UUID_DEVICE_INFORMATION_SERVICE}; 00138 DeviceInformationService *deviceInfo; 00139 00140 // The Nordic UART Service 00141 static const uint8_t uart_base_uuid[] = {0x71, 0x3D, 0, 0, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E}; 00142 static const uint8_t uart_tx_uuid[] = {0x71, 0x3D, 0, 3, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E}; 00143 static const uint8_t uart_rx_uuid[] = {0x71, 0x3D, 0, 2, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E}; 00144 static const uint8_t uart_base_uuid_rev[] = {0x1E, 0x94, 0x8D, 0xF1, 0x48, 0x31, 0x94, 0xBA, 0x75, 0x4C, 0x3E, 0x50, 0, 0, 0x3D, 0x71}; 00145 00146 int freq_shave[] = {NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 1, NOTE_B3, NOTE_C4}; 00147 int beat_shave[] = {4, 8, 8, 4, 4, 4, 4, 4 }; 00148 int freq_coll[] = {NOTE_C4, NOTE_B4, NOTE_B4, NOTE_A4, NOTE_G4, NOTE_A4, NOTE_G4, NOTE_G4, 00149 NOTE_F4, NOTE_E4, NOTE_D3, NOTE_E4, NOTE_F4, NOTE_G4, NOTE_A4, NOTE_F4, 00150 NOTE_D4, NOTE_C3, NOTE_E4, NOTE_G4, NOTE_C4, NOTE_E5, NOTE_D4, NOTE_C4, 00151 NOTE_G4, NOTE_G4, NOTE_C4, NOTE_G4}; 00152 int beat_coll[] = {6, 2, 2, 2, 4, 6, 2, 2, 2, 4, 4, 2, 2, 2, 00153 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 2, 2}; 00154 00155 uint8_t txPayload[TXRX_BUF_LEN] = {0,}; 00156 uint8_t rxPayload[TXRX_BUF_LEN] = {0,}; 00157 00158 GattCharacteristic txCharacteristic (uart_tx_uuid, txPayload, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE); 00159 GattCharacteristic rxCharacteristic (uart_rx_uuid, rxPayload, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); 00160 GattCharacteristic *uartChars[] = {&txCharacteristic, &rxCharacteristic}; 00161 GattService uartService(uart_base_uuid, uartChars, sizeof(uartChars) / sizeof(GattCharacteristic *)); 00162 void setup_advertising(void); 00163 00164 void rainbowCycle(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); 00165 void candyChase(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); 00166 void snowflakes(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); 00167 void iceflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip); 00168 void xmas(int delay, uint8_t numLEDs, neopixel_strip_t m_strip); 00169 void collegiate(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); 00170 void irondude(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); 00171 void easter(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); 00172 void spring(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); 00173 void memorial(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); 00174 00175 //extern uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority, 00176 // nrf_radio_notification_distance_t distance, 00177 // ble_radio_notification_evt_handler_t evt_handler);
Generated on Tue Jul 12 2022 21:09:08 by
1.7.2
