Open ghost opened 7 years ago
And here hx711.c:
HX711 HX711_Tare(HX711 data, uint8_t times) { int sum = HX711_AverageValue(data, times); data.offset = sum; return data; }
Hi there! I would like to know if you have any example about the implementation of this lib, since it was made for a experience programmer it is not possible for me to use these files. Thank you!
I would like to know if you have any example about the implementation of this lib, since it was made for a experience programmer it is not possible for me to use these files.
That's probably for the best. Since the library is totally buggy and incomplete. And the creator didn't care to fix those bugs in 4 years.
you have some errors in your library. I resolve them.
//====== //hx711.h //======
ifndef HX711H
define HX711H
include "stm32f3xx_hal.h"
typedef struct _hx711 { GPIO_TypeDef gpioSck; GPIO_TypeDef gpioData; uint16_t pinSck; uint16_t pinData; int offset; int gain; // 1: channel A, gain factor 128 // 2: channel B, gain factor 32 // 3: channel A, gain factor 64 } HX711;
void HX711_Init(HX711 data); HX711 HX711_Tare(HX711 data, uint8_t times); int HX711_Value(HX711 data); int HX711_AverageValue(HX711 data, uint8_t times);
endif / HX711H /
//====== //hx711.c //======
include "hx711.h"
void HX711_Init(HX711 data) { GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = data.pinSck; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(data.gpioSck, &GPIO_InitStruct);
}
int HX711_AverageValue(HX711 data, uint8_t times) { int sum = 0; for (int i = 0; i < times; i++) { sum += HX711_Value(data); }
}
int HX711_Value(HX711 data) { int buffer; buffer = 0;
}
HX711 HX711_Tare(HX711 data, uint8_t times) { int sum = HX711_Average_Value(data, times); data.offset = sum; return data; }