raytac dongle only has 1 led populated
This commit is contained in:
1 parent
77e7f7cf8e
commit
e6812abe3a
3 files changed
+26
-13
No files matched your search
+2
-2
@@ -525,8 +525,8 @@ mdbt50qrx.build.f_cpu=64000000
|
||||
mdbt50qrx.build.board=MDBT50Q_RX
|
||||
mdbt50qrx.build.core=nRF5
|
||||
mdbt50qrx.build.variant=raytac_mdbt50q_rx
|
||||
mdbt50qrx.build.usb_manufacturer="Raytac Corporation"
|
||||
mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX"
|
||||
mdbt50qrx.build.usb_manufacturer="Raytac"
|
||||
mdbt50qrx.build.usb_product="nRF52840 Dongle"
|
||||
mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld
|
||||
mdbt50qrx.build.vid=0x239A
|
||||
|
||||
@@ -130,7 +130,7 @@ void setup()
|
||||
lsbLED.setPermission(SECMODE_OPEN, SECMODE_OPEN);
|
||||
lsbLED.setFixedLen(1);
|
||||
lsbLED.begin();
|
||||
lsbLED.write8(0x00); // led = off
|
||||
lsbLED.write8(0x01); // led = on when connected
|
||||
|
||||
lsbLED.setWriteCallback(led_write_callback);
|
||||
|
||||
@@ -167,6 +167,19 @@ void startAdv(void)
|
||||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
||||
}
|
||||
|
||||
void setLED(bool on)
|
||||
{
|
||||
// data = 1 -> LED = On
|
||||
// data = 0 -> LED = Off
|
||||
digitalWrite(LED_BUILTIN, on ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||
|
||||
#ifdef PIN_NEOPIXEL
|
||||
uint32_t c = neopixel.Color(0x00, 0x00, on ? 0x20 : 0x00);
|
||||
neopixel.fill(c, 0, NEOPIXEL_NUM);
|
||||
neopixel.show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void led_write_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
(void) conn_hdl;
|
||||
@@ -175,13 +188,7 @@ void led_write_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data
|
||||
|
||||
// data = 1 -> LED = On
|
||||
// data = 0 -> LED = Off
|
||||
digitalWrite(LED_BUILTIN, data[0] ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||
|
||||
#ifdef PIN_NEOPIXEL
|
||||
uint32_t c = neopixel.Color(0x00, 0x00, data[0] ? 0x20 : 0x00);
|
||||
neopixel.fill(c, 0, NEOPIXEL_NUM);
|
||||
neopixel.show();
|
||||
#endif
|
||||
setLED(data[0]);
|
||||
}
|
||||
|
||||
void loop()
|
||||
@@ -212,6 +219,9 @@ void connect_callback(uint16_t conn_handle)
|
||||
{
|
||||
(void) conn_handle;
|
||||
|
||||
setLED(true);
|
||||
lsbLED.write8(0x01);
|
||||
|
||||
connection_count++;
|
||||
Serial.print("Connection count: ");
|
||||
Serial.println(connection_count);
|
||||
@@ -234,6 +244,9 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason)
|
||||
(void) conn_handle;
|
||||
(void) reason;
|
||||
|
||||
setLED(false);
|
||||
lsbLED.write8(0x00);
|
||||
|
||||
Serial.println();
|
||||
Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX);
|
||||
|
||||
|
||||
@@ -44,13 +44,13 @@ extern "C"
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED1 (0)
|
||||
#define PIN_LED2 (1)
|
||||
#define PIN_LED2 (1) // LED2 is not populated by default
|
||||
|
||||
#define LED_BUILTIN PIN_LED1
|
||||
#define LED_CONN PIN_LED2
|
||||
#define LED_CONN PIN_LED1
|
||||
|
||||
#define LED_RED PIN_LED1
|
||||
#define LED_BLUE PIN_LED2
|
||||
#define LED_BLUE PIN_LED1
|
||||
|
||||
#define LED_STATE_ON 0 // State when LED is litted
|
||||
|
||||
|
||||
Reference in new issue
Block a user