-
Notifications
You must be signed in to change notification settings - Fork 1
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
battery monitor tx message #209
base: dev
Are you sure you want to change the base?
Conversation
#include <opencan_rx.h> | ||
#include <opencan_tx.h> | ||
|
||
#include <math.h> |
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.
Include only the headers you need.
components/batt/src/batt.c
Outdated
#include <string.h> | ||
|
||
// hypothetical battery percent data | ||
typedef struct { |
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.
We don't need to make a CAN data struct, this is already generated by OpenCAN, we just have to implement a populate function.
components/batt/src/batt.c
Outdated
|
||
static void batt_1Hz(); | ||
|
||
// task scheduling |
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.
Don't add redundant comments.
components/batt/src/batt.c
Outdated
|
||
static void batt_1Hz() | ||
{ | ||
/* |
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.
Not in this scope, the battery monitor will just report the battery percentage.
components/batt/src/batt.c
Outdated
batteryPercent = 0; | ||
} | ||
|
||
void CANTX_populate_BATT_BatteryPercentData( |
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's the associated entry in can/network.yml
?
|
||
|
||
firmware, flash = env.SConscript( | ||
'src/SConscript.py', |
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.py
under src/
?
#ifndef BATT_H | ||
#define BATT_H | ||
|
||
#endif // BATT.H |
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.
#endif // BATT.H | |
#endif /* BATT_H */ |
@@ -13,6 +13,7 @@ | |||
'steer', | |||
'sup', | |||
'throttle', | |||
'batt', |
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.
Let's try to keep this list in alphabetical order.
], | ||
) | ||
for src in [ | ||
'batt.c', # Ensure this file exists in your source directory |
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.
'batt.c', # Ensure this file exists in your source directory | |
'batt.c', |
] | ||
] | ||
|
||
# Correct the typo in the variable name |
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.
Why didn't you just fix it?
components/sup/src/firmware-base
Outdated
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.
This should have stayed a symlink!
(sizeof(adc_digi_output_data_t) * FRAME_SAMPLES * ADC_CHANNELS) | ||
|
||
#define SAMPLES_OUT_SIZE 1024 // how to decide the size of the output | ||
#define PREV_SAMPLES_DELAY 0.010 // why is this the delay time |
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.
To answer the comment, this was arbitrarily chosen :)
#define ADC_CONV ADC_CONV_SINGLE_UNIT_1 | ||
#define ADC_DIGI_OUTPUT_FORMAT ADC_DIGI_OUTPUT_FORMAT_TYPE2 | ||
|
||
#define BV_ADC_ATTEN ADC_ATTEN_DB_12 | ||
#define BV_ADC_UNIT ADC_UNIT_2 | ||
#define BV_ADC_CHANNEL ADC_CHANNEL_7 // GPIO_8 | ||
#define BV_ADC_BITWIDTH SOC_ADC_DIGI_MAX_BITWIDTH |
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.
Nice!
// #define PWM_INIT_DUTY_CYCLE 0 | ||
// #define PWM_RESOLUTION 10 | ||
|
||
adc_continuous_handle_t handle = NULL; |
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.
adc_continuous_handle_t handle = NULL; | |
static adc_continuous_handle_t handle; |
This will automatically be set to NULL
if we don't initialize it as a global variable. I'd also change the handle to be static
so that we don't pollute the global symbol table.
.conv_frame_size = FRAME_SIZE, | ||
}; | ||
|
||
ESP_ERROR_CHECK( |
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.
Let's get rid of the ESP_ERROS_CHECK()
macros and instead create an error variable for the return value and set a flag if initialization failed and report that over CAN. We can then extend this CAN signal to just be the ADC status by using an enum. Take inspiration from eeprom_read()
.
Co-authored-by: Jacob Koziej <jacobkoziej@gmail.com>
No description provided.