diff --git a/due_obd2/due_obd2.ino b/due_obd2/due_obd2.ino index 5a1be89..38dfc97 100644 --- a/due_obd2/due_obd2.ino +++ b/due_obd2/due_obd2.ino @@ -310,6 +310,9 @@ void on_main_enter() display.setColor(VGA_AQUA); } +/** + * @brief Main loop of the main state. Queries the OBD2 scanner for values and updates the display. + */ void on_main_run() { if (update_slow) diff --git a/due_obd2/obd2_elm327.cpp b/due_obd2/obd2_elm327.cpp index 9f9f7b1..db95525 100644 --- a/due_obd2/obd2_elm327.cpp +++ b/due_obd2/obd2_elm327.cpp @@ -52,6 +52,21 @@ void obd2_elm327_get_state(obd2_elm327_t *elm327, char *state) strcpy(state, bt_states[elm327->bt_state]); } +char obd2_el327_is_bit_set(obd2_elm327_t *elm327, uint16_t pos) +{ + return elm327->value_updates & (1 << pos); +} + +void obd2_el327_set_bit(obd2_elm327_t *elm327, uint16_t pos) +{ + elm327->value_updates |= (1 << pos); +} + +void obd2_el327_clear_bit(obd2_elm327_t *elm327, uint16_t pos) +{ + elm327->value_updates &= ~(1 << pos); +} + void obd2_elm327_check_connection(obd2_elm327_t *elm327) { if (elm327->bt_state != BT_CONNECTED) diff --git a/due_obd2/obd2_elm327.h b/due_obd2/obd2_elm327.h index f8f093f..20447f3 100644 --- a/due_obd2/obd2_elm327.h +++ b/due_obd2/obd2_elm327.h @@ -132,6 +132,23 @@ void obd2_elm327_check_connection(obd2_elm327_t *elm327); */ void obd2_elm327_get_state(obd2_elm327_t *elm327, char *state); +/** + * @brief checks if a bit is set in the value_updates variable + * + * @returns 1 if the bit is set, 0 if not + */ +char obd2_el327_is_bit_set(obd2_elm327_t *elm327, uint16_t pos); + +/** + * @brief sets a bit in the value_updates variable + */ +void obd2_el327_set_bit(obd2_elm327_t *elm327, uint16_t pos); + +/** + * @brief clears a bit in the value_updates variable + */ +void obd2_el327_clear_bit(obd2_elm327_t *elm327, uint16_t pos); + #ifdef __cplusplus } #endif