feat: Board-Tabelle für alle acht Gerätetypen
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include "board/nl_board.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define NONE {-1, NL_PIN_NONE, false, false}
|
||||
#define CH(c, p) {(c), (p), false, false}
|
||||
#define CHL(c, p) {(c), (p), true, false} /* active low */
|
||||
#define CHA(c, p) {(c), (p), false, true} /* antiphase */
|
||||
|
||||
/* SM2135EH current codes: RGB high nibble (15 mA = 1, 40 mA = 6, 45 mA = 7),
|
||||
* WY low nibble (15 mA = 3, 35 mA = 7). Values from qcl_build_config_lamp.h. */
|
||||
#define NO_SM NL_PIN_NONE, NL_PIN_NONE, 0
|
||||
|
||||
const nl_board_t nl_boards[] = {
|
||||
/* R G B CW WW */
|
||||
{"evk", "W600 EVK v1.2", NL_DRV_PWM, true, 2700, 6500, 5000,
|
||||
{CHL(0, NL_PB(18)), CHL(2, NL_PB(16)), CHL(3, NL_PB(15)), CHL(1, NL_PB(13)), CHL(4, NL_PB(8))}, NO_SM},
|
||||
{"e27_rgb", "Klyqa E27 RGB CW/WW", NL_DRV_SM2135EH, true, 2700, 6500, 0,
|
||||
{NONE, NONE, NONE, NONE, NONE}, NL_PB(13), NL_PB(8), 0x17},
|
||||
{"e14_rgb", "Klyqa E14 RGB CW/WW", NL_DRV_SM2135EH, true, 2700, 6500, 0,
|
||||
{NONE, NONE, NONE, NONE, NONE}, NL_PB(8), NL_PB(13), 0x73},
|
||||
{"gu10_rgb", "Klyqa GU10 RGB CW/WW", NL_DRV_SM2135EH, true, 2700, 6500, 0,
|
||||
{NONE, NONE, NONE, NONE, NONE}, NL_PB(8), NL_PB(13), 0x63},
|
||||
{"e27_cw", "Klyqa E27 CW/WW", NL_DRV_PWM, false, 2500, 5000, 600,
|
||||
{NONE, NONE, NONE, CHA(1, NL_PB(13)), CH(4, NL_PB(8))}, NO_SM},
|
||||
{"e14_cw", "Klyqa E14 CW/WW", NL_DRV_PWM, false, 2500, 5000, 600,
|
||||
{NONE, NONE, NONE, CH(2, NL_PB(16)), CH(4, NL_PB(8))}, NO_SM},
|
||||
{"gu10_cw", "Klyqa GU10 CW/WW", NL_DRV_PWM, false, 2500, 5000, 600,
|
||||
{NONE, NONE, NONE, CH(2, NL_PB(16)), CH(4, NL_PB(8))}, NO_SM},
|
||||
/* G95: pin assignment still to be verified on a series bulb (old note: PB16=WW, PB15=CW). */
|
||||
{"g95_cw", "Klyqa G95 Vintage CW/WW", NL_DRV_PWM, false, 2500, 5000, 600,
|
||||
{NONE, NONE, NONE, CH(1, NL_PB(13)), CH(3, NL_PB(15))}, NO_SM},
|
||||
};
|
||||
|
||||
const size_t nl_boards_count = sizeof(nl_boards) / sizeof(nl_boards[0]);
|
||||
|
||||
const nl_board_t *nl_board_find(const char *id)
|
||||
{
|
||||
for (size_t i = 0; i < nl_boards_count; i++)
|
||||
if (strcmp(nl_boards[i].id, id) == 0)
|
||||
return &nl_boards[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef NINLIGHT_DEVICE_ID
|
||||
const nl_board_t *nl_board_get(void)
|
||||
{
|
||||
return nl_board_find(NINLIGHT_DEVICE_ID);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef NL_BOARD_H
|
||||
#define NL_BOARD_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* GPIO numbers are identical to enum tls_io_name of the W600 SDK (PA_00 = 0, PB_00 = 16). */
|
||||
#define NL_PB(n) ((uint8_t)(16u + (n)))
|
||||
#define NL_PIN_NONE 0xFFu
|
||||
|
||||
typedef enum { NL_CH_R = 0, NL_CH_G, NL_CH_B, NL_CH_CW, NL_CH_WW, NL_CH_COUNT } nl_channel_t;
|
||||
typedef enum { NL_DRV_PWM = 0, NL_DRV_SM2135EH } nl_led_driver_t;
|
||||
|
||||
typedef struct {
|
||||
int8_t pwm_ch; /* PWM unit channel 0..4, -1 = channel not populated */
|
||||
uint8_t pin; /* NL_PB(x) or NL_PIN_NONE */
|
||||
bool active_low; /* LED lights up while the pin is low */
|
||||
bool antiphase; /* inverted PWM output, shifts the pulse (e27_cw cold white) */
|
||||
} nl_pwm_chan_t;
|
||||
|
||||
typedef struct {
|
||||
const char *id;
|
||||
const char *name;
|
||||
nl_led_driver_t driver;
|
||||
bool has_rgb;
|
||||
uint16_t ct_min; /* Kelvin, warmest */
|
||||
uint16_t ct_max; /* Kelvin, coldest */
|
||||
uint32_t pwm_freq_hz; /* PWM boards */
|
||||
nl_pwm_chan_t pwm[NL_CH_COUNT];
|
||||
uint8_t sm_clk_pin; /* SM2135EH boards */
|
||||
uint8_t sm_dat_pin;
|
||||
uint8_t sm_current; /* (rgb_code << 4) | wy_code, see SM2135EH datasheet */
|
||||
} nl_board_t;
|
||||
|
||||
extern const nl_board_t nl_boards[];
|
||||
extern const size_t nl_boards_count;
|
||||
|
||||
const nl_board_t *nl_board_find(const char *id);
|
||||
|
||||
/* Board selected at build time via NINLIGHT_DEVICE_ID. */
|
||||
const nl_board_t *nl_board_get(void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user