Extract function
This commit is contained in:
parent
5d51a1bf9e
commit
e366853f11
2 changed files with 6 additions and 2 deletions
|
@ -267,6 +267,10 @@ inline void send_i_infomessage(struct module from, uint8_t *data, uint8_t data_l
|
||||||
send(&msg);
|
send(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool is_from_controller(struct module from) {
|
||||||
|
return from.type == OBUS_TYPE_CONTROLLER && from.id == OBUS_CONTROLLER_ID;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* end of include guard: OBUS_CAN_H */
|
#endif /* end of include guard: OBUS_CAN_H */
|
||||||
|
|
|
@ -115,7 +115,7 @@ bool loopPuzzle(obus_can::message* message, void (*callback_game_start)(), void
|
||||||
|
|
||||||
bool interesting_message = false;
|
bool interesting_message = false;
|
||||||
if (obus_can::receive(message)) {
|
if (obus_can::receive(message)) {
|
||||||
if (message->from.type == OBUS_TYPE_CONTROLLER && message->from.id == 0) {
|
if (is_from_controller(message->from)) {
|
||||||
switch (message->msg_type) {
|
switch (message->msg_type) {
|
||||||
case OBUS_MSGTYPE_C_GAMESTART:
|
case OBUS_MSGTYPE_C_GAMESTART:
|
||||||
active = true;
|
active = true;
|
||||||
|
@ -157,7 +157,7 @@ bool loopNeedy(obus_can::message* message, void (*callback_game_start)(), void (
|
||||||
bool loopInfo(obus_can::message* message, int (*info_generator)(uint8_t*)) {
|
bool loopInfo(obus_can::message* message, int (*info_generator)(uint8_t*)) {
|
||||||
bool interesting_message = false;
|
bool interesting_message = false;
|
||||||
if (obus_can::receive(message)) {
|
if (obus_can::receive(message)) {
|
||||||
if (message->from.type == OBUS_TYPE_CONTROLLER && message->from.id == 0) {
|
if (is_from_controller(message->from)) {
|
||||||
switch (message->msg_type) {
|
switch (message->msg_type) {
|
||||||
case OBUS_MSGTYPE_C_INFOSTART:
|
case OBUS_MSGTYPE_C_INFOSTART:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue