Skip to content

Commit

Permalink
Merge branch 'openshwprojects:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
valeklubomir committed Oct 19, 2022
2 parents 7a94e11 + 78adf96 commit 027cef6
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/cmnds/cmd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int CMD_SimonTest(const void *context, const char *cmd, const char *args,
ADDLOG_INFO(LOG_FEATURE_CMD, "CMD_SimonTest: ir test routine");

#ifdef PLATFORM_BK7231T
testmehere();
// anything
#endif


Expand Down
2 changes: 1 addition & 1 deletion src/cmnds/cmd_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int testMallocFree(const void * context, const char *cmd, const char *arg
int repeats;
int rep;
char *msg;
int i;
//int i;
int ra1;
static int totalCalls = 0;

Expand Down
3 changes: 2 additions & 1 deletion src/driver/drv_bl_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ void BL09XX_AppendInformationToHTTPIndexPage(http_request_t *request)
memset(tmp,0,128);
}
}
sprintf(tmp, "<br>History Index: %d<br>JSON Stats: %s </h5>", energyCounterMinutesIndex,
// energyCounterMinutesIndex is a long type, we need to use %ld instead of %d
sprintf(tmp, "<br>History Index: %ld<br>JSON Stats: %s </h5>", energyCounterMinutesIndex,
(energyCounterStatsJSONEnable == true) ? "enabled" : "disabled");
//addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU,"'%s'\n", tmp);
hprintf128(request, tmp);
Expand Down
4 changes: 2 additions & 2 deletions src/driver/drv_ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ extern "C" void DRV_IR_ISR(UINT8 t){

// test routine to start IR RX and TX
// currently fixed pins for testing.
extern "C" void testmehere(){
extern "C" void DRV_IR_Init(){
ADDLOG_INFO(LOG_FEATURE_CMD, (char *)"Log from extern C CPP");

unsigned char pin = 9;// PWM3/25
Expand Down Expand Up @@ -509,7 +509,7 @@ void PrintIRData(IRData *aIRDataPtr){
// this polls the IR receive to see off there was any IR received
// currently called once per sec from user_main timer
// should probably be called every 100ms.
extern "C" void DRV_IR_Print(){
extern "C" void DRV_IR_RunFrame(){
if (ir_counter){
//ADDLOG_INFO(LOG_FEATURE_CMD, (char *)"IR counter: %u", ir_counter);
}
Expand Down
6 changes: 2 additions & 4 deletions src/driver/drv_ir.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#ifndef __DRV_IR_H__
#define __DRV_IR_H__

void DRV_IR_Test();
void DRV_IR_Print();

void testmehere();
void DRV_IR_Init();
void DRV_IR_RunFrame();

#endif
1 change: 1 addition & 0 deletions src/driver/drv_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void BP1658CJ_Init();
void BP1658CJ_RunFrame();
void BP1658CJ_OnChannelChanged(int ch, int value);

void BL_Shared_Init();
void BL_ProcessUpdate(float voltage, float current, float power);
void BL09XX_AppendInformationToHTTPIndexPage(http_request_t *request);
bool DRV_IsRunning(const char *name);
Expand Down
2 changes: 2 additions & 0 deletions src/driver/drv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "drv_local.h"
#include "drv_uart.h"
#include "drv_tuyaMCU.h"
#include "drv_ir.h"
#include "../i2c/drv_i2c_public.h"
#include "drv_ntp.h"
#include "../httpserver/new_http.h"
Expand Down Expand Up @@ -57,6 +58,7 @@ static driver_t g_drivers[] = {


#if PLATFORM_BEKEN
{ "IR", DRV_IR_Init, DRV_IR_RunFrame, NULL, NULL, NULL, NULL, false },
{ "DGR", DRV_DGR_Init, NULL, DRV_DGR_RunEverySecond, DRV_DGR_RunQuickTick, DRV_DGR_Shutdown, DRV_DGR_OnChannelChanged, false },
{ "DDP", DRV_DDP_Init, NULL, NULL, DRV_DDP_RunFrame, DRV_DDP_Shutdown, NULL, false },
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/driver/drv_ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int NTP_SetServer(const void *context, const char *cmd, const char *args, int cm
addLogAdv(LOG_INFO, LOG_FEATURE_NTP,"Argument missing e.g. ntp_setServer ipAddress\n");
return 0;
}
char *newValue = Tokenizer_GetArg(0);
const char *newValue = Tokenizer_GetArg(0);
CFG_SetNTPServer(newValue);
addLogAdv(LOG_INFO, LOG_FEATURE_NTP, "NTP server set to %s\n", newValue);
return 1;
Expand Down
1 change: 1 addition & 0 deletions src/driver/drv_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bool DRV_IsRunning(const char *name);
void DRV_OnChannelChanged(int channel,int iVal);
void SM2135_Write(byte *rgbcw);
void BP5758D_Write(byte *rgbcw);
void BP1658CJ_Write(byte *rgbcw);
void DRV_DGR_OnLedDimmerChange(int iVal);
void DRV_DGR_OnLedEnableAllChange(int iVal);

Expand Down
3 changes: 2 additions & 1 deletion src/driver/drv_tuyaMCU.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ static bool heartbeat_valid = false;
static int heartbeat_timer = 0;
static int heartbeat_counter = 0;
static bool product_information_valid = false;
static char *prod_info = NULL;
// ?? it's unused atm
//static char *prod_info = NULL;
static bool working_mode_valid = false;
static bool wifi_state_valid = false;
static bool wifi_state = false;
Expand Down
96 changes: 48 additions & 48 deletions src/hal/w800/hal_pins_w800.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "wm_include.h"

typedef struct wmPin_s {
const char *name;
const char* name;
unsigned short code;
short pwm_channel;
} wmPin_t;
Expand Down Expand Up @@ -35,7 +35,7 @@ static wmPin_t g_pins[] = {
{"PB20",WM_IO_PB_20, -1}
};

static int g_pwmChannelPins[] = {WM_IO_PB_00, WM_IO_PB_01, WM_IO_PB_02, WM_IO_PB_03, WM_IO_PA_07};
static int g_pwmChannelPins[] = { WM_IO_PB_00, WM_IO_PB_01, WM_IO_PB_02, WM_IO_PB_03, WM_IO_PA_07 };

#else

Expand All @@ -44,9 +44,9 @@ static wmPin_t g_pins[] = {
{"PA1",WM_IO_PA_01, -1},
{"PA4",WM_IO_PA_04, -1},
{"PA5",WM_IO_PA_05, -1},
{"PB8",WM_IO_PB_08, -1},
{"PB6",WM_IO_PB_06, -1},
{"PB7",WM_IO_PB_07, -1},
{"PB8",WM_IO_PB_08, -1},
{"PB9",WM_IO_PB_09, -1},
{"PB10",WM_IO_PB_10, -1},
{"PB11",WM_IO_PB_11, -1},
Expand All @@ -59,129 +59,129 @@ static wmPin_t g_pins[] = {
{"PB18",WM_IO_PB_18, 0}
};

static int g_pwmChannelPins[] = {WM_IO_PB_18, WM_IO_PB_17, WM_IO_PB_16, WM_IO_PB_15, WM_IO_PB_14};
static int g_pwmChannelPins[] = { WM_IO_PB_18, WM_IO_PB_17, WM_IO_PB_16, WM_IO_PB_15, WM_IO_PB_14 };

#endif

static int g_numPins = sizeof(g_pins)/sizeof(g_pins[0]);
static int g_numPins = sizeof(g_pins) / sizeof(g_pins[0]);

static int IsPinIndexOk(int index){
if(index<0)
static int IsPinIndexOk(int index) {
if (index < 0)
return 0;
if(index>=g_numPins)
if (index >= g_numPins)
return 0;
return 1;
}
static int PIN_GetPWMIndexForPinIndex(int index) {
return g_pins[index].pwm_channel;
}
const char *HAL_PIN_GetPinNameAlias(int index) {
if(IsPinIndexOk(index)==0)
const char* HAL_PIN_GetPinNameAlias(int index) {
if (IsPinIndexOk(index) == 0)
return "error";
return g_pins[index].name;
}

int HAL_PIN_CanThisPinBePWM(int index) {
if(IsPinIndexOk(index)==0)
if (IsPinIndexOk(index) == 0)
return 0;

return PIN_GetPWMIndexForPinIndex(index) == -1 ? 0 : 1;
}
void HAL_PIN_SetOutputValue(int index, int iVal) {
int realCode ;
if(IsPinIndexOk(index)==0)
int realCode;
if (IsPinIndexOk(index) == 0)
return;
realCode = g_pins[index].code;

tls_gpio_write(realCode,iVal); /*д¸ß*/
tls_gpio_write(realCode, iVal); /*д¸ß*/
}

int HAL_PIN_ReadDigitalInput(int index) {
int realCode ;
if(IsPinIndexOk(index)==0)
int realCode;
if (IsPinIndexOk(index) == 0)
return 0;
realCode = g_pins[index].code;

return tls_gpio_read(realCode);
}
void HAL_PIN_Setup_Input_Pullup(int index) {
int realCode ;
if(IsPinIndexOk(index)==0)
int realCode;
if (IsPinIndexOk(index) == 0)
return;
realCode = g_pins[index].code;

tls_gpio_cfg(realCode, WM_GPIO_DIR_INPUT, WM_GPIO_ATTR_PULLHIGH);
}
void HAL_PIN_Setup_Input(int index) {
int realCode ;
if(IsPinIndexOk(index)==0)
int realCode;
if (IsPinIndexOk(index) == 0)
return;
realCode = g_pins[index].code;

tls_gpio_cfg(realCode, WM_GPIO_DIR_INPUT, WM_GPIO_ATTR_FLOATING);
}
void HAL_PIN_Setup_Output(int index) {
int realCode ;
if(IsPinIndexOk(index)==0)
int realCode;
if (IsPinIndexOk(index) == 0)
return;
realCode = g_pins[index].code;

tls_gpio_cfg(realCode, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
}

static int pwm_demo_multiplex_config(u8 channel)
{
{
switch (channel)
{
case 0:
case 1:
case 2:
case 3:
case 4:
wm_pwm5_config(g_pwmChannelPins[channel]);
break;
default:
break;
case 0:
case 1:
case 2:
case 3:
case 4:
wm_pwm5_config(g_pwmChannelPins[channel]);
break;
default:
break;
}

return 0;
}

void HAL_PIN_PWM_Stop(int index) {
int channel;
if(IsPinIndexOk(index)==0)
if (IsPinIndexOk(index) == 0)
return;
channel = PIN_GetPWMIndexForPinIndex(index);
if(channel == -1)
if (channel == -1)
return;

tls_pwm_stop(channel);
}

void HAL_PIN_PWM_Start(int index) {
int ret;
int channel;
if(IsPinIndexOk(index)==0)
if (IsPinIndexOk(index) == 0)
return;
channel = PIN_GetPWMIndexForPinIndex(index);
if(channel == -1)
if (channel == -1)
return;

pwm_demo_multiplex_config(channel);
ret = tls_pwm_init(channel, 1000, 0, 0);
if (ret != WM_SUCCESS)
return;

pwm_demo_multiplex_config(channel);
ret = tls_pwm_init(channel, 1000, 0, 0);
if(ret != WM_SUCCESS)
return ;
tls_pwm_start(channel);
tls_pwm_start(channel);
}
//value is in 0 100 range
void HAL_PIN_PWM_Update(int index, int value) {
int channel;
if(IsPinIndexOk(index)==0)
if (IsPinIndexOk(index) == 0)
return;
channel = PIN_GetPWMIndexForPinIndex(index);
if(channel == -1)
if (channel == -1)
return;

tls_pwm_duty_set(channel, value * 2.55f);
}

Expand Down
2 changes: 1 addition & 1 deletion src/httpserver/http_fns.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ int http_fn_ha_discovery(http_request_t* request) {
return 0;
}

void http_generate_rgb_cfg(http_request_t* request, char* clientId) {
void http_generate_rgb_cfg(http_request_t* request, const char* clientId) {
hprintf128(request, " rgb_command_template: \"{{ '#%%02x%%02x%%02x0000' | format(red, green, blue)}}\"\n");
hprintf128(request, " rgb_value_template: \"{{ value[1:3] | int(base=16) }},{{ value[3:5] | int(base=16) }},{{ value[5:7] | int(base=16) }}\"\n");
hprintf128(request, " rgb_state_topic: \"%s/led_basecolor_rgb/get\"\n", clientId);
Expand Down
6 changes: 3 additions & 3 deletions src/logging/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void LOG_SetRawSocketCallback(int newFD)
}

#ifdef WINDOWS
void addLogAdv(int level, int feature, char *fmt, ...)
void addLogAdv(int level, int feature, const char *fmt, ...)
{
va_list argList;
const size_t tmp_len = 1024;
Expand Down Expand Up @@ -137,7 +137,7 @@ void addLogAdv(int level, int feature, char *fmt, ...)

static SemaphoreHandle_t g_mutex = 0;

void addLogAdv(int level, int feature, char *fmt, ...)
void addLogAdv(int level, int feature, const char *fmt, ...)
{
va_list argList;
BaseType_t taken;
Expand Down Expand Up @@ -252,7 +252,7 @@ static void initLog( void )

// adds a log to the log memory
// if head collides with either tail, move the tails on.
void addLogAdv(int level, int feature, char *fmt, ...)
void addLogAdv(int level, int feature, const char *fmt, ...)
{
char *tmp;
char *t;
Expand Down
2 changes: 1 addition & 1 deletion src/logging/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#ifndef _OBK_LOGGING_H
#define _OBK_LOGGING_H

void addLogAdv(int level, int feature, char *fmt, ...);
void addLogAdv(int level, int feature, const char *fmt, ...);
void LOG_SetRawSocketCallback(int newFD);
int log_command(const void *context, const char *cmd, const char *args, int cmdFlags);

Expand Down
5 changes: 3 additions & 2 deletions src/user_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include "hal/hal_adc.h"
#include "new_common.h"

#include "driver/drv_ir.h"
//#include "driver/drv_ir.h"
#include "driver/drv_public.h"
//#include "ir/ir_local.h"

// Commands register, execution API and cmd tokenizer
Expand Down Expand Up @@ -270,7 +271,7 @@ void Main_OnEverySecond()
}
// IR TESTING ONLY!!!!
#ifdef PLATFORM_BK7231T
DRV_IR_Print();
//DRV_IR_Print();
#endif

// when we hit 30s, mark as boot complete.
Expand Down

0 comments on commit 027cef6

Please sign in to comment.