2017-08-25 22:17:07 -04:00
|
|
|
/*
|
2017-08-27 15:02:50 -04:00
|
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
2017-08-25 22:17:07 -04:00
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
2017-09-22 21:05:51 -04:00
|
|
|
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
2017-08-25 22:17:07 -04:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2017-09-22 21:05:51 -04:00
|
|
|
#ifndef MICROPY_INCLUDED_SUPERVISOR_RGB_LED_STATUS_H
|
|
|
|
#define MICROPY_INCLUDED_SUPERVISOR_RGB_LED_STATUS_H
|
2016-12-09 22:27:41 -05:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2017-09-22 21:05:51 -04:00
|
|
|
#include "lib/utils/pyexec.h"
|
2017-11-01 01:23:45 -04:00
|
|
|
#include "supervisor/port.h"
|
2017-09-22 21:05:51 -04:00
|
|
|
|
2018-10-19 21:46:22 -04:00
|
|
|
#include "py/mpconfig.h"
|
2016-12-09 22:27:41 -05:00
|
|
|
#include "rgb_led_colors.h"
|
|
|
|
|
2018-12-06 17:24:20 -05:00
|
|
|
#include "supervisor/shared/safe_mode.h"
|
|
|
|
|
2017-09-22 21:05:51 -04:00
|
|
|
// Overall, the time module must be implemented.
|
|
|
|
// To work with a DotStar, one must have MICROPY_HW_APA102_SCK and
|
|
|
|
// MICROPY_HW_APA102_MOSI defined and bitbangio.SPI or busio.SPI implemented.
|
|
|
|
// To work with a NeoPixel, one must have MICROPY_HW_NEOPIXEL defined and
|
|
|
|
// neopixel_write implemented.
|
|
|
|
|
2017-04-12 18:24:50 -04:00
|
|
|
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) && !defined(CIRCUITPY_BITBANG_APA102)
|
|
|
|
#include "common-hal/busio/SPI.h"
|
|
|
|
extern busio_spi_obj_t status_apa102;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void rgb_led_status_init(void);
|
|
|
|
void reset_status_led(void);
|
|
|
|
void new_status_color(uint32_t rgb);
|
|
|
|
void temp_status_color(uint32_t rgb);
|
|
|
|
void clear_temp_status(void);
|
2016-12-09 22:27:41 -05:00
|
|
|
|
|
|
|
uint32_t color_brightness(uint32_t color, uint8_t brightness);
|
2017-09-12 15:09:22 -04:00
|
|
|
void set_rgb_status_brightness(uint8_t level);
|
2016-12-09 22:27:41 -05:00
|
|
|
|
2017-09-22 21:05:51 -04:00
|
|
|
typedef struct {
|
|
|
|
bool ok;
|
|
|
|
uint32_t pattern_start;
|
|
|
|
uint32_t total_exception_cycle;
|
2017-11-01 01:23:45 -04:00
|
|
|
safe_mode_t safe_mode;
|
|
|
|
uint8_t digit_sum;
|
2017-09-22 21:05:51 -04:00
|
|
|
uint8_t ones;
|
|
|
|
uint8_t tens;
|
|
|
|
uint8_t hundreds;
|
|
|
|
uint8_t thousands;
|
|
|
|
uint32_t exception_color;
|
|
|
|
bool found_main;
|
|
|
|
} rgb_status_animation_t;
|
|
|
|
|
2017-11-01 01:23:45 -04:00
|
|
|
void prep_rgb_status_animation(const pyexec_result_t* result,
|
|
|
|
bool found_main,
|
|
|
|
safe_mode_t safe_mode,
|
|
|
|
rgb_status_animation_t* status);
|
2017-09-22 21:05:51 -04:00
|
|
|
void tick_rgb_status_animation(rgb_status_animation_t* status);
|
|
|
|
|
|
|
|
#endif // MICROPY_INCLUDED_SUPERVISOR_RGB_LED_STATUS_H
|