Fixed improper _

This commit is contained in:
Kevin Thomas
2026-04-11 10:52:10 -04:00
parent f6683beff5
commit 0df58712e1
70 changed files with 603 additions and 603 deletions
+2 -2
View File
@@ -53,7 +53,7 @@
* on failure prints a wiring-check message. Waits 2 s before returning
* to respect the DHT11 minimum polling interval.
*/
static void _print_reading(void) {
static void print_reading(void) {
float humidity = 0.0f;
float temperature = 0.0f;
if (dht11_read(&humidity, &temperature))
@@ -68,5 +68,5 @@ int main(void) {
dht11_init(DHT11_GPIO);
printf("DHT11 driver initialized on GPIO %d\r\n", DHT11_GPIO);
while (true)
_print_reading();
print_reading();
}
+14 -14
View File
@@ -40,7 +40,7 @@ static uint dht_pin;
* Drives the pin LOW for 18 ms then HIGH for 40 us before switching
* the pin to input mode to listen for the sensor response.
*/
static void _send_start_signal(void) {
static void send_start_signal(void) {
gpio_set_dir(dht_pin, GPIO_OUT);
gpio_put(dht_pin, 0);
sleep_ms(18);
@@ -58,7 +58,7 @@ static void _send_start_signal(void) {
* @param level Logic level to wait through (0 or 1)
* @return bool true once the level changed, false on timeout
*/
static bool _wait_for_level(int level) {
static bool wait_for_level(int level) {
uint32_t timeout = 10000;
while (gpio_get(dht_pin) == level)
if (--timeout == 0) return false;
@@ -73,10 +73,10 @@ static bool _wait_for_level(int level) {
*
* @return bool true if the full response was received, false on timeout
*/
static bool _wait_response(void) {
if (!_wait_for_level(1)) return false;
if (!_wait_for_level(0)) return false;
if (!_wait_for_level(1)) return false;
static bool wait_response(void) {
if (!wait_for_level(1)) return false;
if (!wait_for_level(0)) return false;
if (!wait_for_level(1)) return false;
return true;
}
@@ -90,10 +90,10 @@ static bool _wait_response(void) {
* @param i Bit index (0-39)
* @return bool true on success, false on timeout
*/
static bool _read_bit(uint8_t *data, int i) {
if (!_wait_for_level(0)) return false;
static bool read_bit(uint8_t *data, int i) {
if (!wait_for_level(0)) return false;
uint32_t start = time_us_32();
if (!_wait_for_level(1)) return false;
if (!wait_for_level(1)) return false;
uint32_t duration = time_us_32() - start;
data[i / 8] <<= 1;
if (duration > 40) data[i / 8] |= 1;
@@ -108,7 +108,7 @@ static bool _read_bit(uint8_t *data, int i) {
*/
static bool _read_40_bits(uint8_t *data) {
for (int i = 0; i < 40; i++)
if (!_read_bit(data, i)) return false;
if (!read_bit(data, i)) return false;
return true;
}
@@ -118,7 +118,7 @@ static bool _read_40_bits(uint8_t *data) {
* @param data 5-byte received data (bytes 0-3 plus checksum in byte 4)
* @return bool true if the checksum matches, false otherwise
*/
static bool _validate_checksum(const uint8_t *data) {
static bool validate_checksum(const uint8_t *data) {
return data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF);
}
@@ -130,10 +130,10 @@ void dht11_init(uint8_t pin) {
bool dht11_read(float *humidity, float *temperature) {
uint8_t data[5] = {0};
_send_start_signal();
if (!_wait_response()) return false;
send_start_signal();
if (!wait_response()) return false;
if (!_read_40_bits(data)) return false;
if (!_validate_checksum(data)) return false;
if (!validate_checksum(data)) return false;
*humidity = data[0] + data[1] * 0.1f;
*temperature = data[2] + data[3] * 0.1f;
return true;