clean
This commit is contained in:
parent
b27676fb9f
commit
91b4bd81e7
@ -4,7 +4,10 @@ prepare:
|
||||
./flashing_time.py
|
||||
|
||||
flash:
|
||||
tinygo flash -target=xiao-ble
|
||||
tinygo flash -target=xiao-ble -size=short
|
||||
|
||||
production:
|
||||
tinygo flash -target=xiao-ble -serial=none -size=short -opt=z -gc=leaking -scheduler=tasks
|
||||
tinygo flash -target=xiao-ble -serial=none -size=short
|
||||
|
||||
testing:
|
||||
tinygo flash -target=xiao-ble -serial=none -size=short -opt=2 -gc=leaking -scheduler=tasks
|
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"machine"
|
||||
"time"
|
||||
|
||||
@ -134,6 +135,7 @@ func main() {
|
||||
arrAcc := valuesToByteArray(x, y, z, int8(2))
|
||||
|
||||
currentTimeStamp = currentTimeStamp.Add(time.Now().Sub(lastTimeStamp))
|
||||
fmt.Println("TIME: ", time.Now().Sub(lastTimeStamp))
|
||||
arrTime := timeStampToByteArray(currentTimeStamp.UnixMilli(), int8(3))
|
||||
|
||||
senseCharacteristic.Write(arrRot)
|
||||
@ -149,35 +151,19 @@ func main() {
|
||||
}
|
||||
|
||||
func valuesToByteArray(x int32, y int32, z int32, p int8) []byte {
|
||||
arr := make([]byte, 13)
|
||||
arr[0] = byte(x)
|
||||
arr[1] = byte(x >> 8)
|
||||
arr[2] = byte(x >> 16)
|
||||
arr[3] = byte(x >> 24)
|
||||
arr[4] = byte(y)
|
||||
arr[5] = byte(y >> 8)
|
||||
arr[6] = byte(y >> 16)
|
||||
arr[7] = byte(y >> 24)
|
||||
arr[8] = byte(z)
|
||||
arr[9] = byte(z >> 8)
|
||||
arr[10] = byte(z >> 16)
|
||||
arr[11] = byte(z >> 24)
|
||||
arr[12] = byte(p)
|
||||
return arr
|
||||
byteSlice := make([]byte, 13)
|
||||
binary.LittleEndian.PutUint32(byteSlice, uint32(x))
|
||||
binary.LittleEndian.PutUint32(byteSlice[4:], uint32(y))
|
||||
binary.LittleEndian.PutUint32(byteSlice[8:], uint32(z))
|
||||
byteSlice[12] = byte(p)
|
||||
return byteSlice
|
||||
}
|
||||
|
||||
func timeStampToByteArray(value int64, p int8) []byte {
|
||||
arr := make([]byte, 9)
|
||||
arr[0] = byte(value)
|
||||
arr[1] = byte(value >> 8)
|
||||
arr[2] = byte(value >> 16)
|
||||
arr[3] = byte(value >> 24)
|
||||
arr[4] = byte(value >> 32)
|
||||
arr[5] = byte(value >> 40)
|
||||
arr[6] = byte(value >> 48)
|
||||
arr[7] = byte(value >> 56)
|
||||
arr[8] = byte(p)
|
||||
return arr
|
||||
byteSlice := make([]byte, 9)
|
||||
binary.LittleEndian.PutUint64(byteSlice, uint64(value))
|
||||
byteSlice[8] = byte(p)
|
||||
return byteSlice
|
||||
}
|
||||
|
||||
func must(action string, err error) {
|
||||
|
@ -1,106 +0,0 @@
|
||||
package main
|
||||
|
||||
// import (
|
||||
// "encoding/binary"
|
||||
// "fmt"
|
||||
// "unsafe"
|
||||
// )
|
||||
|
||||
// func main() {
|
||||
// const x int32 = 2017403647
|
||||
// const y int32 = 1010101010
|
||||
// const z int32 = 2020202020
|
||||
|
||||
// // bytearr := valuesToByteArrayTest(x, y, z, 1)
|
||||
// // fmt.Println("TEST: ", bytearr)
|
||||
|
||||
// // slice := binary.LittleEndian.Uint32(bytearr[0:4])
|
||||
// // fmt.Println("SLICE:", slice)
|
||||
|
||||
// // slice2 := binary.LittleEndian.Uint32(bytearr[4:8])
|
||||
// // fmt.Println("SLICE2:", slice2)
|
||||
|
||||
// bs := make([]byte, 4)
|
||||
// binary.LittleEndian.PutUint32(bs, uint32(y))
|
||||
// fmt.Println(bs)
|
||||
|
||||
// // buf := make([]byte, 4)
|
||||
// // arr[0] = byte(x >> 8)
|
||||
|
||||
// // buf[0], buf[1], buf[2] = uint8(7676767>>16), uint8(id>>8), uint8(id)
|
||||
|
||||
// bytearr := valuesToByteArray3(x, y, z, 1)
|
||||
// fmt.Println("TEST: ", bytearr)
|
||||
|
||||
// slice := binary.LittleEndian.Uint32(bytearr[0:4])
|
||||
// fmt.Println("SLICE:", slice)
|
||||
|
||||
// slice2 := binary.LittleEndian.Uint32(bytearr[4:8])
|
||||
// fmt.Println("SLICE2:", slice2)
|
||||
|
||||
// }
|
||||
|
||||
// func valuesToByteArrayOld(x int32, y int32, z int32, p int8) []byte {
|
||||
// arr := make([]byte, 13)
|
||||
// for i := 0; i < 12; i++ {
|
||||
// var test unsafe.Pointer
|
||||
// var test2 unsafe.Pointer
|
||||
// var test3 unsafe.Pointer
|
||||
// if i < 4 {
|
||||
// test = unsafe.Pointer(&x)
|
||||
// } else if i < 8 {
|
||||
// test2 = unsafe.Pointer(&y)
|
||||
// } else if i < 12 {
|
||||
// test3 = unsafe.Pointer(&z)
|
||||
// }
|
||||
// byt := *(*uint8)(unsafe.Pointer(uintptr(test) + uintptr(i)))
|
||||
// arr[i] = byt
|
||||
// }
|
||||
// arr[12] = byte(p)
|
||||
// return arr
|
||||
// }
|
||||
|
||||
// func valuesToByteArray1(x int32, y int32, z int32, p int8) []byte {
|
||||
// arr := make([]byte, 13)
|
||||
// arr[0] = byte(x)
|
||||
// arr[1] = byte(x >> 8)
|
||||
// arr[2] = byte(x >> 16)
|
||||
// arr[3] = byte(x >> 24)
|
||||
// arr[4] = byte(y)
|
||||
// arr[5] = byte(y >> 8)
|
||||
// arr[6] = byte(y >> 16)
|
||||
// arr[7] = byte(y >> 24)
|
||||
// arr[8] = byte(z)
|
||||
// arr[9] = byte(z >> 8)
|
||||
// arr[10] = byte(z >> 16)
|
||||
// arr[11] = byte(z >> 24)
|
||||
// arr[12] = byte(p)
|
||||
// return arr
|
||||
// }
|
||||
|
||||
// func valuesToByteArray2(x int32, y int32, z int32, p int8) []byte {
|
||||
// buf := make([]byte, 13)
|
||||
// binary.LittleEndian.PutUint32(buf[0:], uint32(x))
|
||||
// binary.LittleEndian.PutUint32(buf[4:], uint32(y))
|
||||
// binary.LittleEndian.PutUint32(buf[8:], uint32(z))
|
||||
// buf[12] = byte(p)
|
||||
// return buf
|
||||
// }
|
||||
|
||||
// func valuesToByteArray3(x int32, y int32, z int32, p int8) []byte {
|
||||
// arr := make([]byte, 13)
|
||||
// for i := 0; i < 12; i++ {
|
||||
// var test unsafe.Pointer
|
||||
// if i < 4 {
|
||||
// test = unsafe.Pointer(&x)
|
||||
// } else if i < 8 {
|
||||
// test = unsafe.Pointer(&y)
|
||||
// } else if i < 12 {
|
||||
// test = unsafe.Pointer(&z)
|
||||
// }
|
||||
// byt := *(*uint8)(unsafe.Pointer(uintptr(test) + uintptr(i)))
|
||||
// arr[i] = byt
|
||||
// }
|
||||
// arr[12] = byte(p)
|
||||
// return arr
|
||||
// }
|
Loading…
x
Reference in New Issue
Block a user