mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-20 00:32:37 +01:00
buttons for up and down
This commit is contained in:
@@ -18,6 +18,7 @@ void DRV_DDP_AppendInformationToHTTPIndexPage(http_request_t *request, int bPreS
|
||||
void DRV_Shutters_RunQuickTick();
|
||||
void DRV_Shutters_AddToHtmlPage(http_request_t *request, int bPreState);
|
||||
void DRV_Shutters_Init();
|
||||
void Shutter_MoveByIndex(int index, float frac);
|
||||
|
||||
void BMP280_Init();
|
||||
void BMP280_OnEverySecond();
|
||||
|
||||
@@ -178,29 +178,22 @@ static void Shutter_Stop(shutter_t *s) {
|
||||
}
|
||||
Shutter_SetPins(s, s->state);
|
||||
}
|
||||
static commandResult_t CMD_Shutter_MoveTo(const void *context, const char *cmd, const char *args, int flags) {
|
||||
Tokenizer_TokenizeString(args, 0);
|
||||
|
||||
int index = Tokenizer_GetArgInteger(0);
|
||||
|
||||
void Shutter_MoveByIndex(int index, float frac) {
|
||||
shutter_t *s = GetForChannel(index);
|
||||
if (!s)
|
||||
return CMD_RES_BAD_ARGUMENT;
|
||||
|
||||
const char *target = Tokenizer_GetArg(1);
|
||||
if (!stricmp(target, "stop")) {
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
if (frac < 0) {
|
||||
// stop right now
|
||||
Shutter_Stop(s);
|
||||
// it's fair to assume that if we stop, target is the current pos
|
||||
s->targetFrac = s->frac;
|
||||
return CMD_RES_OK;
|
||||
return;
|
||||
}
|
||||
float frac = Tokenizer_GetArgFloat(1);
|
||||
|
||||
if (frac < 0.0f) frac = 0.0f;
|
||||
if (frac > 1.0f) frac = 1.0f;
|
||||
|
||||
|
||||
s->targetFrac = frac;
|
||||
|
||||
if (s->frac < 0.0f)
|
||||
@@ -213,7 +206,17 @@ static commandResult_t CMD_Shutter_MoveTo(const void *context, const char *cmd,
|
||||
s->state = SHUTTER_CLOSING;
|
||||
}
|
||||
Shutter_SetPins(s, s->state);
|
||||
|
||||
}
|
||||
static commandResult_t CMD_Shutter_MoveTo(const void *context, const char *cmd, const char *args, int flags) {
|
||||
Tokenizer_TokenizeString(args, 0);
|
||||
int index = Tokenizer_GetArgInteger(0);
|
||||
const char *target = Tokenizer_GetArg(1);
|
||||
if (!stricmp(target, "stop")) {
|
||||
Shutter_MoveByIndex(index, -1);
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
float frac = Tokenizer_GetArgFloat(1);
|
||||
Shutter_MoveByIndex(index, frac);
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
void Shutter_SetTimes(int channel, float timeOpen, float timeClose) {
|
||||
|
||||
@@ -562,6 +562,9 @@ const char* htmlPinRoleNames[] = {
|
||||
"RCRecv_nPup",
|
||||
"ShutterA",
|
||||
"ShutterB",
|
||||
"BtnShutterUp",
|
||||
"BtnShutterDown",
|
||||
"error",
|
||||
"error",
|
||||
};
|
||||
|
||||
|
||||
@@ -582,6 +582,18 @@ void Button_OnShortClick(int index)
|
||||
LED_NextColor();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_DRIVER_SHUTTERS
|
||||
if (g_cfg.pins.roles[index] == IOR_Button_ShutterUp)
|
||||
{
|
||||
Shutter_MoveByIndex(g_cfg.pins.channels[index], 1.0f);
|
||||
return;
|
||||
}
|
||||
if (g_cfg.pins.roles[index] == IOR_Button_ShutterDown)
|
||||
{
|
||||
Shutter_MoveByIndex(g_cfg.pins.channels[index], 0.0f);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (g_cfg.pins.roles[index] == IOR_Button_NextDimmer || g_cfg.pins.roles[index] == IOR_Button_NextDimmer_n)
|
||||
{
|
||||
@@ -628,6 +640,20 @@ void Button_OnDoubleClick(int index)
|
||||
// double click toggles SECOND CHANNEL linked to this button
|
||||
CHANNEL_Toggle(g_cfg.pins.channels2[index]);
|
||||
}
|
||||
#if ENABLE_DRIVER_SHUTTERS
|
||||
if (g_cfg.pins.roles[index] == IOR_Button_ShutterUp)
|
||||
{
|
||||
// issue stop order
|
||||
Shutter_MoveByIndex(g_cfg.pins.channels[index], -1.0f);
|
||||
return;
|
||||
}
|
||||
if (g_cfg.pins.roles[index] == IOR_Button_ShutterDown)
|
||||
{
|
||||
// issue stop order
|
||||
Shutter_MoveByIndex(g_cfg.pins.channels[index], -1.0f);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_LED_BASIC
|
||||
if (g_cfg.pins.roles[index] == IOR_SmartButtonForLEDs || g_cfg.pins.roles[index] == IOR_SmartButtonForLEDs_n) {
|
||||
LED_NextColor();
|
||||
@@ -825,6 +851,10 @@ void CHANNEL_SetAll(int iVal, int iFlags) {
|
||||
case IOR_Button_ScriptOnly_n:
|
||||
case IOR_SmartButtonForLEDs:
|
||||
case IOR_SmartButtonForLEDs_n:
|
||||
#if ENABLE_DRIVER_SHUTTERS
|
||||
case IOR_Button_ShutterUp:
|
||||
case IOR_Button_ShutterDown:
|
||||
#endif
|
||||
{
|
||||
|
||||
}
|
||||
@@ -968,6 +998,10 @@ void PIN_SetPinRoleForPinIndex(int index, int role) {
|
||||
case IOR_Button_ScriptOnly_n:
|
||||
case IOR_SmartButtonForLEDs:
|
||||
case IOR_SmartButtonForLEDs_n:
|
||||
#if ENABLE_DRIVER_SHUTTERS
|
||||
case IOR_Button_ShutterUp:
|
||||
case IOR_Button_ShutterDown:
|
||||
#endif
|
||||
{
|
||||
//pinButton_s *bt = &g_buttons[index];
|
||||
// TODO: disable button
|
||||
@@ -1036,6 +1070,10 @@ void PIN_SetPinRoleForPinIndex(int index, int role) {
|
||||
case IOR_Button_NextTemperature:
|
||||
case IOR_Button_ScriptOnly:
|
||||
case IOR_SmartButtonForLEDs:
|
||||
#if ENABLE_DRIVER_SHUTTERS
|
||||
case IOR_Button_ShutterUp:
|
||||
case IOR_Button_ShutterDown:
|
||||
#endif
|
||||
falling = 1;
|
||||
case IOR_Button_n:
|
||||
case IOR_Button_ToggleAll_n:
|
||||
@@ -2217,7 +2255,11 @@ void PIN_ticks(void* param)
|
||||
|| g_cfg.pins.roles[i] == IOR_Button_NextDimmer || g_cfg.pins.roles[i] == IOR_Button_NextDimmer_n
|
||||
|| g_cfg.pins.roles[i] == IOR_Button_NextTemperature || g_cfg.pins.roles[i] == IOR_Button_NextTemperature_n
|
||||
|| g_cfg.pins.roles[i] == IOR_Button_ScriptOnly || g_cfg.pins.roles[i] == IOR_Button_ScriptOnly_n
|
||||
|| g_cfg.pins.roles[i] == IOR_SmartButtonForLEDs || g_cfg.pins.roles[i] == IOR_SmartButtonForLEDs_n) {
|
||||
|| g_cfg.pins.roles[i] == IOR_SmartButtonForLEDs || g_cfg.pins.roles[i] == IOR_SmartButtonForLEDs_n
|
||||
#if ENABLE_DRIVER_SHUTTERS
|
||||
|| g_cfg.pins.roles[i] == IOR_Button_ShutterUp || g_cfg.pins.roles[i] == IOR_Button_ShutterDown
|
||||
#endif
|
||||
) {
|
||||
//addLogAdv(LOG_INFO, LOG_FEATURE_GENERAL,"Test hold %i\r\n",i);
|
||||
PIN_Input_Handler(i, t_diff);
|
||||
}
|
||||
|
||||
@@ -644,6 +644,20 @@ typedef enum ioRole_e {
|
||||
//iodetail:"file":"new_pins.h",
|
||||
//iodetail:"driver":"RC"}
|
||||
IOR_ShutterB,
|
||||
//iodetail:{"name":"RCRecv_nPup",
|
||||
//iodetail:"title":"RCRecv_nPup Pin",
|
||||
//iodetail:"descr":"433MHz RC receiver input without internal pull-up.",
|
||||
//iodetail:"enum":"IOR_RCRecv_nPup",
|
||||
//iodetail:"file":"new_pins.h",
|
||||
//iodetail:"driver":"RC"}
|
||||
IOR_Button_ShutterUp,
|
||||
//iodetail:{"name":"RCRecv_nPup",
|
||||
//iodetail:"title":"RCRecv_nPup Pin",
|
||||
//iodetail:"descr":"433MHz RC receiver input without internal pull-up.",
|
||||
//iodetail:"enum":"IOR_RCRecv_nPup",
|
||||
//iodetail:"file":"new_pins.h",
|
||||
//iodetail:"driver":"RC"}
|
||||
IOR_Button_ShutterDown,
|
||||
//iodetail:{"name":"Total_Options",
|
||||
//iodetail:"title":"TODO",
|
||||
//iodetail:"descr":"Current total number of available IOR roles",
|
||||
|
||||
Reference in New Issue
Block a user