-
Notifications
You must be signed in to change notification settings - Fork 16
Implement AMK dashboard page #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /** | ||
| * @file amk.c | ||
| * @brief AMK page implementation | ||
| * | ||
| * @author Amruth Nadimpally (nadimpaa@purdue.edu) | ||
| * @author Aditya Saini (sain91@purdue.edu) | ||
| */ | ||
|
|
||
| #include "amk.h" | ||
|
|
||
| #include "common/can_library/generated/DASHBOARD.h" | ||
| #include "nextion.h" | ||
| #include "colors.h" | ||
|
|
||
| void amk_telemetry_update() { | ||
| NXT_setFontColor(INVA_BERROR, WHITE); | ||
| NXT_setFontColor(INVB_BERROR, WHITE); | ||
| NXT_setFontColor(INVC_BERROR, WHITE); | ||
| NXT_setFontColor(INVD_BERROR, WHITE); | ||
| NXT_setFontColor(INVA_DIAGNOSTIC, WHITE); | ||
| NXT_setFontColor(INVB_DIAGNOSTIC, WHITE); | ||
| NXT_setFontColor(INVC_DIAGNOSTIC, WHITE); | ||
| NXT_setFontColor(INVD_DIAGNOSTIC, WHITE); | ||
| NXT_setFontColor(INVA_ON, WHITE); | ||
| NXT_setFontColor(INVB_ON, WHITE); | ||
| NXT_setFontColor(INVC_ON, WHITE); | ||
| NXT_setFontColor(INVD_ON, WHITE); | ||
|
|
||
| if (can_data.inva_set_vcan.is_stale()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. theres too much repeated code here |
||
| NXT_setFontColor(INVA_STATUS, RED); | ||
| NXT_setText(INVA_STATUS, "STALE"); | ||
| NXT_setText(INVA_BERROR, "--"); | ||
| NXT_setText(INVA_DIAGNOSTIC, "--"); | ||
| NXT_setText(INVA_ON, "--"); | ||
| } else { | ||
| NXT_setFontColor(INVA_STATUS, can_data.inva_set_vcan.AMK_Control_bEnable ? GREEN : RED); | ||
| NXT_setText(INVA_STATUS, can_data.inva_set_vcan.AMK_Control_bEnable ? "ENABLE" : "DISABLE"); | ||
| NXT_setText(INVA_ON, can_data.inva_set_vcan.AMK_Control_bInverterOn ? "ON" : "OFF"); | ||
| NXT_setText(INVA_BERROR, can_data.inva_set_vcan.AMK_Control_bErrorReset ? "RESET" : "OK"); | ||
| int16_t inva_torque = (int16_t)( | ||
| can_data.inva_set_vcan.AMK_TorqueSetpoint * UNPACK_COEFF_INVC_SET_VCAN_AMK_TORQUESETPOINT | ||
| ); | ||
| NXT_setTextFormatted(INVA_DIAGNOSTIC, "%d", inva_torque); | ||
| } | ||
|
|
||
| if (can_data.invb_set_vcan.is_stale()) { | ||
| NXT_setFontColor(INVB_STATUS, RED); | ||
| NXT_setText(INVB_STATUS, "STALE"); | ||
| NXT_setText(INVB_BERROR, "--"); | ||
| NXT_setText(INVB_DIAGNOSTIC, "--"); | ||
| NXT_setText(INVB_ON, "--"); | ||
| } else { | ||
| NXT_setFontColor(INVB_STATUS, can_data.invb_set_vcan.AMK_Control_bEnable ? GREEN : RED); | ||
| NXT_setText(INVB_STATUS, can_data.invb_set_vcan.AMK_Control_bEnable ? "ENABLE" : "DISABLE"); | ||
| NXT_setText(INVB_ON, can_data.invb_set_vcan.AMK_Control_bInverterOn ? "ON" : "OFF"); | ||
| NXT_setText(INVB_BERROR, can_data.invb_set_vcan.AMK_Control_bErrorReset ? "RESET" : "OK"); | ||
| int16_t invb_torque = (int16_t)( | ||
| can_data.invb_set_vcan.AMK_TorqueSetpoint * UNPACK_COEFF_INVC_SET_VCAN_AMK_TORQUESETPOINT | ||
| ); | ||
| NXT_setTextFormatted(INVB_DIAGNOSTIC, "%d", invb_torque); | ||
| } | ||
|
|
||
| if (can_data.invc_set_vcan.is_stale()) { | ||
| NXT_setFontColor(INVC_STATUS, RED); | ||
| NXT_setText(INVC_STATUS, "STALE"); | ||
| NXT_setText(INVC_BERROR, "--"); | ||
| NXT_setText(INVC_DIAGNOSTIC, "--"); | ||
| NXT_setText(INVC_ON, "--"); | ||
| } else { | ||
| NXT_setFontColor(INVC_STATUS, can_data.invc_set_vcan.AMK_Control_bEnable ? GREEN : RED); | ||
| NXT_setText(INVC_STATUS, can_data.invc_set_vcan.AMK_Control_bEnable ? "ENABLE" : "DISABLE"); | ||
| NXT_setText(INVC_ON, can_data.invc_set_vcan.AMK_Control_bInverterOn ? "ON" : "OFF"); | ||
| NXT_setText(INVC_BERROR, can_data.invc_set_vcan.AMK_Control_bErrorReset ? "RESET" : "OK"); | ||
| int16_t invc_torque = (int16_t)( | ||
| can_data.invc_set_vcan.AMK_TorqueSetpoint * UNPACK_COEFF_INVC_SET_VCAN_AMK_TORQUESETPOINT | ||
| ); | ||
| NXT_setTextFormatted(INVC_DIAGNOSTIC, "%d", invc_torque); | ||
| } | ||
|
|
||
| if (can_data.invd_set_vcan.is_stale()) { | ||
| NXT_setFontColor(INVD_STATUS, RED); | ||
| NXT_setText(INVD_STATUS, "STALE"); | ||
| NXT_setText(INVD_BERROR, "--"); | ||
| NXT_setText(INVD_DIAGNOSTIC, "--"); | ||
| NXT_setText(INVD_ON, "--"); | ||
| } else { | ||
| NXT_setFontColor(INVD_STATUS, can_data.invd_set_vcan.AMK_Control_bEnable ? GREEN : RED); | ||
| NXT_setText(INVD_STATUS, can_data.invd_set_vcan.AMK_Control_bEnable ? "ENABLE" : "DISABLE"); | ||
| NXT_setText(INVD_ON, can_data.invd_set_vcan.AMK_Control_bInverterOn ? "ON" : "OFF"); | ||
| NXT_setText(INVD_BERROR, can_data.invd_set_vcan.AMK_Control_bErrorReset ? "RESET" : "OK"); | ||
| int16_t invd_torque = (int16_t)( | ||
| can_data.invd_set_vcan.AMK_TorqueSetpoint * UNPACK_COEFF_INVC_SET_VCAN_AMK_TORQUESETPOINT | ||
| ); | ||
| NXT_setTextFormatted(INVD_DIAGNOSTIC, "%d", invd_torque); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #ifndef AMK_H | ||
| #define AMK_H | ||
|
|
||
| /** | ||
| * @file amk.h | ||
| * @brief AMK page implementation | ||
| * | ||
| * @author Amruth Nadimpally (nadimpaa@purdue.edu) | ||
| * @author Aditya Saini (sain91@purdue.edu) | ||
| */ | ||
|
|
||
| #define AMK_STRING "amk" | ||
|
|
||
| // Nextion object names | ||
| #define INVA_STATUS "A" | ||
| #define INVB_STATUS "B" | ||
| #define INVC_STATUS "C" | ||
| #define INVD_STATUS "D" | ||
| #define INVA_BERROR "aberror" | ||
| #define INVB_BERROR "bberror" | ||
| #define INVC_BERROR "cberror" | ||
| #define INVD_BERROR "dberror" | ||
| #define INVA_DIAGNOSTIC "da" | ||
| #define INVB_DIAGNOSTIC "db" | ||
| #define INVC_DIAGNOSTIC "dc" | ||
| #define INVD_DIAGNOSTIC "dd" | ||
| #define INVA_ON "ia" | ||
| #define INVB_ON "ib" | ||
| #define INVC_ON "ic" | ||
| #define INVD_ON "id" | ||
|
|
||
| void amk_telemetry_update(); | ||
|
|
||
| #endif // AMK_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,54 @@ void report_telemetry() { | |
| g_car.rear_left.temps->AMK_IGBTTemp, | ||
| g_car.rear_right.temps->AMK_IGBTTemp | ||
| ); | ||
|
|
||
| CAN_SEND_inva_set_vcan( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prob shouldnt send this here, we dont want to potentially slow down the more critical stuff |
||
| g_car.front_right.set->AMK_Control_bReserve, | ||
| g_car.front_right.set->AMK_Control_bInverterOn, | ||
| g_car.front_right.set->AMK_Control_bDcOn, | ||
| g_car.front_right.set->AMK_Control_bEnable, | ||
| g_car.front_right.set->AMK_Control_bErrorReset, | ||
| g_car.front_right.set->AMK_Control_bReserve2, | ||
| g_car.front_right.set->AMK_TorqueSetpoint, | ||
| g_car.front_right.set->AMK_PositiveTorqueLimit, | ||
| g_car.front_right.set->AMK_NegativeTorqueLimit | ||
| ); | ||
|
|
||
| CAN_SEND_invb_set_vcan( | ||
| g_car.front_left.set->AMK_Control_bReserve, | ||
| g_car.front_left.set->AMK_Control_bInverterOn, | ||
| g_car.front_left.set->AMK_Control_bDcOn, | ||
| g_car.front_left.set->AMK_Control_bEnable, | ||
| g_car.front_left.set->AMK_Control_bErrorReset, | ||
| g_car.front_left.set->AMK_Control_bReserve2, | ||
| g_car.front_left.set->AMK_TorqueSetpoint, | ||
| g_car.front_left.set->AMK_PositiveTorqueLimit, | ||
| g_car.front_left.set->AMK_NegativeTorqueLimit | ||
| ); | ||
|
|
||
| CAN_SEND_invc_set_vcan( | ||
| g_car.rear_left.set->AMK_Control_bReserve, | ||
| g_car.rear_left.set->AMK_Control_bInverterOn, | ||
| g_car.rear_left.set->AMK_Control_bDcOn, | ||
| g_car.rear_left.set->AMK_Control_bEnable, | ||
| g_car.rear_left.set->AMK_Control_bErrorReset, | ||
| g_car.rear_left.set->AMK_Control_bReserve2, | ||
| g_car.rear_left.set->AMK_TorqueSetpoint, | ||
| g_car.rear_left.set->AMK_PositiveTorqueLimit, | ||
| g_car.rear_left.set->AMK_NegativeTorqueLimit | ||
| ); | ||
|
|
||
| CAN_SEND_invd_set_vcan( | ||
| g_car.rear_right.set->AMK_Control_bReserve, | ||
| g_car.rear_right.set->AMK_Control_bInverterOn, | ||
| g_car.rear_right.set->AMK_Control_bDcOn, | ||
| g_car.rear_right.set->AMK_Control_bEnable, | ||
| g_car.rear_right.set->AMK_Control_bErrorReset, | ||
| g_car.rear_right.set->AMK_Control_bReserve2, | ||
| g_car.rear_right.set->AMK_TorqueSetpoint, | ||
| g_car.rear_right.set->AMK_PositiveTorqueLimit, | ||
| g_car.rear_right.set->AMK_NegativeTorqueLimit | ||
| ); | ||
| } | ||
|
|
||
| void fsm_periodic() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
u need more information than echoing inv_set. i would trim this down to a custom message which includes the amk state and diagnostic stuff only