Skip to content

Commit

Permalink
Merge branch 'main' into UDS_protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
AdonaiDiazEsparza committed Nov 8, 2024
2 parents 7a38d99 + 9faeab7 commit ec3341b
Show file tree
Hide file tree
Showing 24 changed files with 80 additions and 110 deletions.
Binary file added Canbus_app/assets/CAR52x20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/DTCLN47x20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/EC48x26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/ECU24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/ENG28x20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/ENGTIME39x21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/FILERROR27x38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/FTANK28x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/LOAD28x20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/MSGERROR41x38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/MSGOK41x38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/NOC119x38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/RPLYOK49x38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/RPM30x23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/SPD64x20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/THR36x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Canbus_app/assets/WIP45x38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 14 additions & 21 deletions Canbus_app/draw_functions/drawWidgets.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,39 @@
// Draws a developmet
void draw_in_development(App* app) {
widget_reset(app->widget);

widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "SCENE IN");

widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "DEVELOPMENT");
widget_add_icon_element(app->widget, 41, 0, &I_WIP45x38);
widget_add_string_multiline_element(
app->widget, 65, 60, AlignCenter, AlignBottom, FontPrimary, "WORK IN\nPROGRESS");
}

// Draws device not connected
void draw_device_no_connected(App* app) {
widget_reset(app->widget);

widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "DEVICE NOT");

widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "CONNECTED");
widget_add_icon_element(app->widget, 4, 0, &I_NOC119x38);
widget_add_string_multiline_element(
app->widget, 65, 60, AlignCenter, AlignBottom, FontPrimary, "DEVICE NOT\nCONNECTED");
}

// draw when a message is not recognized
void draw_transmition_failure(App* app) {
widget_reset(app->widget);

widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "TRANSMITION");

widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "FAILURE");
widget_add_icon_element(app->widget, 43, 0, &I_MSGERROR41x38);
widget_add_string_multiline_element(
app->widget, 65, 60, AlignCenter, AlignBottom, FontPrimary, "TRANSMISSION\nFAILURE");
}

// draw when a message is send OK
void draw_send_wrong(App* app) {
widget_reset(app->widget);
widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignCenter, FontPrimary, "MESSAGE SEND ERROR");
widget_add_icon_element(app->widget, 43, 0, &I_MSGERROR41x38);
widget_add_string_multiline_element(
app->widget, 65, 60, AlignCenter, AlignBottom, FontPrimary, "ERROR SENDING\nMESSAGE");
}

// draw when a message is send ok
void draw_send_ok(App* app) {
widget_reset(app->widget);
widget_add_icon_element(app->widget, 43, 0, &I_MSGOK41x38);
widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignCenter, FontPrimary, "MESSAGE SEND OK");
app->widget, 65, 50, AlignCenter, AlignCenter, FontPrimary, "MESSAGE SENT OK");
}
14 changes: 5 additions & 9 deletions Canbus_app/scenes/AboutUs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ static void button_callback(GuiButtonType result, InputType input, void* context

static void draw_present_view(App* app) {
widget_reset(app->widget);
widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignCenter, FontPrimary, "ELECTRONIC CATS");
widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignCenter, FontPrimary, "Presents:");

widget_add_icon_element(app->widget, 40, 1, &I_EC48x26);
widget_add_string_multiline_element(
app->widget, 65, 40, AlignCenter, AlignCenter, FontPrimary, "ELECTRONIC CATS \n Presents:");
widget_add_button_element(app->widget, GuiButtonTypeRight, "Next", button_callback, app);
}

static void draw_can_app_view(App* app) {
widget_reset(app->widget);
widget_add_string_element(
widget_add_string_multiline_element(
app->widget, 65, 20, AlignCenter, AlignCenter, FontPrimary, "CANBUS APP");
widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignCenter, FontSecondary, "v1.1.3");
app->widget, 65, 35, AlignCenter, AlignCenter, FontSecondary, "v1.1.3.1");

