mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-03-11 01:39:13 +01:00
bridge per pixel to LED driver
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "cmd_public.h"
|
||||
#include "../obk_config.h"
|
||||
#include "../driver/drv_public.h"
|
||||
#include "../driver/drv_local.h"
|
||||
#include "../hal/hal_flashVars.h"
|
||||
#include "../hal/hal_flashConfig.h"
|
||||
#include "../rgb2hsv.h"
|
||||
@@ -140,6 +141,7 @@ bool LED_IsLedDriverChipRunning()
|
||||
return DRV_IsRunning("SM2135") || DRV_IsRunning("BP5758D")
|
||||
|| DRV_IsRunning("TESTLED") || DRV_IsRunning("SM2235") || DRV_IsRunning("BP1658CJ")
|
||||
|| DRV_IsRunning("KP18058")
|
||||
|| DRV_IsRunning("SM16703P")
|
||||
;
|
||||
#else
|
||||
return false;
|
||||
@@ -577,6 +579,12 @@ void apply_smart_light() {
|
||||
#if ENABLE_DRIVER_TUYAMCU
|
||||
TuyaMCU_OnRGBCWChange(finalColors, g_lightEnableAll, g_lightMode, g_brightness0to100*0.01f, LED_GetTemperature0to1Range());
|
||||
#endif
|
||||
#if ENABLE_DRIVER_SM16703P
|
||||
if (pixel_count > 0) {
|
||||
SM16703P_setAllPixels(finalColors[0], finalColors[1], finalColors[2]);
|
||||
SM16703P_Show();
|
||||
}
|
||||
#endif
|
||||
|
||||
// I am not sure if it's the best place to do it
|
||||
// NOTE: this will broadcast MQTT only if a flag is set
|
||||
|
||||
@@ -53,7 +53,9 @@ void KP18058_Init();
|
||||
|
||||
void SM16703P_Init();
|
||||
void SM16703P_setPixel(int pixel, int r, int g, int b);
|
||||
void SM16703P_setAllPixels(int r, int g, int b);
|
||||
void SM16703P_Show();
|
||||
extern uint32_t pixel_count;
|
||||
|
||||
void TM1637_Init();
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "drv_local.h"
|
||||
#include "../hal/hal_pins.h"
|
||||
|
||||
extern uint32_t pixel_count;
|
||||
|
||||
// Credit: https://github.com/Electriangle/RainbowCycle_Main
|
||||
byte *RainbowWheel_Wheel(byte WheelPosition) {
|
||||
|
||||
@@ -243,6 +243,49 @@ void SM16703P_setPixel(int pixel, int r, int g, int b) {
|
||||
translate_byte(b1, spi_msg->send_buf + (pixel_offset + 4 + (pixel * 3 * 4)));
|
||||
translate_byte(b2, spi_msg->send_buf + (pixel_offset + 8 + (pixel * 3 * 4)));
|
||||
}
|
||||
void SM16703P_setAllPixels(int r, int g, int b) {
|
||||
int pixel;
|
||||
if (!initialized)
|
||||
return;
|
||||
// Load data in correct format
|
||||
int b0, b1, b2;
|
||||
if (color_order == SM16703P_COLOR_ORDER_RGB) {
|
||||
b0 = r;
|
||||
b1 = g;
|
||||
b2 = b;
|
||||
}
|
||||
if (color_order == SM16703P_COLOR_ORDER_RBG) {
|
||||
b0 = r;
|
||||
b1 = b;
|
||||
b2 = g;
|
||||
}
|
||||
if (color_order == SM16703P_COLOR_ORDER_BRG) {
|
||||
b0 = b;
|
||||
b1 = r;
|
||||
b2 = g;
|
||||
}
|
||||
if (color_order == SM16703P_COLOR_ORDER_BGR) {
|
||||
b0 = b;
|
||||
b1 = g;
|
||||
b2 = r;
|
||||
}
|
||||
if (color_order == SM16703P_COLOR_ORDER_GRB) {
|
||||
b0 = g;
|
||||
b1 = r;
|
||||
b2 = b;
|
||||
}
|
||||
if (color_order == SM16703P_COLOR_ORDER_GBR) {
|
||||
b0 = g;
|
||||
b1 = b;
|
||||
b2 = r;
|
||||
}
|
||||
for (pixel = 0; pixel < pixel_count; pixel++) {
|
||||
translate_byte(b0, spi_msg->send_buf + (pixel_offset + 0 + (pixel * 3 * 4)));
|
||||
translate_byte(b1, spi_msg->send_buf + (pixel_offset + 4 + (pixel * 3 * 4)));
|
||||
translate_byte(b2, spi_msg->send_buf + (pixel_offset + 8 + (pixel * 3 * 4)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SM16703P_SetRaw bUpdate byteOfs HexData
|
||||
// SM16703P_SetRaw 1 0 FF000000FF000000FF
|
||||
|
||||
Reference in New Issue
Block a user