diff --git a/plugin.lua b/plugin.lua index 0656a99..b03177f 100644 --- a/plugin.lua +++ b/plugin.lua @@ -24,7 +24,7 @@ function on_init() end ---It should be defined by the user in the script. ---@return nil function on_start() end ----This function is called every minute +---This function is called every second ---It should be defined by the user in the script. ---@return nil function tick() end diff --git a/src/rds.c b/src/rds.c index bb2a597..a708380 100644 --- a/src/rds.c +++ b/src/rds.c @@ -157,8 +157,12 @@ static void get_rds_group(RDSEncoder* enc, RDSGroup *group, uint8_t stream) { time(&now); utc = gmtime(&now); - if (utc->tm_min != enc->state[enc->program].last_minute) { + if(utc->tm_sec != enc->state[enc->program].last_second) { + enc->state[enc->program].last_second = utc->tm_sec; lua_call_function("tick"); + } + + if (utc->tm_min != enc->state[enc->program].last_minute) { enc->state[enc->program].last_minute = utc->tm_min; uint8_t eon_has_ta = 0; @@ -355,6 +359,7 @@ void reset_rds_state(RDSEncoder* enc, uint8_t program) { time(&now); utc = gmtime(&now); tempCoder.state[program].last_minute = utc->tm_min; + tempCoder.state[program].last_second = utc->tm_min; for(int i = 0; i < EONs; i++) tempCoder.data[program].eon[i].ta = 0; diff --git a/src/rds.h b/src/rds.h index 20e88f1..143a0ba 100644 --- a/src/rds.h +++ b/src/rds.h @@ -159,6 +159,7 @@ typedef struct { uint8_t fasttuning_state : 3; uint8_t last_minute : 6; + uint8_t last_second : 6; uint8_t ta_timeout : 7; uint8_t ta_timeout_state : 7;