Loading src/app/wetterstation/main.cc +45 −5 Original line number Diff line number Diff line Loading @@ -8,9 +8,14 @@ volatile uint16_t anemometer_count = 0; void loop(void) { static uint8_t loop_count = 0; static uint8_t wind_count = 0; static uint8_t dew_count = 0; static uint16_t anemometer_copy; if (++loop_count == 10) { wind_count++; dew_count++; if (wind_count == 10) { cli(); anemometer_copy = anemometer_count; Loading @@ -18,7 +23,39 @@ void loop(void) sei(); kout << "Anemometer Count = " << anemometer_copy << endl; loop_count = 0; wind_count = 0; } if (dew_count == 59) { gpio.output(GPIO::pc5, 0); gpio.output(GPIO::pc4, 1); } else if (dew_count == 60) { // Measure ADC6 with AVCC reference ADMUX = _BV(REFS0) | 6; // Enable ADC with /64 prescaler ADCSRA = _BV(ADEN) | _BV(ADPS2); // Start conversion ADCSRA |= _BV(ADSC); // wait until conversion is complete while (ADCSRA & _BV(ADSC)) ; uint8_t adcr_l = ADCL; uint8_t adcr_h = ADCH; uint16_t dew_raw = adcr_l + (adcr_h << 8); dew_raw = 1024 - dew_raw; // Disable ADC ADCSRA &= ~_BV(ADEN); kout << "Dew Raw = " << dew_raw << endl; dew_count = 0; gpio.input(GPIO::pc5, 0); gpio.input(GPIO::pc4, 0); } } Loading @@ -28,8 +65,11 @@ int main(void) gpio.setup(); kout.setup(); gpio.output(GPIO::pd2, 0); gpio.input(GPIO::pd3, 1); gpio.output(GPIO::pd2, 0); // Anemometer Reed Contact gpio.input(GPIO::pd3, 1); // Anemometer Reed Contact gpio.input(GPIO::pc5, 0); // Dew Sensor GND gpio.input(GPIO::pc4, 0); // Dew Sensor VCC EICRA = _BV(ISC11); EIMSK = _BV(INT1); Loading Loading
src/app/wetterstation/main.cc +45 −5 Original line number Diff line number Diff line Loading @@ -8,9 +8,14 @@ volatile uint16_t anemometer_count = 0; void loop(void) { static uint8_t loop_count = 0; static uint8_t wind_count = 0; static uint8_t dew_count = 0; static uint16_t anemometer_copy; if (++loop_count == 10) { wind_count++; dew_count++; if (wind_count == 10) { cli(); anemometer_copy = anemometer_count; Loading @@ -18,7 +23,39 @@ void loop(void) sei(); kout << "Anemometer Count = " << anemometer_copy << endl; loop_count = 0; wind_count = 0; } if (dew_count == 59) { gpio.output(GPIO::pc5, 0); gpio.output(GPIO::pc4, 1); } else if (dew_count == 60) { // Measure ADC6 with AVCC reference ADMUX = _BV(REFS0) | 6; // Enable ADC with /64 prescaler ADCSRA = _BV(ADEN) | _BV(ADPS2); // Start conversion ADCSRA |= _BV(ADSC); // wait until conversion is complete while (ADCSRA & _BV(ADSC)) ; uint8_t adcr_l = ADCL; uint8_t adcr_h = ADCH; uint16_t dew_raw = adcr_l + (adcr_h << 8); dew_raw = 1024 - dew_raw; // Disable ADC ADCSRA &= ~_BV(ADEN); kout << "Dew Raw = " << dew_raw << endl; dew_count = 0; gpio.input(GPIO::pc5, 0); gpio.input(GPIO::pc4, 0); } } Loading @@ -28,8 +65,11 @@ int main(void) gpio.setup(); kout.setup(); gpio.output(GPIO::pd2, 0); gpio.input(GPIO::pd3, 1); gpio.output(GPIO::pd2, 0); // Anemometer Reed Contact gpio.input(GPIO::pd3, 1); // Anemometer Reed Contact gpio.input(GPIO::pc5, 0); // Dew Sensor GND gpio.input(GPIO::pc4, 0); // Dew Sensor VCC EICRA = _BV(ISC11); EIMSK = _BV(INT1); Loading