fix(MP/daemon): change frequency to period
This commit is contained in:
@@ -2,18 +2,19 @@
|
|||||||
#ifndef COMMON_IPC_H
|
#ifndef COMMON_IPC_H
|
||||||
#define COMMON_IPC_H
|
#define COMMON_IPC_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#define SOCKET_PATH "/tmp/regulator_daemon.sock"
|
#define SOCKET_PATH "/tmp/regulator_daemon.sock"
|
||||||
|
|
||||||
/* Commands definitions */
|
/* Commands definitions */
|
||||||
#define CMD_SET_MODE 10
|
#define CMD_SET_MODE 10
|
||||||
#define CMD_SET_FREQ 20
|
#define CMD_SET_PERIOD 20
|
||||||
#define CMD_INC_FREQ 30
|
#define CMD_INC_PERIOD 30
|
||||||
#define CMD_DEC_FREQ 40
|
#define CMD_DEC_PERIOD 40
|
||||||
|
|
||||||
/* Structure of the message sent through IPC */
|
/* Structure of the message sent through IPC */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int command;
|
int command;
|
||||||
int value;
|
uint32_t value;
|
||||||
} ipc_msg_t;
|
} ipc_msg_t;
|
||||||
|
|
||||||
#endif /* COMMON_IPC_H */
|
#endif /* COMMON_IPC_H */
|
||||||
|
|||||||
@@ -21,25 +21,25 @@ static void process_message(ipc_msg_t *msg) {
|
|||||||
switch (msg->command) {
|
switch (msg->command) {
|
||||||
case CMD_SET_MODE:
|
case CMD_SET_MODE:
|
||||||
if (current_cbs.on_set_mode) {
|
if (current_cbs.on_set_mode) {
|
||||||
current_cbs.on_set_mode(msg->value);
|
current_cbs.on_set_mode((int) msg->value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_SET_FREQ:
|
case CMD_SET_PERIOD:
|
||||||
if (current_cbs.on_set_frequency) {
|
if (current_cbs.on_set_period) {
|
||||||
current_cbs.on_set_frequency(msg->value);
|
current_cbs.on_set_period((uint32_t) msg->value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_INC_FREQ:
|
case CMD_INC_PERIOD:
|
||||||
if (current_cbs.on_inc_frequency) {
|
if (current_cbs.on_inc_period) {
|
||||||
current_cbs.on_inc_frequency();
|
current_cbs.on_inc_period();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_DEC_FREQ:
|
case CMD_DEC_PERIOD:
|
||||||
if (current_cbs.on_dec_frequency) {
|
if (current_cbs.on_dec_period) {
|
||||||
current_cbs.on_dec_frequency();
|
current_cbs.on_dec_period();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,17 @@
|
|||||||
|
|
||||||
#include "../../common/common_ipc.h"
|
#include "../../common/common_ipc.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure holding the callbacks for IPC commands.
|
* Structure holding the callbacks for IPC commands.
|
||||||
* Each function pointer will be called when the corresponding command is received.
|
* Each function pointer will be called when the corresponding command is received.
|
||||||
*/
|
*/
|
||||||
struct ipc_callbacks_t {
|
struct ipc_callbacks_t {
|
||||||
void (*on_set_mode)(int mode);
|
void (*on_set_mode)(int mode);
|
||||||
void (*on_set_frequency)(int freq);
|
void (*on_set_period)(uint32_t period_ms);
|
||||||
void (*on_inc_frequency)(void);
|
void (*on_inc_period)(void);
|
||||||
void (*on_dec_frequency)(void);
|
void (*on_dec_period)(void);
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ int main(void) {
|
|||||||
btn_set_callback(btn_mode, mode_toggle);
|
btn_set_callback(btn_mode, mode_toggle);
|
||||||
|
|
||||||
struct ipc_callbacks_t ipc_cbs = {
|
struct ipc_callbacks_t ipc_cbs = {
|
||||||
.on_dec_frequency = decrease_period,
|
.on_dec_period = decrease_period,
|
||||||
.on_inc_frequency = increase_period,
|
.on_inc_period = increase_period,
|
||||||
// .on_set_frequency = set_period,
|
.on_set_period = set_period,
|
||||||
.on_set_mode = set_mode,
|
.on_set_mode = set_mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user