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.
Dependencies: BLE_API mbed nRF51822
Fork of nRF51822_SimpleControls by
Revision 8:e275405a431d, committed 2016-12-16
- Comitter:
- MarkSPA
- Date:
- Fri Dec 16 00:02:07 2016 +0000
- Parent:
- 7:0db51a3107fc
- Child:
- 9:02ac9f6bb320
- Commit message:
- New Pattern
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| patterns.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Dec 15 23:25:16 2016 +0000
+++ b/main.cpp Fri Dec 16 00:02:07 2016 +0000
@@ -56,6 +56,7 @@
#define PATTERN_XMAS 0x09
#define PATTERN_ICE 0x0A
#define PATTERN_COL 0x0B
+#define PATTERN_IRON 0x0C
#define LEDS_ON 0x01
#define LEDS_OFF 0x02
@@ -106,6 +107,7 @@
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);
extern uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority,
nrf_radio_notification_distance_t distance,
@@ -226,7 +228,9 @@
neopixel_show(&m_strip);
} else if (pattern == PATTERN_MRB) {
- neopixel_clear(&m_strip);
+ //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);
@@ -250,6 +254,9 @@
else if (pattern == PATTERN_COL)
collegiate(100, NUM_LEDS, m_strip);
+ else if (pattern == PATTERN_IRON)
+ irondude(250, NUM_LEDS, m_strip);
+
else
neopixel_clear(&m_strip);
--- a/patterns.cpp Thu Dec 15 23:25:16 2016 +0000
+++ b/patterns.cpp Fri Dec 16 00:02:07 2016 +0000
@@ -105,7 +105,7 @@
int led_to_enable = rand()%numLEDs;
neopixel_set_color(&m_strip, led_to_enable, 0, 0, 235); // set random blue
neopixel_show(&m_strip);
- wait_ms(delay);
+ //wait_ms(delay);
}
void xmas(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
@@ -141,4 +141,23 @@
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);
+ }
}
\ No newline at end of file
