better docs for tm1637 etc commands, merge ping watchdog interval, now it uses field from config

This commit is contained in:
openshwprojects
2023-04-13 09:14:56 +02:00
parent 0541402e6d
commit d894e109bf
5 changed files with 31 additions and 24 deletions

View File

@ -521,8 +521,8 @@ void CMD_InitChannelCommands(){
//cmddetail:"fn":"CMD_SetChannelVisible","file":"cmnds/cmd_channels.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("SetChannelVisible", CMD_SetChannelVisible, NULL);
//cmddetail:{"name":"Ch","args":"[TargetChannel][InputValue]",
//cmddetail:"descr":"qqq",
//cmddetail:{"name":"Ch","args":"[InputValue]",
//cmddetail:"descr":"An alternate command to access channels. It returns all used channels in JSON format. The syntax is ChINDEX value, there is no space between Ch and channel index. It can be sent without value to poll channel values.",
//cmddetail:"fn":"CMD_Ch","file":"cmnds/cmd_channels.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("Ch", CMD_Ch, NULL);

View File

@ -10,7 +10,6 @@
#include "../hal/hal_adc.h"
#include "../hal/hal_flashVars.h"
int g_pingWatchDog_intervalMs = 1000;
int cmd_uartInitIndex = 0;
@ -276,8 +275,7 @@ static commandResult_t CMD_PingInterval(const void* context, const char* cmd, co
return CMD_RES_NOT_ENOUGH_ARGUMENTS;
}
// convert seconds to ms
g_pingWatchDog_intervalMs = Tokenizer_GetArgInteger(0) * 1000;
CFG_SetPingIntervalSeconds(Tokenizer_GetArgInteger(0));
return CMD_RES_OK;
}

View File

@ -242,6 +242,7 @@ static commandResult_t CMD_TM1637_Char(const void *context, const char *cmd, con
return CMD_RES_OK;
}
// [StartOfs] [MaxLenOr0] [StringText] [optionalBClampWithZeroesForClock]
static commandResult_t CMD_TM1637_Print(const void *context, const char *cmd, const char *args, int flags) {
int ofs;
int maxLen;
@ -454,34 +455,34 @@ void TM_GN_Display_SharedInit() {
TM1637_SetBrightness(0x0f, true);
//cmddetail:{"name":"TM1637_Clear","args":"CMD_TM1637_Clear",
//cmddetail:"descr":"",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm1637.c","requires":"",
//cmddetail:{"name":"TMGN_Clear","args":"",
//cmddetail:"descr":"This clears the TM1637/GN932/etc display",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm_gn_display_shared.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("TMGN_Clear", CMD_TM1637_Clear, NULL);
//cmddetail:{"name":"TMGN_Char","args":"CMD_TMGN_Char",
//cmddetail:"descr":"",
//cmddetail:{"name":"TMGN_Char","args":"[CharIndex] [CharCode]",
//cmddetail:"descr":"This allows you to set binary code for given char, valid chars range is 0 to 15, because this is 7-seg display",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm1637.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("TMGN_Char", CMD_TM1637_Char, NULL);
//cmddetail:{"name":"TM1637_Print","args":"CMD_TM1637_Print",
//cmddetail:"descr":"",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm1637.c","requires":"",
//cmddetail:{"name":"TMGN_Print","args":"[StartOfs] [MaxLenOr0] [StringText] [optionalBClampWithZeroesForClock]",
//cmddetail:"descr":"This allows you to print string on TM1637/GN932/etc display, it supports variables expansion",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm_gn_display_shared.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("TMGN_Print", CMD_TM1637_Print, NULL);
//cmddetail:{"name":"TM1637_Test","args":"CMD_TM1637_Test",
//cmddetail:{"name":"TMGN_Test","args":"CMD_TM1637_Test",
//cmddetail:"descr":"",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm1637.c","requires":"",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm_gn_display_shared.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("TMGN_Test", CMD_TM1637_Test, NULL);
//cmddetail:{"name":"TM1637_Brightness","args":"CMD_TM1637_Brightness",
//cmddetail:"descr":"",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm1637.c","requires":"",
//cmddetail:{"name":"TMGN_Brightness","args":"[Brigthness0to7][bOn]",
//cmddetail:"descr":"This allows you to change brightness and state of TM1637/GN932/etc display",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm_gn_display_shared.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("TMGN_Brightness", CMD_TM1637_Brightness, NULL);
//cmddetail:{"name":"TM1637_Map","args":"CMD_TM1637_Map",
//cmddetail:"descr":"",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm1637.c","requires":"",
//cmddetail:{"name":"TMGN_Map","args":"[Map0][Map1, etc]",
//cmddetail:"descr":"This allows you to remap characters order for TM1637/GN932/etc. My TM1637 module from Aliexpress has a strange characters order.",
//cmddetail:"fn":"NULL);","file":"driver/drv_tm_gn_display_shared.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("TMGN_Map", CMD_TM1637_Map, NULL);
//cmddetail:{"name":"TM1650_Test","args":"CMD_TM1650_Test",

View File

@ -440,7 +440,6 @@ extern int g_bWantPinDeepSleep;
extern int g_timeSinceLastPingReply;
extern int g_startPingWatchDogAfter;
extern int g_openAP;
extern int g_pingWatchDog_intervalMs;
typedef int(*jsonCb_t)(void *userData, const char *fmt, ...);
int JSON_ProcessCommandReply(const char *cmd, const char *args, void *request, jsonCb_t printer, int flags);

View File

@ -114,7 +114,16 @@ static void ping_send(struct raw_pcb *raw, const ip_addr_t *addr)
}
pbuf_free(p);
}
int PING_getPingIntervalMS() {
int ret;
ret = CFG_GetPingIntervalSeconds();
if (ret < 1) {
ret = 1;
}
return ret * 1000;
}
static void ping_timeout(void *arg)
{
struct raw_pcb *pcb = (struct raw_pcb*)arg;
@ -126,7 +135,7 @@ static void ping_timeout(void *arg)
ping_send(pcb, &ping_target);
}
// void sys_timeout (u32_t msecs, sys_timeout_handler handler, void *arg)
sys_timeout(g_pingWatchDog_intervalMs, ping_timeout, pcb);
sys_timeout(PING_getPingIntervalMS(), ping_timeout, pcb);
}
static u8_t ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr)
@ -189,7 +198,7 @@ void Main_SetupPingWatchDog(const char *target/*, int delayBetweenPings_Seconds*
raw_recv(ping_pcb, ping_recv, NULL);
raw_bind(ping_pcb, IP_ADDR_ANY);
// void sys_timeout (u32_t msecs, sys_timeout_handler handler, void *arg)
sys_timeout(g_pingWatchDog_intervalMs, ping_timeout, ping_pcb);
sys_timeout(PING_getPingIntervalMS(), ping_timeout, ping_pcb);
ping_handler_active = true;
}