int main() { int fd; int wd; #define EV_BUFF 1024 char buffer[EV_BUFF]; fd = inotify_init(); if(fd < 0) xdie("inotify_init failed!"); /* create dir and try to watch it */ umask(0); mkdir(WATCHDIR, S_IRWXU | S_IRWXG); chown(WATCHDIR, AID_SYSTEM, AID_AUDIO); wd = inotify_add_watch(fd, WATCHDIR, IN_CREATE|IN_DELETE); if(wd < 0) xdie("inotify_add_watch failed!"); init_freq(); for(;;) { ALOGI("inotify event\n"); update_freq(); read(fd, buffer, EV_BUFF); } close(fd); return 0; }
void Main_Window::on_sweep_clicked() { QProgressDialog *dlg = new QProgressDialog(this); dlg->setWindowModality(Qt::WindowModal); dlg->setLabelText("Frequency Sweep"); dlg->setCancelButtonText("Cancel"); dlg->setMaximum(100); dlg->show(); double start = ui.sweep_start->value(); double stop = ui.sweep_stop->value(); double step = ui.sweep_step->value(); for (double f = start; f <= stop && !dlg->wasCanceled(); f += step) { dlg->setValue((int)((f - start) * 100.0 / (stop - start))); QCoreApplication::processEvents(); ui.freq->setValue(f); on_idle_clicked(); update_freq(); send_freq(); on_cal_clicked(); on_tx_clicked(); usleep(100 * 1000); } delete dlg; }
int freq_update(void) { freq_lock(); update_freq(); freq_unlock(); return 0; }
void Main_Window::on_send_clicked() { update_freq(); send_freq(); int channel = ui.channel->value(); _dev->control(USB_Device::Control_In | USB_Device::Control_Vendor, 1, channel, 0x0a); }
Main_Window::Main_Window(USB_Device *dev, QWidget *parent): QMainWindow(parent) { _dev = dev; tx = false; ui.setupUi(this); connect(ui.crystal, SIGNAL(valueChanged(double)), SLOT(update_freq())); connect(ui.freq, SIGNAL(valueChanged(double)), SLOT(update_freq())); update_freq(); }
int freq_enter(int cpu, int bus) { int idx; // dbg_printf(d, "%s: enter %d/%d", __func__, cpu, bus); freq_lock(); idx = freq_add(cpu, bus); if (idx < 0) { freq_unlock(); return -1; } update_freq(); freq_unlock(); return idx; }
int freq_leave(int freq_id) { // dbg_printf(d, "%s: leave %d", __func__, freq_id); int idx; freq_lock(); for (idx = 0; idx < freqs_cnt; ++idx) { if (freqs[idx].id == freq_id) { // dbg_printf(d, "%s: removing freqs: %d/%d", __func__, freqs[idx].cpu, freqs[idx].bus); memmove(&freqs[idx], &freqs[idx + 1], sizeof(freqs[0]) * (freqs_cnt - idx - 1)); freqs = safe_realloc(freqs, sizeof(freqs[0]) * (freqs_cnt - 1)); freqs_cnt--; break; } } update_freq(); freq_unlock(); return 0; }
AFSKSetupView::AFSKSetupView( NavigationView& nav ) { using name_t = std::string; using value_t = int32_t; using option_t = std::pair<name_t, value_t>; using options_t = std::vector<option_t>; options_t format_options; uint8_t rpt; size_t i; add_children({ { &text_setfreq, &button_setfreq, &text_bps, &options_bps, &text_mark, &field_mark, &text_space, &field_space, &text_bw, &field_bw, &text_repeat, &field_repeat, &text_format, &options_format, &button_save } }); for (i = 0; i < AFSK_MODES_COUNT; i++) format_options.emplace_back(std::make_pair(afsk_formats[i].fullname, i)); options_format.set_options(format_options); options_format.set_selected_index(portapack::persistent_memory::afsk_format()); update_freq(portapack::persistent_memory::tuned_frequency()); field_mark.set_value(portapack::persistent_memory::afsk_mark_freq() * 25); field_space.set_value(portapack::persistent_memory::afsk_space_freq() * 25); field_bw.set_value(portapack::persistent_memory::afsk_bw()); rpt = portapack::persistent_memory::afsk_repeats(); if ((rpt > 99) || (!rpt)) rpt = 5; field_repeat.set_value(rpt); button_setfreq.on_select = [this,&nav](Button&) { auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::tuned_frequency()); new_view->on_changed = [this](rf::Frequency f) { update_freq(f); }; }; options_bps.set_by_value(portapack::persistent_memory::afsk_bitrate()); button_save.on_select = [this,&nav](Button&) { uint32_t afsk_config = 0; portapack::persistent_memory::set_afsk_bitrate(options_bps.selected_index_value()); portapack::persistent_memory::set_afsk_mark(field_mark.value() / 25); portapack::persistent_memory::set_afsk_space(field_space.value() / 25); portapack::persistent_memory::set_afsk_bw(field_bw.value()); afsk_config |= (options_format.selected_index() << 16); afsk_config |= (field_repeat.value() << 24); portapack::persistent_memory::set_afsk_config(afsk_config); nav.pop(); }; }