void number(uint8_t n) { // Beep out the current warning time while (n >= 10) { dah(); n -= 10; } if (n > 0) { dit(); } }
static void send_morse_char(const Q_ROM struct MorseChar *mc) { uint8_t nsymbols = Q_ROM_BYTE(mc->nsymbols); uint8_t symbols = Q_ROM_BYTE(mc->symbols); while (nsymbols) { if (symbols & 0b10000000) dah(); else dit(); BSP_delay_ms( DIT_LENGTH ); symbols <<= 1; nsymbols--; } }
void Telegraph::output_code(const char* code) { const unsigned int code_length = strlen(code); for (unsigned int i = 0; i < code_length; i++) { if (code[i] == '.') { dit(); } else { dah(); } if (i != code_length - 1) { delay(_dit_length); } } }
void loop() { dah(); dit(); dah(); dah(); pause(); dah(); dit(); dah(); dah(); pause(); dah(); dah(); dit(); dit(); pause(); pause(); }
void w() { dit(); dah(); dah(); space(); }
void o() { dah(); dah(); dah(); space(); }
void k() { dah(); dit(); dah(); space(); }
int main() { cli(); disableWatchdog(); slowClock(); initBuzzer(); initSwitch(); initADC(); #ifdef DEBUG uint16_t v = getVoltage(); uint16_t i; for (i = 0x8000; i != 0; i >>= 1) { if (v & i) { dit(); } else { dah(); } _delay_ms(1000); } #endif // Retrieve the current warning timeout from eeprom uint8_t warn_min = eeprom_read_byte(&cfg_warn_min); if (switchPressed()) { number(warn_min); // pause between increments _delay_ms(3000); } // If switch is depressed (at power up), begin increasing // warning time, in 5-minute increments, max 30 minutes // SOS time is 2 x warning time. // while (switchPressed()) { if (switchPressed()) { // Increment warning time by 5 minutes warn_min += 5; // Maximum warning time is 30 minutes if (warn_min > 30) warn_min = 5; // Save the new warning time eeprom_update_byte(&cfg_warn_min, warn_min); } number(warn_min); // pause between increments _delay_ms(3000); } // Compute the number of seconds for warning and SOS warn_sec = warn_min * 60; sos_sec = warn_sec * 2; if (checkVoltage()) { ok(); } else { sos(); } enableWatchdog(); sei(); while (1) { set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_mode(); } }