use smallest possible var size

pull/154/head
Joseph Poirier 2015-12-20 16:16:52 -06:00
rodzic 373c0fa956
commit 227f4f5571
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -149,12 +149,12 @@ func makeTrafficReport(ti TrafficInfo) {
//
// Algo example at: https://play.golang.org/p/AQ0fpDudvi
//
var alt int32
var alt int16
if ti.Alt < -1000 || ti.Alt > 101350 {
alt = 0xFFF
alt = 0x0FFF
} else {
// output guaranteed to be between 0x000 and 0xFFE
alt = int32((ti.Alt / 25) + 40)
// output guaranteed to be between 0x0000 and 0x0FFE
alt = int16((ti.Alt / 25) + 40)
}
msg[11] = byte((alt & 0xFF0) >> 4) // Altitude.
msg[12] = byte((alt & 0x00F) << 4)