Skip to content

Commit

Permalink
Fix doc & flash size for some targets
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelj committed May 11, 2016
1 parent 6a66272 commit 3913722
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 66 deletions.
102 changes: 51 additions & 51 deletions docs/LedStrip.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,57 +246,6 @@ This mode toggles LEDs between green and blue when disarmed and armed, respectiv

Note: Armed State cannot be used with Flight Mode.

### Mode Colors Assignement

Mode Colors can be configured using the cli `mode_color` command.

- No arguments: lists all mode colors
- arguments: mode, function, color

First 6 groups of ModeIndexes are :

| mode | name |
|------|-------------|
| 0 | orientation |
| 1 | headfree |
| 2 | horizon |
| 3 | angle |
| 4 | mag |
| 5 | baro |
| 6 | special |

Modes 0 to 5 functions:

| function | name |
|----------|-------|
| 0 | north |
| 1 | east |
| 2 | south |
| 3 | west |
| 4 | up |
| 5 | down |

Mode 6 use these functions:

| function | name |
|----------|--------------------|
| 0 | disarmed |
| 1 | armed |
| 2 | animation |
| 3 | background |
| 4 | blink background |
| 5 | gps: no satellites |
| 6 | gps: no fix |
| 7 | gps: 3D fix |

The ColorIndex is picked from the colors array ("palette").

Examples (using the default colors):

- set armed color to red: ```mode_color 6 1 2```
- set disarmed color to yellow: ```mode_color 6 0 4```
- set Headfree mode 'south' to Cyan: ```mode_color 1 2 8```

#### Thrust state

