#include "qt_pi.h"

uint16_t batt_lvl;

void initBatt(){
    
    pinMode(BATT_PIN,INPUT);
    digitalWrite(BATT_PIN,1);
    
    batt_lvl = analogRead(BATT_PIN);

}

void updateBattLevel(){

    for(int i = 0; i < 10; i++)
      batt_lvl += analogRead(BATT_PIN);
    
    batt_lvl /= 10;
}

void getBattLvl(uint8_t *buf){

    updateBattLevel();
    memcpy(buf, &batt_lvl, 2);
    
}
