Skip to content

Commit

Permalink
ESP-IDF 5 ADC Implementation Updates for Wall-E (#140)
Browse files Browse the repository at this point in the history
* Refactor line sensor initialization and reading

* Refractor to use adc handles

* Update sra-board-component to latest
  • Loading branch information
SuperChamp234 authored Feb 1, 2024
1 parent 0fbb69d commit 69f4cd5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions 2_LSA/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ static const char *TAG = "LSA_READINGS";
void app_main(void)
{
// enable line sensor after checking optimal working state of ESP
ESP_ERROR_CHECK(enable_line_sensor());
adc_handle_t line_sensor;
ESP_ERROR_CHECK(enable_line_sensor(&line_sensor));

// Union containing line sensor readings
line_sensor_array line_sensor_readings;
Expand All @@ -41,7 +42,7 @@ void app_main(void)
while (1)
{
// get line sensor readings from the LSA sensors
line_sensor_readings = read_line_sensor();
line_sensor_readings = read_line_sensor(line_sensor);
for (int i = 0; i < 5; i++)
{
// constrain lsa readings between BLACK_MARGIN and WHITE_MARGIN
Expand Down
5 changes: 3 additions & 2 deletions 6_line_following/main/line_following.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ void line_follow_task(void* arg)
motor_handle_t motor_a_0, motor_a_1;
ESP_ERROR_CHECK(enable_motor_driver(&motor_a_0, MOTOR_A_0));
ESP_ERROR_CHECK(enable_motor_driver(&motor_a_1, MOTOR_A_1));
ESP_ERROR_CHECK(enable_line_sensor());
adc_handle_t line_sensor;
ESP_ERROR_CHECK(enable_line_sensor(&line_sensor));
ESP_ERROR_CHECK(enable_bar_graph());
#ifdef CONFIG_ENABLE_OLED
// Initialising the OLED
Expand All @@ -124,7 +125,7 @@ void line_follow_task(void* arg)

while(true)
{
line_sensor_readings = read_line_sensor();
line_sensor_readings = read_line_sensor(line_sensor);
for(int i = 0; i < 5; i++)
{
line_sensor_readings.adc_reading[i] = bound(line_sensor_readings.adc_reading[i], WHITE_MARGIN, BLACK_MARGIN);
Expand Down
2 changes: 1 addition & 1 deletion components/sra-board-component

0 comments on commit 69f4cd5

Please sign in to comment.