This mode fades the LED current LED color to the previous/next color in the HSB color space depending on throttle stick position. When the
Expand Down Expand Up @@ -385,6 +334,57 @@ color 14 0,0,0
color 15 0,0,0
```

### Mode Colors Assignement

Mode Colors can be configured using the cli `mode_color` command.

- No arguments: lists all mode colors
- arguments: mode, function, color

First 6 groups of ModeIndexes are :

| mode | name |
|------|-------------|
| 0 | orientation |
| 1 | headfree |
| 2 | horizon |
| 3 | angle |
| 4 | mag |
| 5 | baro |
| 6 | special |

Modes 0 to 5 functions:

| function | name |
|----------|-------|
| 0 | north |
| 1 | east |
| 2 | south |
| 3 | west |
| 4 | up |
| 5 | down |

Mode 6 use these functions:

| function | name |
|----------|--------------------|
| 0 | disarmed |
| 1 | armed |
| 2 | animation |
| 3 | background |
| 4 | blink background |
| 5 | gps: no satellites |
| 6 | gps: no fix |
| 7 | gps: 3D fix |

The ColorIndex is picked from the colors array ("palette").

Examples (using the default colors):

- set armed color to red: ```mode_color 6 1 2```
- set disarmed color to yellow: ```mode_color 6 0 4```
- set Headfree mode 'south' to Cyan: ```mode_color 1 2 8```

## Positioning

Cut the strip into sections as per diagrams below. When the strips are cut ensure you reconnect each output to each input with cable where the break is made.
Expand Down
29 changes: 14 additions & 15 deletions src/main/io/ledstrip.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ void determineLedStripDimensions(void)

const ledConfig_t *ledConfig;

for (int ledIndex = 0; ledIndex < ledCount; ledIndex++) {
for (uint8_t ledIndex = 0; ledIndex < ledCount; ledIndex++) {
ledConfig = ledConfigs(ledIndex);

if (GET_LED_X(ledConfig) >= ledGridWidth) {
Expand All @@ -335,9 +335,9 @@ void determineOrientationLimits(void)

void updateLedCount(void)
{
int count = 0, countRing = 0;
uint8_t count = 0, countRing = 0;

for (int ledIndex = 0; ledIndex < MAX_LED_STRIP_LENGTH; ledIndex++) {
for (uint8_t ledIndex = 0; ledIndex < MAX_LED_STRIP_LENGTH; ledIndex++) {
const ledConfig_t *ledConfig = ledConfigs(ledIndex);
if (ledConfig->flags == 0 && ledConfig->xy == 0)
break;
Expand Down Expand Up @@ -381,7 +381,7 @@ bool parseLedStripConfig(uint8_t ledIndex, const char *config)
char chunkSeparator = chunkSeparators[parseState];

memset(&chunk, 0, sizeof(chunk));
int chunkIndex = 0;
uint8_t chunkIndex = 0;

while (*config && chunkIndex < CHUNK_BUFFER_SIZE && *config != chunkSeparator) {
chunk[chunkIndex++] = *config++;
Expand All @@ -404,7 +404,7 @@ bool parseLedStripConfig(uint8_t ledIndex, const char *config)
break;

case DIRECTIONS:
for (int chunkIndex = 0; chunk[chunkIndex] && chunkIndex < CHUNK_BUFFER_SIZE; chunkIndex++) {
for (uint8_t chunkIndex = 0; chunk[chunkIndex] && chunkIndex < CHUNK_BUFFER_SIZE; chunkIndex++) {
for (unsigned mappingIndex = 0; mappingIndex < DIRECTION_COUNT; mappingIndex++) {
if (directionCodes[mappingIndex] == chunk[chunkIndex]) {
ledConfig->flags |= directionMappings[mappingIndex];
Expand All @@ -415,7 +415,7 @@ bool parseLedStripConfig(uint8_t ledIndex, const char *config)
break;

case FUNCTIONS:
for (int chunkIndex = 0; chunk[chunkIndex] && chunkIndex < CHUNK_BUFFER_SIZE; chunkIndex++) {
for (uint8_t chunkIndex = 0; chunk[chunkIndex] && chunkIndex < CHUNK_BUFFER_SIZE; chunkIndex++) {
for (unsigned mappingIndex = 0; mappingIndex < FUNCTION_COUNT; mappingIndex++) {
if (functionCodes[mappingIndex] == chunk[chunkIndex]) {
ledConfig->flags |= functionMappings[mappingIndex];
Expand Down Expand Up @@ -546,7 +546,7 @@ void applyQuadrantColor(const uint8_t ledIndex, const ledConfig_t *ledConfig, co

void applyLedModeLayer(void)
{
for (int ledIndex = 0; ledIndex < ledCount; ledIndex++) {
for (uint8_t ledIndex = 0; ledIndex < ledCount; ledIndex++) {
const ledConfig_t *ledConfig = ledConfigs(ledIndex);

if (!(ledConfig->flags & LED_FUNCTION_THRUST_RING)) {
Expand Down Expand Up @@ -633,7 +633,7 @@ void applyLedWarningLayer(bool updateNow)
}
}

for (int ledIndex = 0; ledIndex < ledCount; ledIndex++) {
for (uint8_t ledIndex = 0; ledIndex < ledCount; ledIndex++) {
const ledConfig_t *ledConfig = ledConfigs(ledIndex);
if (!(ledConfig->flags & LED_FUNCTION_WARNING))
continue;
Expand Down Expand Up @@ -669,7 +669,7 @@ void applyLedGpsLayer(bool updateNow)
}
}

for (int i = 0; i < ledCount; ++i) {
for (uint8_t i = 0; i < ledCount; ++i) {
const ledConfig_t *ledConfig = ledConfigs(i);

if (ledConfig->flags & LED_FUNCTION_GPS) {
Expand Down Expand Up @@ -704,7 +704,7 @@ void applyLedIndicatorLayer(uint8_t indicatorFlashState)
}


for (int ledIndex = 0; ledIndex < ledCount; ledIndex++) {
for (uint8_t ledIndex = 0; ledIndex < ledCount; ledIndex++) {
const ledConfig_t *ledConfig = ledConfigs(ledIndex);
if (!(ledConfig->flags & LED_FUNCTION_INDICATOR))
continue;
Expand Down Expand Up @@ -736,7 +736,7 @@ void applyLedHue(uint16_t flag, int16_t value, int16_t minRange, int16_t maxRang
int scaled = scaleRange(value, minRange, maxRange, -60, +60);
scaled += HSV_HUE_MAX; // wrap negative values correctly

for (int i = 0; i < ledCount; ++i) {
for (uint8_t i = 0; i < ledCount; ++i) {
const ledConfig_t *ledConfig = ledConfigs(i);
if (!(ledConfig->flags & flag))
continue;
Expand All @@ -755,13 +755,13 @@ void applyLedHue(uint16_t flag, int16_t value, int16_t minRange, int16_t maxRang

void applyLedThrustRingLayer(void)
{
int ledRingIndex = 0;
uint8_t ledRingIndex = 0;
// initialised to special value instead of using more memory for a flag.
static uint8_t rotationSeqLedCount = RING_PATTERN_NOT_CALCULATED;
static uint8_t rotationPhase = ROTATION_SEQUENCE_LED_COUNT;
bool nextLedOn = false;

for (int ledIndex = 0; ledIndex < ledCount; ledIndex++) {
for (uint8_t ledIndex = 0; ledIndex < ledCount; ledIndex++) {
const ledConfig_t *ledConfig = ledConfigs(ledIndex);
if ((ledConfig->flags & LED_FUNCTION_THRUST_RING) == 0)
continue;
Expand All @@ -786,7 +786,6 @@ void applyLedThrustRingLayer(void)

if (rotationSeqLedCount == RING_PATTERN_NOT_CALCULATED) {
// update ring pattern according to total number of ring leds found
int ledRingLedCount = ledRingIndex;

rotationSeqLedCount = ledRingLedCount;

Expand Down Expand Up @@ -816,7 +815,7 @@ void applyLedBlinkLayer(bool updateNow)
const uint8_t blinkCycleLength = 20;

if (blinkCounter > 0) {
for (int i = 0; i < ledCount; ++i) {
for (uint8_t i = 0; i < ledCount; ++i) {
const ledConfig_t *ledConfig = ledConfigs(i);
if (!(ledConfig->flags & LED_FUNCTION_BLINK))
continue;
Expand Down

0 comments on commit 3913722

Please sign in to comment.