This is an example program for the PololuLedStrip library. It generates a simple moving gradient pattern.

Dependencies:   PololuLedStrip mbed LedStripGradient

Dependents:   LedStripGradient led_phare_crf

For more information, see the PololuLedStrip library.

Files at this revision

API Documentation at this revision

Comitter:
DavidEGrayson
Date:
Tue Feb 26 02:25:19 2013 +0000
Parent:
4:27b5c9cafe92
Child:
6:59f1db26a9ff
Commit message:
Made a tiny pulse using assembly! We are like half-way there!

Changed in this revision

led_strip.s Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/led_strip.s	Tue Feb 26 02:18:55 2013 +0000
+++ b/led_strip.s	Tue Feb 26 02:25:19 2013 +0000
@@ -1,13 +1,23 @@
     AREA asm_func, CODE, READONLY
-    EXPORT led_strip_write
-led_strip_write
+    EXPORT led_strip_write_color
+led_strip_write_color
     push    {R9,R10}
-    LDR     R9, =0x2009C020 ; 0x2009C020 = GPIO port 1 base address
-    MOV.W   R10, #0x040000   ; 0x040000 = 1<<18 all "0"s with a "1" in bit 18
-    CMP     R3, #0          ; value == 0 ?
-    ITE EQ
-    STREQ   R10, [R2,#0]  ; if==0, clear LED1 bit
-    STRNE   R10, [R1,#0]  ; if==1, set LED1 bit
+;    LDR     R9, =0x2009C020 ; 0x2009C020 = GPIO port 1 base address
+;    MOV.W   R10, #0x040000   ; 0x040000 = 1<<18 all "0"s with a "1" in bit 18
+;    CMP     R3, #0          ; value == 0 ?
+;    ITE EQ
+    STR   R3, [R1,#0]  ; set
+    NOP
+    NOP
+    NOP
+    NOP
+    NOP
+    NOP
+    NOP
+    NOP
+    NOP
+    NOP
+    STR   R3, [R2,#0]  ; clear
     pop     {R9,R10}
     BX      LR
     END
\ No newline at end of file
--- a/main.cpp	Tue Feb 26 02:18:55 2013 +0000
+++ b/main.cpp	Tue Feb 26 02:25:19 2013 +0000
@@ -11,7 +11,7 @@
   } rgb_color;
   #endif
 
-  extern "C" int led_strip_write(rgb_color *, volatile uint32_t * set, volatile uint32_t * clear, uint32_t mask);
+  extern "C" int led_strip_write_color(rgb_color *, volatile uint32_t * set, volatile uint32_t * clear, uint32_t mask);
 
   class PololuLedStrip
   {
@@ -102,15 +102,18 @@
 
 DigitalOut myled2(LED2);
 
+#define LED_COUNT 60
+rgb_color colors[LED_COUNT];
+
 int main() {
     gpio_t gpio;
-    gpio_init(&gpio, LED1, PIN_OUTPUT);
+    gpio_init(&gpio, p8, PIN_OUTPUT);
 
     while(1) {
         myled2 = 1;
-        led_strip_write(NULL, gpio.reg_set, gpio.reg_clr, 1);
+        led_strip_write_color(colors, gpio.reg_set, gpio.reg_clr, gpio.mask);
         wait(0.2);
-        led_strip_write(NULL, gpio.reg_set, gpio.reg_clr, 0);
+        led_strip_write_color(colors, gpio.reg_set, gpio.reg_clr, gpio.mask);
         myled2 = 0;
         wait(1);
     }