#include "bike_store.h"
#include <stdint.h>

#define BIKE_STORE_MAX_NUMBER_MEASUREMENTS (32)

static uint16_t bikeStoreGetMaximumBikeStoreSize() {
    return BIKE_STORE_MAX_NUMBER_MEASUREMENTS;
}

static bikeStoreMeasurement bikeStoreArray[BIKE_STORE_MAX_NUMBER_MEASUREMENTS] = {{ 0, },};

static uint16_t bikeStoreNumberOfMeasurementsPresent = 0;

void bikeStoreAddMeasurement(bikeStoreMeasurement value)
{
    if (bikeStoreNumberOfMeasurementsPresent >= bikeStoreGetMaximumBikeStoreSize()) {
        bikeStoreNumberOfMeasurementsPresent = 0;
    }
    bikeStoreArray[bikeStoreNumberOfMeasurementsPresent] = value;
    bikeStoreNumberOfMeasurementsPresent++;
}

uint16_t bikeStoreGetNumberOfMeasurementsPresent() {
    return bikeStoreNumberOfMeasurementsPresent;
}

bikeStoreMeasurement bikeStoreGetMeasurement(uint16_t indexPosition) {
    bikeStoreMeasurement value = bikeStoreArray[indexPosition];

    return value;
}
