<commit_before>package dht

// #include "dht.go.h"
// #cgo LDFLAGS: -lrt
import "C"

import (
	"fmt"
	"log"
	"reflect"
	"time"
	"unsafe"
)

type SensorType int

const (
	DHT11 SensorType = iota + 1
	DHT22
)

type Pulse struct {
	Value    bool
	Duration time.Duration
}

func dialDHTxxAndGetResponse(pin int) (error, []Pulse) {
	var arr *C.int32_t
	var arrLen C.int32_t
	var l []int32
	// return array: [pulse, duration, pulse, duration, ...]
	r := C.dial_DHTxx_and_read(4, &arr, &arrLen)
	if r == -1 {
		return fmt.Errorf("Error found in call to C.dial_DHTxx_and_read(...)"), nil
	}
	defer C.free(unsafe.Pointer(arr))
	h := (*reflect.SliceHeader)(unsafe.Pointer(&l))
	h.Data = uintptr(unsafe.Pointer(arr))
	h.Len = int(arrLen)
	h.Cap = int(arrLen)
	pulses := make([]Pulse, len(l)/2)
	// convert original int array ([pulse, duration, pulse, duration, ...])
	// to Pulse struct array
	for i := 0; i < len(l)/2; i++ {
		pulses[i] = Pulse{Value: l[i*2] != 0,
			Duration: time.Duration(l[i*2+1]) * time.Microsecond}
	}
	return nil, pulses
}

func decodeByte(pulses []Pulse, start int) (error, int) {
	if len(pulses)-start < 16 {
		return fmt.Errorf("Can't decode byte, since range between "+
			"index and array length is less than 16: %d, %d", start, len(pulses)), 0
	}
	var b int = 0
	for i := 0; i < 8; i++ {
		pulseL := pulses[start+i*2]<commit_msg>Add new images<commit_after>package dht

// #include "dht.go.h"
// #cgo LDFLAGS: -lrt
import "C"

import (
	"fmt"
	"log"
	"reflect"
	"time"
	"unsafe"
)

type SensorType int

const (
	DHT11 SensorType = iota + 1
	DHT22
)

type Pulse struct {
	Value    bool
	Duration time.Duration
}

func dialDHTxxAndGetResponse(pin int) (error, []Pulse) {
	var arr *C.int32_t
	var arrLen C.int32_t
	var l []int32
	// return array: [pulse, duration, pulse, duration, ...]
	r := C.dial_DHTxx_and_read(4, &arr, &arrLen)
	if r == -1 {
		return fmt.Errorf("Error found in call to C.dial_DHTxx_and_read(...)"), nil
	}
	defer C.free(unsafe.Pointer(arr))
	h := (*reflect.SliceHeader)(unsafe.Pointer(&l))
	h.Data = uintptr(unsafe.Pointer(arr))
	h.Len = int(arrLen)
	h.Cap = int(arrLen)
	pulses := make([]Pulse, len(l)/2)
	// convert original int array ([pulse, duration, pulse, duration, ...])
	// to Pulse struct array
	for i := 0; i < len(l)/2; i++ {
		pulses[i] = Pulse{Value: l[i*2] != 0,
			Duration: time.Duration(l[i*2+1]) * time.Microsecond}
	}
	time.
	return nil, pulses
}

func decodeByte(pulses []Pulse, start int) (error, int) {
	if len(pulses)-start < 16 {
		return fmt.Errorf("Can't decode byte, since range between "+
			"index and array length is less than 16: %d, %d", start, len(pulses)), 0
	}
	var b int = 0
	for i := 0; i < 8; i++ {
		pulseL := pulses[start+i*2]
{'fraction_non_alphanumeric': 0.1703621581670362, 'fraction_numerical': 0.021433850702143386, 'mean_word_length': 3.63527397260274, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3648849', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1097, 'n_words': 300}