uint8_t system_baud_set(char *name, float x, float y, int8_t button, float data, uint8_t action) { SDL_Log("BAUD: %s_baud = %s\n", baud_selected, name); if (strcmp(baud_selected, "gcs_gps") == 0) { setup.gcs_gps_baud = atoi(name); gcs_gps_exit(); gcs_gps_init(setup.gcs_gps_port, setup.gcs_gps_baud); } else if (strcmp(baud_selected, "rcflow") == 0) { setup.rcflow_baud = atoi(name); rcflow_exit(); rcflow_init(setup.rcflow_port, setup.rcflow_baud); } else if (strcmp(baud_selected, "jeti") == 0) { setup.jeti_baud = atoi(name); jeti_exit(); jeti_init(setup.jeti_port, setup.jeti_baud); } else if (strcmp(baud_selected, "frsky") == 0) { setup.frsky_baud = atoi(name); frsky_exit(); frsky_init(setup.frsky_port, setup.frsky_baud); } else if (strcmp(baud_selected, "tracker") == 0) { setup.tracker_baud = atoi(name); tracker_exit(); tracker_init(setup.tracker_port, setup.tracker_baud); } return 0; }
int main(void) { CLKPR = (1<<7); CLKPR = 0; /* Disable watchdog timer */ MCUSR = 0; wdt_disable(); /* Start the multi-threading kernel */ init_kernel(STACK_MAIN); /* Timer */ TCCR2B = 0x03; /* Pre-scaler for timer0 */ TCCR2A = 1<<WGM21; /* CTC mode */ TIMSK2 = 1<<OCIE2A; /* Interrupt on compare match */ OCR2A = (SCALED_F_CPU / 32 / 2400) - 1; TRACE_INIT; sei(); t_stackErrorHandler(stackOverflow); fbuf_errorHandler(bufferOverflow); reset_params(); /* HDLC and AFSK setup */ mon_init(&cdc_outstr); adf7021_init(); inframes = hdlc_init_decoder( afsk_init_decoder() ); outframes = hdlc_init_encoder( afsk_init_encoder() ); digipeater_init(); /* Activate digipeater in ui thread */ /* USB */ usb_init(); THREAD_START(usbSerListener, STACK_USBLISTENER); ui_init(); /* GPS and tracking */ gps_init(&cdc_outstr); tracker_init(); TRACE(1); while(1) { lbeep(); if (t_is_idle()) { /* Enter idle mode or sleep mode here */ powerdown_handler(); sleep_mode(); } else t_yield(); } }
static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) { const char* mod = "elua"; const char* name = "sync"; int flags = ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER; Tracker* tracker; RES_SYNC = enif_open_resource_type(env, mod, name, free_res, flags, NULL); if(RES_SYNC == NULL) return -1; atom_ok = enif_make_atom(env, "ok"); atom_elua = enif_make_atom(env, "elua"); atom_error = enif_make_atom(env, "error"); tracker = (Tracker*) enif_alloc(sizeof(Tracker)); if(tracker_init(tracker) < 0 ) { enif_free(tracker); return -1; } *priv = (void*) tracker; return 0; }
int main(int argc, char **argv) { static const char * const profiles[] = { "general", "silent", }; static const char * const keys[] = { #if 0 "ringing.alert.tone", #else "calendar.alarm.enabled", "clock.alarm.enabled", "email.alert.tone", "email.alert.volume", "im.alert.tone", "im.alert.volume", "keypad.sound.level", "ringing.alert.tone", "ringing.alert.type", "ringing.alert.volume", "sms.alert.tone", "sms.alert.volume", "system.sound.level", "touchscreen.sound.level", "vibrating.alert.enabled", #endif }; printf("\n================ %s ================\n", "init"); tracker_init(); printf("\n================ %s ================\n", "profiles"); for( int n = 0; n < 2; ++n ) { for( size_t i = 0; i < numof(profiles); ++i ) { printf("--\nSET '%s'\n", profiles[i]); profile_set_profile(profiles[i]); mysleep(1500); } } printf("\n================ %s ================\n", "values"); for( size_t i = 0; i < 8; ++i ) { const char *p = profiles[i % numof(profiles)]; const char *k = keys[i % numof(keys)]; char v[32]; snprintf(v, sizeof v, "dummy-%Zd.mp3", i); printf("--\nSET %s:%s=%s\n", p,k,v); profile_set_value(p, k, v); mysleep(1500); } printf("\n================ %s ================\n", "reset"); for( size_t p = 0; p < numof(profiles); ++p ) { for( size_t k = 0; k < numof(keys); ++k ) { profile_set_value(profiles[p], keys[k], ""); } } mysleep(2000); printf("\n================ %s ================\n", *profiles); profile_set_profile(*profiles); mysleep(1500); return 0; }
static void init(void) { IRQ_ENABLE; kdbg_init(); timer_init(); /* Initialize serial port, we are going to use it to show APRS messages*/ ser_init(&g_serial, SER_UART0); ser_setbaudrate(&g_serial, SER_DEFAULT_BAUD_RATE); // For some reason BertOS sets the serial // to 7 bit characters by default. We set // it to 8 instead. UCSR0C = _BV(UCSZ01) | _BV(UCSZ00); // see ATMEGA328P datasheet P197, Table 20-11. UCSZn Bits Settings // initialize the reader that wraps the serial serialreader_init(&g_serialreader, &g_serial); // Load settings first settings_load(); /* * Init afsk demodulator. We need to implement the macros defined in hw_afsk.h, which * is the hardware abstraction layer. * We do not need transmission for now, so we set transmission DAC channel to 0. */ afsk_init(&g_afsk, ADC_CH, DAC_CH); /* * Here we initialize AX25 context, the channel (KFile) we are going to read messages * from and the callback that will be called on incoming messages. */ ax25_init(&g_ax25, &g_afsk.fd, ax25_msg_callback); g_ax25.pass_through = false; // Initialize the kiss module // NOTE - use shared memory buffer #if MOD_KISS kiss_init(&g_serialreader,&g_ax25); #endif #if MOD_BEACON // Initialize the beacon module beacon_init(beacon_mode_exit_callback); #endif // Initialize the digi module #if MOD_DIGI digi_init(); #endif #if MOD_RADIO // Initialize the soft serial and radio radio_init(4310400); //TODO read from settings #endif // Initialize GPS NMEA/GPRMC parser #if MOD_TRACKER tracker_init(); #endif #if MOD_CONSOLE ////////////////////////////////////////////////////////////// // Initialize the console & commands console_init(); console_add_command(PSTR("MODE"),cmd_switch_mode); // setup tnc run mode #if MOD_KISS console_add_command(PSTR("KISS"),cmd_enter_kiss_mode); // enable KISS mode #endif #endif }