//
// Created by nano on 4/26/25.
//

#include "utils.h"

#include <stdio.h>

#include "communication.h"

// Helper functions to convert from bits to bytes
void byte_to_bit_array(byte bit_array[], byte data) {
	for (int i = 0; i < 8; i++) {
		bit_array[i] = (data >> i) & 1; //shift through all bits and check if they're 1
	}
}


void bit_array_to_byte(byte bit_array[], byte *data) {
	*data=0;
	u_int8_t currentpow=1;

	for (int i = 0; i < 8; i++) {
		data+=bit_array[i]*currentpow;
		currentpow*=2;
	} //2's complement notation
}

