+ while(1)
+ {
+ ADCSRA |= (1 << ADSC); // start ADC measurement
+ while (ADCSRA & (1 << ADSC) ); // wait till conversion complete
+ {
+ // We are detecting "video" if we have a value
+ // greater than some minimal value on ADC1/PB2.
+ // This approach requires a weak pulldown on the relevant
+ // video input to the circuit, but it beats not detecting anything.
+ if (ADCH > 10)
+ {
+ // Dummy code.
+ // This needs to be replaced with something that triggers a timer ...
+ /// Simply indicate on PB4 that we are seeing somethin.
+ PORTB |= 0x10;
+ // The next statement stops sync-generation, thus also image-generation..
+ TIMSK &= ~(1<<OCIE0A); // Enable compare-mach-a interrupt
+ }
+ else
+ {
+ // Dummy code. Simply indicate on PB4 that we are below the threshold.
+ PORTB &= 0xEF;
+
+ // Make sure sync-gen is running...
+ TIMSK |= (1<<OCIE0A); // Enable compare-mach-a interrupt
+ }
+ }
+ };