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.
Diff: main.cpp
- Revision:
- 1:2fae6f119cf4
- Parent:
- 0:e30668e5984b
- Child:
- 2:8a8a848727d5
--- a/main.cpp Wed Jul 29 01:38:22 2015 +0000
+++ b/main.cpp Wed Jul 29 19:13:19 2015 +0000
@@ -55,6 +55,8 @@
void blinkSpecial() {
// level must be from (0 to 127) <<1
+ const int repeats = 1;
+
uint8_t level = 0x01;
char bytes[28] = {START_BYTE, SLAVE_ADDR_ID, SPECIAL_MODE,
@@ -79,7 +81,7 @@
bytes[21] = level<<1; bytes[22] = 0x00<<1;
bytes[24] = level<<1; bytes[25] = 0x00<<1;
- for(int repeats=4; repeats>0; repeats--){
+ for(int r=repeats; r>0; r--){
for(int i=0; i<28; i++){
spi.write(bytes[i]);
}
@@ -96,7 +98,7 @@
bytes[21] = 0x00<<1; bytes[22] = level<<1;
bytes[24] = 0x00<<1; bytes[25] = level<<1;
- for(int repeats=4; repeats>0; repeats--){
+ for(int r=repeats; r>0; r--){
for(int i=0; i<28; i++){
spi.write(bytes[i]);
}
@@ -113,17 +115,17 @@
//wait_ms(4); //wait for device ready (datasheet 9.7)
}
-void blink(uint8_t led_address) {
- wait_ms(250);
+void fastblink(uint8_t led_address) {
+ wait_ms(3);
setLevel(led_address, (0x10)<<1);
- wait_ms(250);
+ wait_ms(3);
setLevel(led_address, (0x00)<<1);
}
-void blinkAll(void) {
- wait_ms(250);
- setLevel(ALL_CHANNEL_SELECT, (0x10)<<1);
- wait_ms(250);
+void blinkAll(uint8_t level) {
+ wait_ms(500);
+ setLevel(ALL_CHANNEL_SELECT, (level)<<1);
+ wait(1/30.0);
setLevel(ALL_CHANNEL_SELECT, (0x00)<<1);
}
@@ -132,7 +134,7 @@
// Setup the spi for 8 bit data, high steady state clock,
// second edge capture, with a 1MHz clock rate
- spi.format(8,3);
+ spi.format(8,1);
spi.frequency(8000000);
pc.baud(57600);
@@ -153,10 +155,10 @@
uint8_t color = colors[color_index];
pc.printf("blinking subaddress %s\n\r", byte_to_binary((channel + color)<<1));
- //blink((channel + color)<<1);
+ fastblink((channel + color)<<1);
//blink((0x01)<<1);
- //blinkAll();
- blinkSpecial();
+ //blinkAll(127);
+ //blinkSpecial();
//setLevel((channel + color)<<1, level<<1);
}