widget_add_button_element(app->widget, GuiButtonTypeRight, "Next", button_callback, app);
widget_add_button_element(app->widget, GuiButtonTypeLeft, "Prev", button_callback, app);
Expand All @@ -52,9 +50,7 @@ void draw_more_info_view(App* app) {
widget_reset(app->widget);
widget_add_string_element(
app->widget, 10, 5, AlignLeft, AlignCenter, FontPrimary, "More info:");

widget_add_icon_element(app->widget, 48, 15, &I_qrcode);

widget_add_button_element(app->widget, GuiButtonTypeLeft, "Prev", button_callback, app);
}

Expand Down
30 changes: 10 additions & 20 deletions Canbus_app/scenes/Obd2Options/dtcPIDOption.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,29 @@ static int32_t obdii_thread_dtc_on_work(void* context) {
if(delete_dtc && run) {
if(clear_dtc(&scanner)) {
widget_reset(app->widget);
widget_add_icon_element(app->widget, 40, 0, &I_DTCLN47x20);
widget_add_string_multiline_element(
app->widget, 65, 43, AlignCenter, AlignBottom, FontPrimary, "ALL DTC\nCLEARED");

widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "ALL DTC");

widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "CLEARED");
} else {
widget_reset(app->widget);

widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "ERROR");

widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "CLEARING");
widget_add_string_multiline_element(
app->widget, 65, 43, AlignCenter, AlignBottom, FontPrimary, "E R R O R\nCLEARING");
}
} else if(!delete_dtc && run) {
if(request_dtc(&scanner, &(count_dtc), codes)) {
if(count_dtc == 0) {
widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "NO DTC");

widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "DETECTED");
widget_add_string_multiline_element(
app->widget, 65, 43, AlignCenter, AlignBottom, FontPrimary, "NO DTC\nDETECTED");

} else
loop = true;

} else {
widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "REQUESTED");

widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "ERROR");
widget_add_icon_element(app->widget, 43, 0, &I_MSGERROR41x38);
widget_add_string_multiline_element(
app->widget, 65, 60, AlignCenter, AlignBottom, FontPrimary, "REQUEST\nERROR");
}

} else {
Expand Down
11 changes: 6 additions & 5 deletions Canbus_app/scenes/Obd2Options/getCarDataOption.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ static int32_t obdii_get_car_data(void* context) {

if(app->request_data == 1) {
if(get_VIN(&scanner, app->text)) {
widget_add_icon_element(app->widget, 38, 1, &I_CAR52x20);
widget_add_string_element(
app->widget, 64, 20, AlignCenter, AlignCenter, FontPrimary, "VIN Number:");

app->widget, 64, 36, AlignCenter, AlignCenter, FontPrimary, "VIN Number:");
widget_add_string_element(
app->widget,
64,
32,
51,
AlignCenter,
AlignCenter,
FontSecondary,
Expand All @@ -68,13 +68,14 @@ static int32_t obdii_get_car_data(void* context) {
}
if(app->request_data == 2) {
if(get_ECU_name(&scanner, app->text)) {
widget_add_icon_element(app->widget, 52, 1, &I_ECU24x24);
widget_add_string_element(
app->widget, 64, 20, AlignCenter, AlignCenter, FontPrimary, "ECU Name:");
app->widget, 65, 40, AlignCenter, AlignCenter, FontPrimary, "ECU Name:");

widget_add_string_element(
app->widget,
64,
32,
55,
AlignCenter,
AlignCenter,
FontSecondary,
Expand Down
57 changes: 32 additions & 25 deletions Canbus_app/scenes/Obd2Options/typicalPIDOption.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ void app_scene_obdii_typical_codes_on_enter(void* context) {
submenu_add_item(app->submenu, "Engine Speed", 0, typical_menu_callback, app);
submenu_add_item(app->submenu, "Vehicle Speed", 1, typical_menu_callback, app);
submenu_add_item(app->submenu, "Calculated Engine Load", 2, typical_menu_callback, app);
submenu_add_item(app->submenu, "Thortle Position", 3, typical_menu_callback, app);
submenu_add_item(app->submenu, "Throttle Position", 3, typical_menu_callback, app);
submenu_add_item(app->submenu, "Fuel Tank Input Level", 4, typical_menu_callback, app);
submenu_add_item(app->submenu, "Thortle Relative Position", 5, typical_menu_callback, app);
submenu_add_item(app->submenu, "Throttle Relative Position", 5, typical_menu_callback, app);
submenu_add_item(app->submenu, "Time Engine Running", 6, typical_menu_callback, app);

submenu_set_selected_item(
Expand Down Expand Up @@ -64,7 +64,7 @@ void app_scene_obdii_typical_codes_on_exit(void* context) {

// Draw the unit medition
void draw_value(App* app, const char* text) {
widget_add_string_element(app->widget, 65, 45, AlignCenter, AlignBottom, FontPrimary, text);
widget_add_string_element(app->widget, 65, 55, AlignCenter, AlignBottom, FontPrimary, text);
}

// Draws the data
Expand All @@ -77,49 +77,56 @@ void draw_scene(App* app, uint8_t selector, uint16_t variable) {
widget_reset(app->widget);

if(selector == 0) { // Engine Speed
widget_add_icon_element(app->widget, 50, 3, &I_RPM30x23);
widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "ENGINE SPEED");
app->widget, 65, 40, AlignCenter, AlignBottom, FontPrimary, "ENGINE SPEED");

text = "RPM";

} else if(selector == 1) { // Vehicle Speed
widget_add_icon_element(app->widget, 37, 5, &I_SPD64x20);
widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "VEHICLE SPEED");
text = "KM/H";
app->widget, 65, 40, AlignCenter, AlignBottom, FontPrimary, "VEHICLE SPEED");

} else if(selector == 2) { // CALCULATED ENGINE LOAD
widget_add_string_element(
app->widget, 65, 15, AlignCenter, AlignBottom, FontPrimary, "CALCULATED");
text = "km/h";

widget_add_string_element(
app->widget, 65, 30, AlignCenter, AlignBottom, FontPrimary, "ENGINE LOAD");
} else if(selector == 2) { // CALCULATED ENGINE LOAD
widget_add_icon_element(app->widget, 50, 0, &I_LOAD28x20);
widget_add_string_multiline_element(
app->widget, 65, 43, AlignCenter, AlignBottom, FontPrimary, "CALCULATED\nENGINE LOAD");

text = "%";

} else if(selector == 3) { // Thortle Position
widget_add_icon_element(app->widget, 46, 0, &I_THR36x24);
widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "THORLE POSITION");
app->widget, 65, 40, AlignCenter, AlignBottom, FontPrimary, "THROTTLE POSITION");

text = "%";

} else if(selector == 4) { // Fuel Tank Input Level
widget_add_string_element(
app->widget, 65, 15, AlignCenter, AlignBottom, FontPrimary, "FUEL TANK");
widget_add_string_element(
app->widget, 65, 30, AlignCenter, AlignBottom, FontPrimary, "INPUT LEVEL");
widget_add_icon_element(app->widget, 50, 0, &I_FTANK28x24);
widget_add_string_multiline_element(
app->widget, 65, 45, AlignCenter, AlignBottom, FontPrimary, "FUEL TANK\nINPUT LEVEL");

text = "%";

} else if(selector == 5) { // Thortle Relative Position
widget_add_string_element(
app->widget, 65, 15, AlignCenter, AlignBottom, FontPrimary, "THORTLE");
widget_add_string_element(
app->widget, 65, 30, AlignCenter, AlignBottom, FontPrimary, "RELATIVE POSITION");
widget_add_icon_element(app->widget, 46, 0, &I_THR36x24);
widget_add_string_multiline_element(
app->widget,
65,
45,
AlignCenter,
AlignBottom,
FontPrimary,
"THROTTLE\nRELATIVE POSITION");

text = "%";
} else if(selector == 6) {
widget_add_string_element(
app->widget, 65, 15, AlignCenter, AlignBottom, FontPrimary, "TIME SINCE");
widget_add_string_element(
app->widget, 65, 30, AlignCenter, AlignBottom, FontPrimary, "ENGINE START");
widget_add_icon_element(app->widget, 45, 0, &I_ENGTIME39x21);
widget_add_string_multiline_element(
app->widget, 65, 43, AlignCenter, AlignBottom, FontPrimary, "TIME SINCE\nENGINE START");

text = "seg";
}
Expand Down Expand Up @@ -246,7 +253,7 @@ static int32_t obdii_thread_on_work(void* context) {
draw_scene(app, option, calculate_engine_load(data[3]));
break;

case 3: // Thortle Position
case 3: // Throttle Position
draw_scene(app, option, calculate_engine_load(data[3]));
break;

Expand Down
25 changes: 8 additions & 17 deletions Canbus_app/scenes/playLogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,16 @@ void path_file_name(const char* path, FuriString* file_name) {
}
}

// For the device no connected
void draw_device_fail_connected(App* app) {
widget_reset(app->widget);

widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "DEVICE NO");

widget_add_string_element(
app->widget, 65, 35, AlignCenter, AlignBottom, FontPrimary, "CONNECTED");
}

// For the message
void draw_message_send(App* app) {
widget_reset(app->widget);
widget_add_string_element(
app->widget, 62, 30, AlignCenter, AlignBottom, FontPrimary, "Sending Ok...");
app->widget, 62, 25, AlignCenter, AlignBottom, FontPrimary, "Sending...");

widget_add_string_element(
app->widget,
62,
50,
40,
AlignCenter,
AlignBottom,
FontSecondary,
Expand All @@ -118,7 +107,7 @@ void draw_message_send(App* app) {
void draw_message_fail(App* app) {
widget_reset(app->widget);
widget_add_string_element(
app->widget, 62, 30, AlignCenter, AlignBottom, FontPrimary, "Sending Fail...");
app->widget, 62, 30, AlignCenter, AlignBottom, FontPrimary, "Sending Failed...");

widget_add_string_element(
app->widget,
Expand All @@ -132,14 +121,16 @@ void draw_message_fail(App* app) {

void draw_finished(App* app) {
widget_reset(app->widget);
widget_add_icon_element(app->widget, 39, 0, &I_RPLYOK49x38);
widget_add_string_element(
app->widget, 62, 32, AlignCenter, AlignBottom, FontPrimary, "Replay Finished");
app->widget, 62, 47, AlignCenter, AlignCenter, FontPrimary, "REPLAY FINISHED");
}

void draw_file_no_opened(App* app) {
widget_reset(app->widget);
widget_add_icon_element(app->widget, 50, 0, &I_FILERROR27x38);
widget_add_string_element(
app->widget, 62, 32, AlignCenter, AlignBottom, FontPrimary, "File cannot be opened");
app->widget, 62, 47, AlignCenter, AlignCenter, FontPrimary, "File cannot be opened");
}

void draw_starting_transmition(App* app) {
Expand All @@ -156,7 +147,7 @@ void play_data_frames_bk(void* context, int frame_interval) {
debug = mcp2515_init(app->mcp_can);

if(debug != ERROR_OK) {
draw_device_fail_connected(app);
draw_device_no_connected(app);
return;
}

Expand Down
18 changes: 5 additions & 13 deletions Canbus_app/scenes/senderOption.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void app_scene_send_message_on_enter(void* context) {

widget_reset(app->widget);
widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignCenter, FontPrimary, "Wait to send it Message...");
app->widget, 65, 32, AlignCenter, AlignCenter, FontPrimary, "Waiting to send...");

view_dispatcher_switch_to_view(app->view_dispatcher, ViewWidget);

Expand Down Expand Up @@ -347,24 +347,16 @@ void app_scene_warning_log_on_enter(void* context) {
widget_reset(app->widget);

widget_add_string_element(
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "W A R N I N G");
app->widget, 65, 20, AlignCenter, AlignBottom, FontPrimary, "W A R N I N G !");

widget_add_string_element(
widget_add_string_multiline_element(
app->widget,
65,
40,
35,
AlignCenter,
AlignBottom,
FontSecondary,
"First go to the Sniffing option");
widget_add_string_element(
app->widget,
65,
50,
AlignCenter,
AlignBottom,
FontSecondary,
"in the menu and get the Id's");
"First go to the Sniffing option\nin the menu and get the ID's");

view_dispatcher_switch_to_view(app->view_dispatcher, ViewWidget);
}
Expand Down

0 comments on commit ec3341b

Please sign in to comment.