Changeset - f2aec7c1f1bb
[Not reviewed]
default
0 1 0
Ethan Zonca - 8 years ago 2017-10-10 15:52:14
ezonca@sealandaire.com
Encode fix
1 file changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/wspr.c
Show inline comments
 
@@ -141,35 +141,36 @@ void wspr_transmit(uint8_t* grid_locator
 

	
 
        // Encode value from 0-39 with some scalar/offset/etc
 
        uint32_t batt_enc = adc_get_vbatt();  // Hopefully in decivolts
 
        if(batt_enc > 39)
 
            batt_enc = 39;
 

	
 
        // Encode speed in knots from 0-82 to 0-41
 
        uint32_t speed_enc = gps_getdata()->speed / 2;
 
        if(speed_enc > 41)
 
            speed_enc = 41;
 

	
 
        // Encode GPS status
 
        uint32_t gps_status = 0b00; // MSB is valid fix, lsb is sats > 8
 
        uint32_t gps_status = 0b0 // valid fix
 
        uint32_t gps_sats = 0b0   // lats > 8
 

	
 

	
 
        // We always have a fix if we got to this point; and I think we zero out that we had a fix when turning the GPS off before entering this function
 
//        if(gps_getdata()->fixtype == 2 || gps_getdata()->fixtype == 3)
 
            gps_status |= 0b10;
 
            gps_status = 0b1;
 

	
 
        if(gps_getdata()->sats_in_solution > 5)
 
            gps_status |= 0b01;
 
            gps_sats = 0b1;
 

	
 
        uint32_t engdata = gps_status + 2 * (speed_enc + 42 * (batt_enc + 40 * temp_enc));
 
        uint32_t engdata = gps_sats + 2 * (gps_status + 2 * (speed_enc + 42 * (batt_enc + 40 * temp_enc)));
 

	
 
        ////////////////////////////////////////////
 
        // Encode temp/batt/speed/gps
 
        ////////////////////////////////////////////
 

	
 
        // Mask off fields
 
        chunk = engdata / 18 / 10 / 10 / 19;  
 

	
 
        // Encode to grid locator
 
        loc[0] = 'A' + chunk;
 

	
 
        // Subtract off previous portion 
0 comments (0 inline, 0 general)