mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-04 14:05:31 +00:00
merge gosund sw2 port (not clear if it will be used)
This commit is contained in:
@ -221,6 +221,7 @@
|
||||
<ClCompile Include="src\driver\drv_drawers.c" />
|
||||
<ClCompile Include="src\driver\drv_freeze.c" />
|
||||
<ClCompile Include="src\driver\drv_gn6932.c" />
|
||||
<ClCompile Include="src\driver\drv_gosundSW2.c" />
|
||||
<ClCompile Include="src\driver\drv_hd2015.c" />
|
||||
<ClCompile Include="src\driver\drv_ht16k33.c" />
|
||||
<ClCompile Include="src\driver\drv_httpButtons.c" />
|
||||
|
||||
@ -399,6 +399,8 @@
|
||||
<ClCompile Include="src\driver\drv_tclAC.c" />
|
||||
<ClCompile Include="src\selftest\selftest_pir.c" />
|
||||
<ClCompile Include="src\selftest\selftest_tclAC.c" />
|
||||
<ClCompile Include="src\berry\modules\be_i2c.c" />
|
||||
<ClCompile Include="src\driver\drv_gosundSW2.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\base64\base64.h" />
|
||||
|
||||
@ -248,6 +248,11 @@ void LED_ApplyEmulatedCool(int firstChannelIndex, float chVal) {
|
||||
}
|
||||
|
||||
void LED_I2CDriver_WriteRGBCW(float* finalRGBCW) {
|
||||
#ifdef ENABLE_DRIVER_GOSUNDSW2
|
||||
if (DRV_IsRunning("GosundSW2")) {
|
||||
DRV_GosundSW2_Write(finalRGBCW)
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_DRIVER_LED
|
||||
if (CFG_HasFlag(OBK_FLAG_LED_EMULATE_COOL_WITH_RGB)) {
|
||||
if (g_lightMode == Light_Temperature) {
|
||||
|
||||
56
src/driver/drv_gosundSW2.c
Normal file
56
src/driver/drv_gosundSW2.c
Normal file
@ -0,0 +1,56 @@
|
||||
// based on info from here:
|
||||
// https://www.elektroda.com/rtvforum/viewtopic.php?p=21593497#21593497
|
||||
#include "../obk_config.h"
|
||||
|
||||
|
||||
|
||||
#if ENABLE_DRIVER_GOSUNDSW2
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "drv_local.h"
|
||||
#include "../logging/logging.h"
|
||||
#include "../new_cfg.h"
|
||||
#include "../new_pins.h"
|
||||
#include "../cmnds/cmd_public.h"
|
||||
#include "drv_uart.h"
|
||||
|
||||
#define SW2_BAUDRATE 9600
|
||||
|
||||
void DRV_GosundSW2_RunFrame() {
|
||||
if (UART_GetDataSize() >= 5) {
|
||||
char buff[5];
|
||||
for (int i = 0; i < 5; i++) {
|
||||
buff[i] = UART_GetByte(i);
|
||||
}
|
||||
UART_ConsumeBytes(5);
|
||||
float dimmerVal = buff[1] / 100.0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void DRV_GosundSW2_Write(float* finalRGBCW) {
|
||||
|
||||
float state = finalRGBCW[0];
|
||||
|
||||
uint8_t dimmerVal = 0;
|
||||
|
||||
if (state > 0.0)
|
||||
{
|
||||
dimmerVal = (127.0 * state) + 0.5;
|
||||
dimmerVal |= 0x80; /* Bit 7 seems to control the relay */
|
||||
}
|
||||
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_HTTP, "Writing dimmer value %02X", dimmerVal);
|
||||
UART_SendByte(dimmerVal);
|
||||
}
|
||||
// startDriver GosundSW2
|
||||
// backlog clearConfig; startDriver GosundSW2
|
||||
void DRV_GosundSW2_Init() {
|
||||
UART_InitUART(SW2_BAUDRATE, 0, false);
|
||||
UART_InitReceiveRingBuffer(256);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@ -52,6 +52,9 @@ void KP18058_Init();
|
||||
|
||||
void SM15155E_Init();
|
||||
|
||||
void DRV_GosundSW2_Init();
|
||||
void DRV_GosundSW2_RunFrame();
|
||||
|
||||
void SM16703P_Init();
|
||||
void SM16703P_setPixel(int pixel, int r, int g, int b);
|
||||
void SM16703P_setPixelWithBrig(int pixel, int r, int g, int b);
|
||||
|
||||
@ -82,6 +82,14 @@ static driver_t g_drivers[] = {
|
||||
|
||||
|
||||
|
||||
#if ENABLE_DRIVER_GOSUNDSW2
|
||||
//drvdetail:{"name":"GosundSW",
|
||||
//drvdetail:"title":"TODO",
|
||||
//drvdetail:"descr":"GosundSW2.",
|
||||
//drvdetail:"requires":""}
|
||||
{ "GosundSW2", DRV_GosundSW2_Init, NULL, NULL, DRV_GosundSW2_RunFrame, NULL, NULL, false },
|
||||
#endif
|
||||
|
||||
#if ENABLE_DRIVER_TCL
|
||||
{ "TCL", TCL_Init, TCL_UART_RunEverySecond, TCL_AppendInformationToHTTPIndexPage, NULL, NULL, NULL, TCL_DoDiscovery, false },
|
||||
#endif
|
||||
|
||||
@ -64,6 +64,7 @@ void DRV_OnChannelChanged(int channel, int iVal);
|
||||
#if PLATFORM_BK7231N
|
||||
void SM16703P_setMultiplePixel(uint32_t pixel, uint8_t *data, bool push);
|
||||
#endif
|
||||
void DRV_GosundSW2_Write(float* rgbcw);
|
||||
void SM2135_Write(float* rgbcw);
|
||||
void BP5758D_Write(float* rgbcw);
|
||||
void BP1658CJ_Write(float* rgbcw);
|
||||
|
||||
@ -654,8 +654,14 @@ int http_fn_index(http_request_t* request) {
|
||||
}
|
||||
}
|
||||
|
||||
bool bForceShowSingleDimmer = 0;
|
||||
#if ENABLE_DRIVER_GOSUNDSW2
|
||||
if (DRV_IsRunning("GosundSW2")) {
|
||||
bForceShowSingleDimmer = 1;
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_LED_BASIC
|
||||
if (bRawPWMs == 0 || bForceShowRGBCW || bForceShowRGB) {
|
||||
if (bRawPWMs == 0 || bForceShowRGBCW || bForceShowRGB || bForceShowSingleDimmer) {
|
||||
int c_pwms;
|
||||
int lm;
|
||||
int c_realPwms = 0;
|
||||
@ -668,7 +674,10 @@ int http_fn_index(http_request_t* request) {
|
||||
// into high power 3-outputs single colors LED controller
|
||||
PIN_get_Relay_PWM_Count(0, &c_pwms, 0);
|
||||
c_realPwms = c_pwms;
|
||||
if (bForceShowRGBCW) {
|
||||
if (bForceShowSingleDimmer) {
|
||||
c_pwms = 1;
|
||||
}
|
||||
else if (bForceShowRGBCW) {
|
||||
c_pwms = 5;
|
||||
}
|
||||
else if (bForceShowRGB) {
|
||||
|
||||
Reference in New Issue
Block a user