Extract function

This commit is contained in:
redfast00 2020-10-22 21:16:12 +02:00
parent 5d51a1bf9e
commit e366853f11
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C
2 changed files with 6 additions and 2 deletions

View file

@ -267,6 +267,10 @@ inline void send_i_infomessage(struct module from, uint8_t *data, uint8_t data_l
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 */

View file

@ -115,7 +115,7 @@ bool loopPuzzle(obus_can::message* message, void (*callback_game_start)(), void
bool interesting_message = false;
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) {
case OBUS_MSGTYPE_C_GAMESTART:
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 interesting_message = false;
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) {
case OBUS_MSGTYPE_C_INFOSTART:
{