-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1225 from spark/feature/system_led_fixes
LED signaling fixes
- Loading branch information
Showing
42 changed files
with
4,161 additions
and
3,549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "led_signal.h" | ||
|
||
#include "system_led_signal.h" | ||
|
||
#include "dct.h" | ||
|
||
// See system_led_signal.cpp for the description of the LED theme data format | ||
STATIC_ASSERT(led_theme_version_has_changed, LED_SIGNAL_THEME_VERSION == 1); | ||
|
||
#define UNPACK_COLOR_COMPONENT(_value) \ | ||
((((_value) & 0x0f) << 4) | ((_value) & 0x0f)) /* 0 -> 0, 1 -> 17, 2 -> 34, ..., 15 -> 255 */ \ | ||
|
||
static uint32_t led_signal_color(int signal, const uint8_t* data) { | ||
data += signal * 3 + 1; // 3 bytes per signal; first byte is reserved for a version number | ||
return ((uint32_t)UNPACK_COLOR_COMPONENT(*data >> 4) << 16) | // R | ||
((uint32_t)UNPACK_COLOR_COMPONENT(*data & 0x0f) << 8) | // G | ||
(uint32_t)UNPACK_COLOR_COMPONENT(*(data + 1) >> 4); // B | ||
} | ||
|
||
void get_led_theme_colors(uint32_t* firmware_update, uint32_t* safe_mode, uint32_t* dfu_mode) { | ||
// Check if theme data is initialized in DCT | ||
const uint8_t* d = (const char*)dct_read_app_data(DCT_LED_THEME_OFFSET); | ||
if (d && *d == LED_SIGNAL_THEME_VERSION) { | ||
*firmware_update = led_signal_color(LED_SIGNAL_FIRMWARE_UPDATE, d); | ||
*safe_mode = led_signal_color(LED_SIGNAL_SAFE_MODE, d); | ||
*dfu_mode = led_signal_color(LED_SIGNAL_DFU_MODE, d); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef LED_SIGNAL_H | ||
#define LED_SIGNAL_H | ||
|
||
#include <stdint.h> | ||
|
||
// Loads some of the colors used for LED signaling from DCT | ||
void get_led_theme_colors(uint32_t* firmware_update, uint32_t* safe_mode, uint32_t* dfu_mode); | ||
|
||
#endif // LED_SIGNAL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2016 Particle Industries, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation, either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef HAL_EVENT_H | ||
#define HAL_EVENT_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "core_hal.h" | ||
|
||
// Generates HAL event. See HAL_Event enum for the list of defined events | ||
void hal_notify_event(int event, int flags, void* data); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif // HAL_EVENT_H |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2016 Particle Industries, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation, either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "hal_event.h" | ||
|
||
namespace { | ||
|
||
HAL_Event_Callback eventCallback = nullptr; | ||
|
||
} | ||
|
||
void HAL_Set_Event_Callback(HAL_Event_Callback callback, void* reserved) { | ||
eventCallback = callback; | ||
} | ||
|
||
void hal_notify_event(int event, int flags, void* data) { | ||
if (eventCallback) { | ||
eventCallback(event, flags, data); | ||
} | ||
} |
Oops, something went wrong.