/*
 * task_joystick.c
 *
 *  Created on: Mar 14, 2025
 *      Author: gca76
 *
 *  Handles readings from the joystick and potentiometer
 */


#include "adc.h"

static uint16_t raw_adc[3];

void joystick_task_execute(void)
{
	HAL_ADC_Start_DMA(&hadc1, (uint32_t*)raw_adc, 3); //  Periodically trigger the ADC conversion process
}

uint16_t get_pot_val(void)  // Returns the potentiometer value
{
	return raw_adc[0];
}

uint16_t get_y_val(void)    // Returns the joystick value in the y axis (up or down)
{
	return raw_adc[1];
}

uint16_t get_x_val(void)    // Returns the joystick value in the x axis (left to right)
{
	return raw_adc[2];
}