-
Notifications
You must be signed in to change notification settings - Fork 1
battery monitor tx message #209
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: dev
Are you sure you want to change the base?
Changes from 2 commits
98e5101
ff4607c
ade072d
0dfd2d0
239458f
bc81fca
835eb8e
b1b6906
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # ruff: noqa: F821 | ||
|
|
||
| Import('env') | ||
| Import('envs') | ||
|
|
||
|
|
||
| firmware, flash = env.SConscript( | ||
| 'src/SConscript.py', | ||
| exports={'env': envs['esp32s3']}, | ||
| ) | ||
|
|
||
| component, name = env.Component(firmware, env.File('component.toml')) | ||
| env.ComponentSubtarget(name, 'flash', flash) | ||
|
|
||
|
|
||
| Return('component') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [metadata] | ||
| name = 'batt' | ||
| description = 'battery-monitor' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #include "batt.h" | ||
|
|
||
| #include "firmware-base/state-machine.h" | ||
| #include <ember_taskglue.h> | ||
| #include <freertos/FreeRTOS.h> | ||
| #include <freertos/task.h> | ||
| #include <opencan_rx.h> | ||
| #include <opencan_tx.h> | ||
|
|
||
| #include <math.h> | ||
|
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. Include only the headers you need. |
||
| #include <string.h> | ||
|
|
||
| // hypothetical battery percent data | ||
| typedef struct { | ||
|
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. We don't need to make a CAN data struct, this is already generated by OpenCAN, we just have to implement a populate function. |
||
| uint8_t batteryPercent; | ||
| } CAN_Message_BatteryStatus; | ||
|
|
||
| static uint8_t batterypercent; | ||
|
|
||
| static void batt_1Hz(); | ||
|
|
||
| // task scheduling | ||
|
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. Don't add redundant comments. |
||
| ember_rate_funcs_S module_rf = { | ||
| .call_1Hz = batt_1Hz, | ||
| }; | ||
|
|
||
| static void batt_1Hz() | ||
| { | ||
| /* | ||
|
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. Not in this scope, the battery monitor will just report the battery percentage. |
||
| Do I need any authorizationsfrom SUP? like | ||
| CANRX_is_message_battery_percent_data_Authorization_ok() | ||
| */ | ||
| batteryPercent = 0; | ||
| } | ||
|
|
||
| void CANTX_populate_BATT_BatteryPercentData( | ||
|
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. Where's the associated entry in |
||
| struct CAN_Message_BatteryStatus * const m) | ||
| { | ||
| m->batteryPercent = batteryPercent; | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,4 @@ | ||||||
| #ifndef BATT_H | ||||||
| #define BATT_H | ||||||
|
|
||||||
| #endif // BATT.H | ||||||
|
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.
Suggested change
|
||||||
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.
Where is the
SConscript.pyundersrc/?