From 87db9dbe16841225a558444cbffb0468fa8acf57 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Mon, 5 Dec 2016 20:01:29 -0500 Subject: Update: Found out one of the things was reversed. --- src/survive_data.c | 71 +++++++++++++++++++++++++++++++++++++++------ src/survive_process.c | 2 +- tools/avr_codegen/test.c | 44 ++++++++++++++++++++++++---- tools/avr_codegen/test.elf | Bin 6832 -> 7140 bytes tools/avr_codegen/test.hex | 14 +++++---- 5 files changed, 111 insertions(+), 20 deletions(-) diff --git a/src/survive_data.c b/src/survive_data.c index 026bbb6..bb8836d 100644 --- a/src/survive_data.c +++ b/src/survive_data.c @@ -245,8 +245,6 @@ static void handle_watchman( struct SurviveObject * w, uint8_t * readdata ) } printf("\n"); #endif - - //XXX XXX XXX This code is awful. Rejigger to make go fast. uint8_t * end = &readdata[qty-4]; uint8_t * start = readdata; @@ -304,9 +302,39 @@ static void handle_watchman( struct SurviveObject * w, uint8_t * readdata ) // 90 later, 50 off // 7 later, 60 off. - //TODO: Try to undertand multiple code. - //TODO: Make sure order of on/off is correct. - //TODO: Get some sleepeeepepepeppeepeppeepppepepepepepeppp + //Notes: All LEDs are divisble by 8. + //That leaves us 3 bits earlier in the message. + // + // + + //Assumptions: Bit 0 1 +//XXX DISCARD BETWEEN HERE + //More details. Example: + // 40 only / 40 and 48 / 48 only + // 49/( 139/ 102)41/( 130/ -1) + // 48 only / 48 and 40 / 40 only + // 41/( 129/ 102)49/( 132/ -1) + // + // 00 then 08+00 then 08 only + // 09/( 133/ 100)01/( 135/ -1) + // 08 then 08+00 then 00 only + // 01/( 133/ 102)09/( 133/ -1) + // + // 10 then 10+00+08 then 00+08 + // 0a/( 107/ 20)73/( 93/ 17)11/( 132/ -1) + // 08+00 then 10+08+00 then 10 + // 6a/( 34/ 35)12/( 86/ 125)0a/( 20/ -1) + // + // 08 then 10+08 then 10 + // 11/( 136/ 97)09/( 136/ -1) + + // 08 then nothing then 10 + // 10/( 104/ 161)08/( 102/ -1) + // 10/( 105/ 425)08/( 102/ -1) (LONGER DELAY BETWEEN) + // 10/( 369/ 423)08/( 102/ -1) (LONGER FIRST PULSE) + // 40 -> 48 -> 50 50/( 523/ 2260)48/( 520/ 2260)40/( 873/ -1) +//AND HERE!!! XXX DISCARD + //I think the format is: @@ -316,7 +344,7 @@ static void handle_watchman( struct SurviveObject * w, uint8_t * readdata ) // mask = Led mask switching static int olddel = 0; - int lightmask = lights[lightno-1]; + int lightmask = lights[0]; // // @@ -333,10 +361,37 @@ static void handle_watchman( struct SurviveObject * w, uint8_t * readdata ) printf( "%02x/(%5d/%5d)", lightmask, deltaA, deltaB ); if( lightno-i-2 >= 0 ) - lightmask = lights[lightno-i-2]; + lightmask = lights[i+1]; } printf( "\n"); + //Three distinct motions. + // 40 nothing (long wait) 48 nothing 50 nothing (long pulse) + // 40/( 524/ 2262)48/( 522/ 570)50/( 874/ -1) + // 40, 40+48, 48 only. + // 41/( 529/ 517)49/( 875/ -1) + // 48, 48+40, 40 only + // 49/( 525/ 518)41/( 877/ -1) + // 48 then 48+40 then 48 only //XXX SERIOUSLY???? + // 40/( 526/ 524)4a/( 869/ -1) + // 48 then 48+50 then 50 only. + // 49/( 528/ 518)51/( 881/ -1) + // 50 then 48+50 then 48 only. + // 51/( 528/ 520)49/( 523/ -1) + // 48 then 48+50 then 50 only. + // 49/( 527/ 518)51/( 532/ -1) + // 48 then 48+50 then 48 only //INCORRECT BELOW HERE XXX DO NOT TRUST!!! + // 50/( 527/ 524)4a/( 515/ -1) //No, really... wat? + // 50 then 48+50 then 50 only + // 48/( 529/ 521)52/( 524/ -1) // oh come on! + // 50 then 48+50 then 50 only then 50+40 then 50 only. + // 40/( 5364/ 2292)50/( 5363/283869)48/( 526/ 521)52/( 522/ -1) + + + + + + /* for( i = 0; i < lightno; i++ ) { @@ -469,8 +524,6 @@ void survive_data_cb( struct SurviveUSBInterface * si ) } //DONE OK. - - //printf("\n" ); break; } case USB_IF_WATCHMAN1: diff --git a/src/survive_process.c b/src/survive_process.c index 2c87aa6..a4680af 100644 --- a/src/survive_process.c +++ b/src/survive_process.c @@ -13,6 +13,6 @@ void survive_imu_process( struct SurviveObject * so, int16_t * accelgyro, uint32 { if( so->codename[0] != 'H' ) { -// printf( "I %s %d %d %d %d %d %d %d %d\n", so->codename, timecode, accelgyro[0], accelgyro[1], accelgyro[2], accelgyro[3], accelgyro[4], accelgyro[5], id ); + //printf( "I %s %d %d %d %d %d %d %d %d\n", so->codename, timecode, accelgyro[0], accelgyro[1], accelgyro[2], accelgyro[3], accelgyro[4], accelgyro[5], id ); } } diff --git a/tools/avr_codegen/test.c b/tools/avr_codegen/test.c index ad01747..95b0155 100644 --- a/tools/avr_codegen/test.c +++ b/tools/avr_codegen/test.c @@ -19,7 +19,7 @@ static void setup_clock( void ) CLKPR = 0x80; /*Setup CLKPCE to be receptive*/ CLKPR = 0x00; /*No scalar*/ - OSCCAL = 0x60; //B8 is bottom E8 is top. + OSCCAL = 0x30; //B8 is bottom E8 is top. //This is gonna be about 1.8 MHz, turns out that's probably better than the 2MHz suggestion from the lighthouse-redox people. } @@ -28,7 +28,7 @@ int main( ) { cli(); setup_clock(); - DDRB = _BV(4); + DDRB = _BV(4) | _BV(3) | _BV(1); uint8_t marker; while(1) @@ -50,19 +50,53 @@ int main( ) // 14 = 0x95 0x01 // 15 = 0xa1 0x01 //0x10 = 0xab 0x01 - marker = 10; + marker = 30; do{ - PORTB = _BV(4); + PORTB = _BV(3); //4 = 0x40 3 = 0x48 1 = 0x50 + marker--; + PORTB = 0; + } while( marker ); + marker = 30; + do{ + PORTB = _BV(3)|_BV(1); //4 = 0x40 3 = 0x48 1 = 0x50 + marker--; + PORTB = 0; + } while( marker ); + marker = 30; + do{ + PORTB = _BV(3); //4 = 0x40 3 = 0x48 1 = 0x50 + marker--; + PORTB = 0; + } while( marker ); + do{ + PORTB = _BV(3)|_BV(4); //4 = 0x40 3 = 0x48 1 = 0x50 + marker--; + PORTB = 0; + } while( marker ); + do{ + PORTB = _BV(3); //4 = 0x40 3 = 0x48 1 = 0x50 marker--; PORTB = 0; } while( marker ); _delay_us(80); + +/* + marker = 30; + do{ + PORTB = _BV(0); + marker--; + PORTB = 0; + } while( marker ); +// _delay_us(80); marker = 10; do{ - PORTB = _BV(4); + PORTB = _BV(3); marker--; PORTB = 0; } while( marker ); + +*/ + /* _delay_us(16); marker = 20; do{ diff --git a/tools/avr_codegen/test.elf b/tools/avr_codegen/test.elf index 458f910..c9716a7 100755 Binary files a/tools/avr_codegen/test.elf and b/tools/avr_codegen/test.elf differ diff --git a/tools/avr_codegen/test.hex b/tools/avr_codegen/test.hex index 7c9a4cb..fbe1725 100644 --- a/tools/avr_codegen/test.hex +++ b/tools/avr_codegen/test.hex @@ -1,11 +1,15 @@ :100000000EC015C014C013C012C011C010C00FC064 :100010000EC00DC00CC00BC00AC009C008C011241E -:100020001FBECFE5D2E0DEBFCDBF1AD037C0E8CFCC +:100020001FBECFE5D2E0DEBFCDBF1AD050C0E8CFB3 :100030000F931F9300E010E0980106171707280799 :10004000390759F0EFECF7E03197F1F700C0000005 :100050000F5F1F4F2F4F3F4FF0CF1F910F9108950C -:10006000F89480E886BD16BC80E681BF80E187BB3E -:1000700090E18AE098BB18BA8150E1F785ED8A9546 -:10008000F1F700008AE098BB18BA8150E1F7EFE180 -:10009000FEE43197F1F700C00000EBCFF894FFCFFA +:10006000F89480E886BD16BC80E381BF8AE187BB37 +:1000700098E02AE038E18EE198BB18BA8150E1F7A8 +:100080008EE128BB18BA8150E1F78EE198BB18BA0F +:100090008150E1F745ED4A95F1F7000038BB8150FA +:1000A00018BA8111FBCFE5EDEA95F1F7000098BB96 +:1000B000815018BA8111FBCFF5EDFA95F1F70000E8 +:1000C000EFE1FEE43197F1F700C00000D4CFF894DF +:0200D000FFCF60 :00000001FF -- cgit v1.2.3