static int row2_cb(int absrow, int relrow, int y, void *data) { data = NULL; const void *label = ""; void *value = NULL; void *input_value = NULL; switch(absrow) { case ITEM_INPUT: label = _tr_noop("Input"); value = set_source_cb; data = &tp->trim.src; input_value = set_input_source_cb; break; case ITEM_TRIMNEG: label = _tr_noop("Trim -"); value = set_trim_cb; data = &tp->trim.neg; break; case ITEM_TRIMPOS: label = _tr_noop("Trim +"); value = set_trim_cb; data = &tp->trim.pos; break; case ITEM_TRIMSTEP: label = _tr_noop("Trim Step"); value = set_trimstep_cb; data = (void *)(long)(tp->index + 0x100); //0x100: Use tp->trim break; case ITEM_TRIMSWITCH: label = _tr_noop("Switch"); value = set_switch_cb; data = &tp->trim.sw; input_value = set_input_switch_cb; break; } GUI_CreateLabelBox(&guit->label[relrow], LABEL2_X, y, LABEL2_WIDTH, LINE_HEIGHT, &LABEL_FONT, GUI_Localize, NULL, label); GUI_CreateTextSourcePlate(&guit->value[relrow], TEXTSEL2_X, y, TEXTSEL2_WIDTH, LINE_HEIGHT, &TEXTSEL_FONT, NULL, value, input_value, data); return 1; }
static int row4_cb(int absrow, int relrow, int y, void *data) { (void)data; void *ts = NULL; void *input_ts = NULL; void *ts_press = NULL; void *ts_data = NULL; char *label = NULL; switch (absrow) { case 0: label = _tr_noop("Video Enable"); ts = set_source_cb; ts_press = sourceselect_cb; ts_data = (void *)&Model.videosrc; input_ts = set_input_source_cb; break; case 1: label = _tr_noop("Video Channel"); ts = set_videoch_cb; break; case 2: label = _tr_noop("Contrast"); ts = set_videocontrast_cb; break; case 3: label = _tr_noop("Brightness"); ts = set_videobrightness_cb; break; } GUI_CreateLabelBox(&gui->label[relrow], LABEL_X, y, LABEL_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, NULL, NULL, _tr(label)); GUI_CreateTextSourcePlate(&gui->value[relrow], SELECT_X, y, SELECT_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, ts_press, ts, input_ts, ts_data); return 1; }
static int simple_row_cb(int absrow, int relrow, int y, void *data) { const char *label = NULL; void *tgl = NULL; void *value = NULL; data = NULL; switch(absrow) { case COMMON_SRC: label = _tr_noop("Src"); tgl = sourceselect_cb; value = set_source_cb; data = &mp->mixer[0].src; break; case COMMON_CURVE: label = _tr_noop("Curve"); tgl = curveselect_cb; value = set_curvename_cb; data = &mp->mixer[0]; break; case COMMON_SCALE: label = _tr_noop("Scale"); value = set_number100_cb; data = &mp->mixer[0].scalar; break; case SIMPLE_OFFSET: label = _tr_noop("Offset"); value = set_number100_cb; data = &mp->mixer[0].offset; break; } int x = 0; u8 w = LEFT_VIEW_WIDTH; labelDesc.style = LABEL_LEFTCENTER; GUI_CreateLabelBox(&gui->label[relrow], x, y, w, ITEM_HEIGHT, &labelDesc, NULL, NULL, _tr(label)); labelDesc.style = LABEL_CENTER; GUI_CreateTextSelectPlate(&gui->value[relrow].ts, x, y + ITEM_HEIGHT + 1, w, ITEM_HEIGHT, &labelDesc, tgl, value, data); return 1; }
void PAGE_ModelConfigInit(int page) { (void)page; PAGE_ShowHeader(Model.type == 0 ? _tr_noop("Helicopter") : _tr_noop("Airplane")); if (Model.type == 0) { u8 i = ROW1; GUI_CreateLabelBox(&gui->swashlbl, COL1, i, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("SwashType")); GUI_CreateTextSelect(&gui->swash, COL2, i - 1, TEXTSELECT_96, NULL, swash_val_cb, NULL); i+=28; GUI_CreateLabelBox(&gui->invlbl[0], COL1, i, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("ELE Inv")); GUI_CreateTextSelect(&gui->inv[0], COL2, i - 1, TEXTSELECT_96, swashinv_press_cb, swashinv_val_cb, (void *)1); i+=22; GUI_CreateLabelBox(&gui->invlbl[1], COL1, i, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("AIL Inv")); GUI_CreateTextSelect(&gui->inv[1], COL2, i - 1, TEXTSELECT_96, swashinv_press_cb, swashinv_val_cb, (void *)2); i+=22; GUI_CreateLabelBox(&gui->invlbl[2], COL1, i, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("COL Inv")); GUI_CreateTextSelect(&gui->inv[2], COL2, i - 1, TEXTSELECT_96, swashinv_press_cb, swashinv_val_cb, (void *)4); i+=28; GUI_CreateLabelBox(&gui->mixlbl[0], COL1, i, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("ELE Mix")); GUI_CreateTextSelect(&gui->mix[0], COL2, i - 1, TEXTSELECT_96, NULL, swashmix_val_cb, (void *)1); i+=22; GUI_CreateLabelBox(&gui->mixlbl[1], COL1, i, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("AIL Mix")); GUI_CreateTextSelect(&gui->mix[1], COL2, i - 1, TEXTSELECT_96, NULL, swashmix_val_cb, (void *)0); i+=22; GUI_CreateLabelBox(&gui->mixlbl[2], COL1, i, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("COL Mix")); GUI_CreateTextSelect(&gui->mix[2], COL2, i - 1, TEXTSELECT_96, NULL, swashmix_val_cb, (void *)2); } }
static int complex_row_cb(int absrow, int relrow, int y, void *data) { const char *label = NULL; void *tgl = NULL; void *value = NULL; data = NULL; int x = 0; int w = LEFT_VIEW_WIDTH; if (absrow + COMMON_LAST == COMPLEX_TRIM) { GUI_CreateButtonPlateText(&gui->value[relrow].but, x, y, w, ITEM_HEIGHT, &labelDesc, show_trim_cb, 0x0000, toggle_trim_cb, NULL); if (! MIXER_SourceHasTrim(MIXER_SRC(mp->mixer[0].src))) GUI_SetHidden((guiObject_t *)&gui->label[relrow], 1); return 1; } switch(absrow + COMMON_LAST) { case COMPLEX_MIXER: label = _tr_noop("Mixers"); value = set_nummixers_cb; break; case COMPLEX_PAGE: label = _tr_noop("Page"); tgl = reorder_cb; value = set_mixernum_cb; break; case COMPLEX_SWITCH: label = _tr_noop("Switch"); tgl = sourceselect_cb; value = set_drsource_cb; data = &mp->cur_mixer->sw; break; case COMPLEX_MUX: label = _tr_noop("Mux"); value = set_mux_cb; break; case COMPLEX_SRC: label = _tr_noop("Src"); tgl = sourceselect_cb; value = set_source_cb; data = &mp->cur_mixer->src; break; case COMPLEX_CURVE: label = _tr_noop("Curve"); tgl = curveselect_cb; value = set_curvename_cb; data = mp->cur_mixer; break; case COMPLEX_SCALE: label = _tr_noop("Scale"); value = set_number100_cb; data = &mp->cur_mixer->scalar; break; case COMPLEX_OFFSET: label = _tr_noop("Offset"); value = set_number100_cb; data = &mp->cur_mixer->offset; break; } labelDesc.style = LABEL_LEFTCENTER; GUI_CreateLabelBox(&gui->label[relrow], x, y, w, ITEM_HEIGHT, &labelDesc, NULL, NULL, _tr(label)); labelDesc.style = LABEL_CENTER; GUI_CreateTextSelectPlate(&gui->value[relrow].ts, x, y + ITEM_HEIGHT + 1, w, ITEM_HEIGHT, &labelDesc, tgl, value, data); if (absrow + COMMON_LAST == COMPLEX_SRC) set_src_enable(CURVE_TYPE(&mp->cur_mixer->curve)); return 1; }
void PAGE_TrainConfigInit(int page) { (void)page; int mode = PPMin_Mode(); PAGE_ShowHeader(mode == PPM_IN_TRAIN1 ? _tr_noop("Trainer Cfg (Channel)") : mode == PPM_IN_TRAIN2 ? _tr_noop("Trainer Cfg (Stick)") : _tr_noop("PPMIn Cfg (Extend)")); int row = ROW1; if (PPMin_Mode() != PPM_IN_SOURCE) { GUI_CreateLabelBox(&gui->trainswlbl, COL1, row, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Trainer Sw")); GUI_CreateTextSource(&gui->trainsw, COL2, row, TEXTSELECT_96, sourceselect_cb, set_source_cb, set_input_source_cb, &Model.train_sw); } else { GUI_CreateLabelBox(&gui->numchlbl, COL1, row, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Num Channels")); GUI_CreateTextSelect(&gui->numch, COL2, row, TEXTSELECT_96, NULL, set_train_cb, (void *)0L); } row += 20; GUI_CreateLabelBox(&gui->centerpwlbl, COL1, row, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Center PW")); GUI_CreateTextSelect(&gui->centerpw, COL2, row, TEXTSELECT_96, NULL, set_train_cb, (void *)1L); row += 20; GUI_CreateLabelBox(&gui->deltapwlbl, COL1, row, LABEL_WIDTH, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Delta PW")); GUI_CreateTextSelect(&gui->deltapw, COL2, row, TEXTSELECT_96, NULL, set_train_cb, (void *)2L); row += 20; if (PPMin_Mode() == PPM_IN_SOURCE) return; int num_rows= (MAX_PPM_IN_CHANNELS + 1) / 2; for (int i = 0; i < num_rows; i++) { long idx = i; row += 20; if (row > 300) // RBE: should be LCD_HEIGHT - 16(height box) ==> always < 300 break; GUI_CreateLabelBox(&gui->ppmmaplbl[idx], COL1, row, COL3 - COL1, 16, &LABEL_FONT, input_chname_cb, NULL, (void *)idx); GUI_CreateTextSelect(&gui->ppmmap[idx], COL3, row, TEXTSELECT_96, NULL, set_chmap_cb, (void *)idx); idx += num_rows; if (idx >= MAX_PPM_IN_CHANNELS) break; GUI_CreateLabelBox(&gui->ppmmaplbl[idx], COL4, row, COL5 - COL4, 16, &LABEL_FONT, input_chname_cb, NULL, (void *)idx); GUI_CreateTextSelect(&gui->ppmmap[idx], COL5, row, TEXTSELECT_96, NULL, set_chmap_cb, (void *)idx); } }
static void _show_titlerow() { enum { TITLE_X = 40, BUTTON_X = LCD_WIDTH - 96 - 8, TITLE_WIDTH = BUTTON_X - TITLE_X, }; PAGE_ShowHeader(NULL); GUI_CreateLabelBox(&gui->title, TITLE_X, 10, TITLE_WIDTH, 12, &TITLE_FONT, MIXPAGE_ChanNameProtoCB, NULL, (void *)(long)mp->channel); GUI_CreateButton(&gui->revert, BUTTON_X, 4, BUTTON_96, GUI_Localize, revert_cb, _tr_noop("Revert")); }
static void add_dlg_cb(guiObject_t *obj, const void *data) { (void)obj; (void)data; GUI_CreateDialog(&gui->dialog, ADD_DIALOG_X, ADD_DIALOG_Y, ADD_DIALOG_W, ADD_DIALOG_H, _tr("Page Config"), NULL, dialog_ok_cb, dtOk, ""); GUI_CreateLabelBox(&gui->dlglbl[0], ADD_LBL_X, ADD_DIALOG_Y + 30, ADD_TS_X - ADD_LBL_X, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Type")); GUI_CreateTextSelect(&gui->dlgts[0], ADD_TS_X, ADD_DIALOG_Y + 30, TEXTSELECT_128, NULL, newelem_cb, NULL); GUI_CreateButton(&gui->dlgbut[0], ADD_ADDBUT_X, ADD_DIALOG_Y + 30, BUTTON_64x16, add_dlgbut_str_cb, newelem_press_cb, (void *)1L); GUI_CreateLabelBox(&gui->dlglbl[1], ADD_LBL_X, ADD_DIALOG_Y + 60, ADD_BUT_X - ADD_LBL_X, 0, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Template")); GUI_CreateButton(&gui->dlgbut[1], ADD_BUT_X, ADD_DIALOG_Y + 60, BUTTON_96x16, add_dlgbut_str_cb, add_dlgbut_cb, (void *)0L); int y = ADD_DIALOG_Y + 90; for (long i = 0; i < NUM_QUICKPAGES; i++) { GUI_CreateLabelBox(&gui->dlglbl[i+2], ADD_LBL_X, y, ADD_MENU_X - ADD_LBL_X, 0, &LABEL_FONT, menulabel_cb, NULL, (void *)i); GUI_CreateTextSelect(&gui->dlgts[i+2], ADD_MENU_X, y, TEXTSELECT_224, NULL, menusel_cb, (void *)i); y += 24; } GUI_SetSelected((guiObject_t *)&gui->dlgbut[0]); }
void PAGE_TrimEditInit(int page) { struct Trim *trim = MIXER_GetAllTrims(); tp->index = page; tp->trim = trim[tp->index]; GUI_CreateLabelBox(&guit->header, 0, 0, LABEL2_WIDTH, HEADER_HEIGHT, &TITLE_FONT, GUI_Localize, NULL, _tr_noop("Edit")); GUI_CreateButtonPlateText(&guit->save, BUTTON2_X, BUTTON2_Y, BUTTON2_WIDTH, LINE_HEIGHT, &BUTTON_FONT, GUI_Localize, okcancel_cb, _tr_noop("Save")); GUI_CreateScrollable(&gui->scrollable, 0, HEADER_HEIGHT, LCD_WIDTH, LCD_HEIGHT - HEADER_HEIGHT, LINE_SPACE, ITEM_LAST, row2_cb, getobj2_cb, NULL, NULL); GUI_SetSelected(GUI_ShowScrollableRowOffset(&gui->scrollable, 0)); }
void PAGE_MainLayoutInit(int page) { (void)page; #if HAS_LAYOUT_EDITOR PAGE_ShowHeader(_tr_noop("Layout: Long-Press ENT")); PAGE_SetActionCB(_action_cb); #else PAGE_ShowHeader(PAGE_GetName(PAGEID_MAINCFG)); #endif memset(gui, 0, sizeof(*gui)); memset(lp, 0, sizeof(*lp)); show_config(); }
static int row3_cb(int absrow, int relrow, int y, void *data) { (void)data; void *ts; void *input_ts = NULL; void *ts_press = NULL; void *ts_data = NULL; char *label = NULL; void *label_cmd = NULL; switch (absrow) { case 0: label = _tr_noop("Center PW"); ts = set_train_cb; ts_data = (void *)1L; break; case 1: label = _tr_noop("Delta PW"); ts = set_train_cb; ts_data = (void *)2L; break; case 2: if (PPMin_Mode() != PPM_IN_SOURCE) { label = _tr_noop("Trainer Sw"); ts = set_source_cb; ts_press = sourceselect_cb; ts_data = (void *)&Model.train_sw; input_ts = set_input_source_cb; } else { label = _tr_noop("Num Channels"); ts = set_train_cb; ts_data = (void *)0L; } break; default: label_cmd = input_chname_cb; label = (void *)((long)absrow - 3); ts = set_chmap_cb; ts_data = label; break; } GUI_CreateLabelBox(&gui->label[relrow], LABEL_X, y, LABEL_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, label_cmd, NULL, label_cmd ? label : _tr(label)); GUI_CreateTextSourcePlate(&gui->value[relrow], SELECT_X, y, SELECT_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, ts_press, ts, input_ts, ts_data); return 1; }
static int row2_cb(int absrow, int relrow, int y, void *data) { data = NULL; const void *label = NULL; void *value = NULL; switch(absrow) { case ITEM_INPUT: label = _tr_noop("Input"); value = set_source_cb; data = &tp->trim.src; break; case ITEM_TRIMNEG: label = _tr_noop("Trim -"); value = set_trim_cb; data = &tp->trim.neg; break; case ITEM_TRIMPOS: label = _tr_noop("Trim +"); value = set_trim_cb; data = &tp->trim.pos; break; case ITEM_TRIMSTEP: label = _tr_noop("Trim Step"); value = set_trimstep_cb; data = (void *)(long)(tp->index + 0x100); //0x100: Use tp->trim break; case ITEM_TRIMSWITCH: label = _tr_noop("Switch"); value = set_switch_cb; data = &tp->trim.sw; break; } int w = 63; u8 x = 60; GUI_CreateLabelBox(&guit->label[relrow], 0, y, 0, ITEM_HEIGHT, &DEFAULT_FONT, NULL, NULL, _tr(label)); GUI_CreateTextSelectPlate(&guit->value[relrow], x, y, w, ITEM_HEIGHT, &DEFAULT_FONT, NULL, value, data); return 1; }
static void _show_page(const struct telem_layout2 *page) { PAGE_RemoveAllObjects(); tp->font.font = TINY_FONT.font; tp->font.font_color = 0xffff; tp->font.fill_color = 0; tp->font.style = LABEL_SQUAREBOX; long i = 0; for(const struct telem_layout *ptr = page->header; ptr->source; ptr++, i++) { GUI_CreateLabelBox(&gui->header[i], ptr->x, 0, ptr->width, ITEM_HEIGHT, ptr->source == ARROW_LABEL ? &TINY_FONT : &DEFAULT_FONT, header_cb, NULL, (void *)(long)ptr->source); } PAGE_ShowHeader(_tr_noop("")); // to draw a underline only GUI_CreateScrollable(&gui->scrollable, 0, ITEM_HEIGHT + 1, LCD_WIDTH, LCD_HEIGHT - ITEM_HEIGHT -1, page->row_height, page->num_items, row_cb, getobj_cb, NULL, (void *)page->layout); tp->telem = Telemetry; }
#ifdef MODULAR //Some versions of gcc applythis to definitions, others to calls //So just use long_calls everywhere //#pragma long_calls_off extern unsigned _data_loadaddr; const unsigned long protocol_type = (unsigned long)&_data_loadaddr; #endif #ifdef PROTO_HAS_CC2500 #include "iface_cc2500.h" #if 0 static const char * const frsky_opts[] = { _tr_noop("Freq-Fine"), "-127", "127", NULL, _tr_noop("Freq-Course"), "-127", "127", NULL, NULL }; #endif enum { PROTO_OPTS_FREQFINE = 0, PROTO_OPTS_FREQCOURSE = 1, LAST_PROTO_OPT, }; ctassert(LAST_PROTO_OPT <= NUM_PROTO_OPTS, too_many_protocol_opts); static u8 packet[16]; static u32 state; static u32 seed; static u32 fixed_id;
static int row_cb(int absrow, int relrow, int y, void *data) { int type = (long)data; long elemidx = elem_rel_to_abs(type, absrow); int X = LAYDLG_X + LAYDLG_SCROLLABLE_X - (type == ELEM_TOGGLE ? 68/2 : 0); int width = LAYDLG_MIN_WIDTH + (type == ELEM_TOGGLE ? 64 : 0) - 2 * LAYDLG_SCROLLABLE_X - 16; int del_x = X + 15 + 110; int num_objs = 2; if (type == ELEM_MODELICO) { GUI_CreateLabelBox(&gui->dlglbl[relrow], X, y, 115, LAYDLG_TEXT_HEIGHT, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Model")); } else { GUI_CreateLabelBox(&gui->dlglbl[relrow], X, y, 10, 16, &LABEL_FONT, label_cb, NULL, (void *)(long)(absrow)); GUI_CreateTextSelect(&gui->dlgts[relrow], X + 15, y, TEXTSELECT_96, NULL, dlgts_cb, (void *)elemidx); if (type == ELEM_TOGGLE) { GUI_CreateButton(&gui->dlgbut2[relrow], del_x, y, BUTTON_64x16, dlgbut_str_cb, toggle_press_cb, (void *)elemidx); //del_x = X + 15 + 168; num_objs++; } } GUI_CreateButton(&gui->dlgbut[relrow], X+width-64, y, BUTTON_64x16, dlgbut_str_cb, dlgbut_cb, (void *)elemidx); return num_objs; }
const unsigned long protocol_type = (unsigned long)&_data_loadaddr; #endif #define PPMOUT_MAX_CHANNELS 10 static volatile u16 pulses[PPMOUT_MAX_CHANNELS+1]; u8 num_channels; /* FIXME: The original imlementation used a PWM to output the PPM signal. However, I could not get TIM1 woring properly. The current implementation just bit-bangs the output. It works fine but is less efficient */ #ifndef EMULATOR #define BITBANG_PPM #endif static const char * const ppm_opts[] = { _tr_noop("Center PW"), "1000", "1800", NULL, _tr_noop("Delta PW"), "100", "700", NULL, _tr_noop("Notch PW"), "100", "500", NULL, _tr_noop("Frame Size"), "20000", "22500", NULL, NULL }; enum { CENTER_PW, DELTA_PW, NOTCH_PW, PERIOD_PW, }; volatile u8 state; static void build_data_pkt() {
const char *STDMIXER_ModeName(int mode) { return mode == MIXER_ADVANCED ? _tr_noop("Advanced") : _tr_noop("Standard"); }
static int row_cb(int absrow, int relrow, int y, void *data) { (void) data; u8 ts_x = DEFAULT_TEXTSEL_X; int count = 0; const void *label = NULL; void *ts_tgl = NULL; void *ts_value = NULL; void *but_txt = NULL; void *but_tgl = NULL; void *but_data = NULL; switch(absrow) { case ITEM_FILE: label = _tr_noop("File"); ts_tgl = file_press_cb; ts_value = file_val_cb; break; case ITEM_NAME: label = _tr_noop("Model name"); but_txt = show_text_cb; but_tgl = _changename_cb; but_data = Model.name; break; case ITEM_ICON: label = _tr_noop("Icon"); but_txt = show_icontext_cb; but_tgl = changeicon_cb; break; case ITEM_TYPE: label = _tr_noop("Model type"); ts_tgl = type_press_cb; ts_value = type_val_cb; break; case ITEM_TXPOWER: label = _tr_noop("Tx power"); ts_value = powerselect_cb; break; case ITEM_PPMIN: label = _tr_noop("PPM In"); ts_tgl = ppmin_press_cb; ts_value = ppmin_select_cb; break; #if HAS_VIDEO case ITEM_VIDEO: label = _tr_noop("Video"); but_data = _tr_noop("Setup"); but_tgl = video_settings_cb; break; #endif case ITEM_PROTO: ts_tgl = proto_press_cb; ts_value = protoselect_cb; ts_x = LEFT_TEXTSEL_X; but_txt = show_bindtext_cb; but_tgl = bind_cb; break; case ITEM_FIXEDID: label = _tr_noop("Fixed ID"); but_txt = show_text_cb; but_tgl = fixedid_cb; but_data = mp->fixed_id; break; case ITEM_NUMCHAN: label = _tr_noop("# Channels"); ts_value = numchanselect_cb; break; #if HAS_STANDARD_GUI case ITEM_GUI: label = _tr_noop("Mixer GUI"); ts_value = mixermode_cb; break; #endif } if (label) GUI_CreateLabelBox(&gui->col1[relrow].label, LABEL_X, y, LABEL_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, NULL, NULL, _tr(label)); if (ts_value) { GUI_CreateTextSelectPlate(but_txt ? &gui->col1[relrow].ts : &gui->col2[relrow].ts, ts_x, y, TEXTSEL_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, ts_tgl, ts_value, NULL); count++; } if (but_tgl) { GUI_CreateButtonPlateText(&gui->col2[relrow].but, BUTTON_X, y, BUTTON_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, but_txt, 0x0000, but_tgl, but_data); count++; } return count; }
#include "standard/standard.h" enum { DEFAULT_TEXTSEL_X = 63, LEFT_TEXTSEL_X = 0, TEXTSEL_WIDTH = 59, LABEL_X = 0, LABEL_WIDTH = 0, BUTTON_X = 63, BUTTON_WIDTH = 59, }; #endif //OVERRIDE_PLACEMENT #include <stdlib.h> static const char * const HELI_LABEL = _tr_noop("Heli"); static const char * const PLANE_LABEL = _tr_noop("Plane"); static const char * const MULTI_LABEL = _tr_noop("Multi"); #include "../common/_model_page.c" static u16 current_selected = 0; static const char * show_icontext_cb(guiObject_t *obj, const void *data) { (void)data; (void)obj; unsigned int i; if(! Model.icon[0]) return _tr("Default"); tempstring_cpy(Model.icon+9); for(i = 0; i < strlen(tempstring); i++) {
static int row_cb(int absrow, int relrow, int y, void *data) { data = NULL; const void *label = ""; const void *title = NULL; void *tgl = NULL; void *value = NULL; void *but_str = NULL; u8 x = LARGE_SEL_X_OFFSET; switch(absrow) { #ifndef NO_LANGUAGE_SUPPORT case ITEM_LANG: title = _tr_noop("Generic settings"); label = _tr_noop("Language"); but_str = langstr_cb; tgl = lang_select_cb; break; #endif case ITEM_MODE: #ifdef NO_LANGUAGE_SUPPORT title = _tr_noop("Generic settings"); #endif label = _tr_noop("Stick mode"); value = modeselect_cb; break; case ITEM_STICKS: label = _tr_noop("Sticks"); but_str = calibratestr_cb; tgl = press_cb; data = (void *)CALIB_STICK; break; case ITEM_BUZZ: title = _tr_noop("Buzz settings"); label = _tr_noop("Buzz volume"); value = _buzz_vol_cb; data = &Transmitter.volume; break; case ITEM_HAPTIC: label = _tr_noop("Vibration"); value = _vibration_state_cb; data = &Transmitter.vibration_state; break; case ITEM_BATT: label = _tr_noop("Batt alarm"); value = batalarm_select_cb; break; case ITEM_ALARM_INTV: label = _tr_noop("Alarm intvl"); value = batalarmwarn_select_cb; break; case ITEM_PWR_ALARM: label = _tr_noop("PwrOn alarm"); value = poweralarm_select_cb; break; case ITEM_PWRDN_ALARM: label = _tr_noop("PwrDn alert"); value = _music_shutdown_cb; break; case ITEM_BACKLIGHT: title = _tr_noop("LCD settings"); label = _tr_noop("Backlight"); value = backlight_select_cb; break; case ITEM_CONTRAST: label = _tr_noop("Contrast"); value = _contrast_select_cb; break; case ITEM_DIMTIME: label = _tr_noop("Dimmer time"); value = auto_dimmer_time_cb; x = SMALL_SEL_X_OFFSET; break; case ITEM_DIMVAL: label = _tr_noop("Dimmer target"); value = common_select_cb; data = &Transmitter.auto_dimmer.backlight_dim_value; x = MED_SEL_X_OFFSET; break; case ITEM_PREALERT: title = _tr_noop("Timer settings"); label = _tr_noop("Prealert time"); value = prealert_time_cb; data = (void *)0L; x = MED_SEL_X_OFFSET; break; case ITEM_PREALERT_IVAL: label = _tr_noop("Prealert intvl"); value = timer_interval_cb; data = &Transmitter.countdown_timer_settings.prealert_interval; x = SMALL_SEL_X_OFFSET; break; case ITEM_TIMEUP: label = _tr_noop("Timeup intvl"); value = timer_interval_cb; data = &Transmitter.countdown_timer_settings.timeup_interval; x = SMALL_SEL_X_OFFSET; break; case ITEM_TELEMTEMP: title = _tr_noop("Telemetry settings"); label = _tr_noop("Temperature"); value = units_cb; data = (void *)1L; break; case ITEM_TELEMLEN: label = _tr_noop("Length"); value = units_cb; data = (void *)0L; break; } if (title) { enum LabelType oldType = labelDesc.style; labelDesc.style = LABEL_UNDERLINE; GUI_CreateLabelBox(&gui->title[relrow], TITLE_X_OFFSET, y, TITLE_WIDTH, LINE_HEIGHT, &labelDesc, NULL, NULL, _tr(title)); labelDesc.style = oldType; y += LINE_SPACE; } GUI_CreateLabelBox(&gui->label[relrow], LABEL_X_OFFSET, y, LABEL_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, NULL, NULL, _tr(label)); if(but_str) { GUI_CreateButtonPlateText(&gui->value[relrow].but, x, y, TEXTSEL_X_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, but_str, 0x0000, tgl, data); } else { GUI_CreateTextSelectPlate(&gui->value[relrow].ts, x, y, TEXTSEL_X_WIDTH, LINE_HEIGHT, &DEFAULT_FONT, NULL, value, data); } return 1; }
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Deviation. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" #include "pages.h" #include "gui/gui.h" #include "config/model.h" #include "config/tx.h" #include <stdlib.h> // string too long for devo10, so define it separately for devo8 and devo10 static const char * const HELI_LABEL = _tr_noop("Helicopter"); static const char * const PLANE_LABEL = _tr_noop("Airplane"); static const char * const MULTI_LABEL = _tr_noop("Multirotor"); #include "../common/_model_page.c" #if HAS_STANDARD_GUI static const char *_mixermode_cb(guiObject_t *obj, int dir, void *data) { const char *ret = mixermode_cb(obj, dir, data); if(Model.mixer_mode != mp->last_mixermode) { mp->last_mixermode = Model.mixer_mode; PAGE_RemoveHeader(); PAGE_ShowHeader(PAGE_GetName(PAGEID_MODEL)); } return ret;
void PAGE_AboutInit(int page) { (void)page; PAGE_RemoveAllObjects(); PAGE_ShowHeader(PAGE_GetName(PAGEID_ABOUT)); PAGE_SetActionCB(_action_cb); strcpy(up->tmpstr, (const char *) _tr("Deviation FW version:")); GUI_CreateLabelBox(&gui->label[0], 0, 15, LCD_WIDTH, ITEM_HEIGHT, &DEFAULT_FONT, NULL, NULL, "www.deviationtx.com"); GUI_CreateLabelBox(&gui->label[1], 0, 30, LCD_WIDTH, ITEM_HEIGHT, &DEFAULT_FONT, NULL, NULL, up->tmpstr); GUI_CreateLabelBox(&gui->label[2], 0, 45, LCD_WIDTH, ITEM_HEIGHT, &MICRO_FONT, NULL, NULL, _tr_noop(DeviationVersion)); }
static const char* pm_group_name = "pm"; static const char* vbat_var_name = "vbatMV"; static const u8 vbat_var_type = LOG_UINT16; static const char* extvbat_var_name = "extVbatMV"; static const u8 extvbat_var_type = LOG_UINT16; static const char* radio_group_name = "radio"; static const char* rssi_var_name = "rssi"; static const u8 rssi_var_type = LOG_UINT8; // Repurposing DSM Telemetry fields #define TELEM_CFLIE_INTERNAL_VBAT TELEM_DSM_FLOG_VOLT2 // Onboard voltage #define TELEM_CFLIE_EXTERNAL_VBAT TELEM_DSM_FLOG_VOLT1 // Voltage from external pin (BigQuad) #define TELEM_CFLIE_RSSI TELEM_DSM_FLOG_FADESA // Repurpose FADESA for RSSI static const char * const cflie_opts[] = { _tr_noop("Telemetry"), _tr_noop("Off"), _tr_noop("ACKPKT"), _tr_noop("CRTPLOG"), NULL, _tr_noop("CRTP Mode"), _tr_noop("RPYT"), _tr_noop("CPPM"), NULL, NULL }; enum { PROTOOPTS_TELEMETRY = 0, PROTOOPTS_CRTP_MODE = 1, LAST_PROTO_OPT, }; ctassert(LAST_PROTO_OPT <= NUM_PROTO_OPTS, too_many_protocol_opts); #define TELEM_OFF 0 #define TELEM_ON_ACKPKT 1 #define TELEM_ON_CRTPLOG 2 #define CRTP_MODE_RPYT 0
#include "mixer.h" #include "config/model.h" #ifdef MODULAR #pragma long_calls_off extern unsigned _data_loadaddr; const unsigned long protocol_type = (unsigned long)&_data_loadaddr; #endif #define PPMOUT_MAX_CHANNELS NUM_OUT_CHANNELS static volatile u16 pulses[PPMOUT_MAX_CHANNELS+2]; u8 num_channels; #define STEP_SIZE "3276810" // == 10small/50large == (50 << 16) | 10 #define STEPSIZE2 "32768100" // == 100small / 500large == (500 << 16) | 100 static const char * const ppm_opts[] = { _tr_noop("Center PW"), "1000", "1800", STEP_SIZE, NULL, _tr_noop("Delta PW"), "100", "700", STEP_SIZE, NULL, _tr_noop("Notch PW"), "100", "500", STEP_SIZE, NULL, _tr_noop("Frame Size"), "10000", "30000", STEPSIZE2, NULL, NULL }; enum { CENTER_PW, DELTA_PW, NOTCH_PW, PERIOD_PW, LAST_PROTO_OPT, }; ctassert(LAST_PROTO_OPT <= NUM_PROTO_OPTS, too_many_protocol_opts); static void build_data_pkt()
// State variables for the telemetry_setup_state_machine static u8 toc_size; // Size of the TOC read from the crazyflie static u8 next_toc_variable; // State variable keeping track of the next var to read static u8 vbat_var_id; // ID of the vbatMV variable static u8 extvbat_var_id; // ID of the extVbatMV variable // Constants used for finding var IDs from the toc static const char* pm_group_name = "pm"; static const char* vbat_var_name = "vbatMV"; static const u8 vbat_var_type = LOG_UINT16; static const char* extvbat_var_name = "extVbatMV"; static const u8 extvbat_var_type = LOG_UINT16; static const char * const cflie_opts[] = { _tr_noop("Telemetry"), _tr_noop("Off"), _tr_noop("On"), NULL, NULL }; enum { PROTOOPTS_TELEMETRY = 0, LAST_PROTO_OPT, }; ctassert(LAST_PROTO_OPT <= NUM_PROTO_OPTS, too_many_protocol_opts); #define TELEM_OFF 0 #define TELEM_ON 1 // Bit vector from bit position #define BV(bit) (1 << bit) // Packet ack status values
#define CHANNEL_INVERTED CHANNEL5 // inverted flight on Floureon H101 #define CHANNEL_FLIP CHANNEL6 #define CHANNEL_PICTURE CHANNEL7 #define CHANNEL_VIDEO CHANNEL8 #define CHANNEL_HEADLESS CHANNEL9 #define CHANNEL_RTH CHANNEL10 #define CHANNEL_TO CHANNEL11 #define CHANNEL_EMGSTOP CHANNEL12 enum { Bayang_INIT1 = 0, Bayang_BIND2, Bayang_DATA }; static const char *const bay_opts[] = { _tr_noop("Telemetry"), _tr_noop("Off"), _tr_noop("On"), NULL, _tr_noop("Format"), _tr_noop("regular"), "X16-AH", "IRDRONE", NULL, NULL }; enum { PROTOOPTS_TELEMETRY = 0, PROTOOPTS_FORMAT = 1, LAST_PROTO_OPT, }; enum { FORMAT_REGULAR, FORMAT_X16_AH, FORMAT_IRDRONE,
#define HITEC_BIND_NUM_FREQUENCE 14 enum { HITEC_START = 0x00, HITEC_CALIB = 0x01, HITEC_PREP = 0x02, HITEC_DATA1 = 0x03, HITEC_DATA2 = 0x04, HITEC_DATA3 = 0x05, HITEC_DATA4 = 0x06, HITEC_RX1 = 0x07, HITEC_RX2 = 0x08, }; static const char *const hitec_opts[] = { _tr_noop("Format"), "OPTIMA", "MINIMA", NULL, _tr_noop("Freq-Fine"), "-127", "127", NULL, NULL }; enum { FORMAT_OPTIMA, FORMAT_MINIMA, }; enum { PROTO_OPTS_FORMAT = 0, PROTO_OPTS_FREQFINE, LAST_PROTO_OPT, };
/* Advanced Standard Row1 Timer Timer Row2 Switch Switch Row3 Reset(perm)/ResetSwitch Reset(perm)/Start Row4 Start/Set-to Set-to */ static int row_cb(int absrow, int relrow, int y, void *data) { (void)data; int COL1 = 30; int COL2 = 130; int selectable = 0; for (int j = 0; j < TIMERCOLUMNS; j++) { int row = y; int i = relrow * TIMERCOLUMNS + j; int timer_num = TIMERCOLUMNS*absrow+j; //Row 1 GUI_CreateLabelBox(&gui->timer[i], COL1, row, COL2-COL1, 18, &LABEL_FONT,timer_str_cb, NULL, (void *)(long)timer_num); GUI_CreateTextSelect(&gui->type[i], COL2, row, TEXTSELECT_96, NULL, set_timertype_cb, (void *)(long)timer_num); //Row 2 row+=20; GUI_CreateLabelBox(&gui->switchlbl[i], COL1, row, COL2-COL1, 18, &LABEL_FONT, switch_str_cb, NULL, (void *)(long)timer_num); GUI_CreateTextSource(&gui->src[i], COL2, row, TEXTSELECT_96, toggle_source_cb, set_source_cb, set_input_source_cb, (void *)(long)timer_num); //Row 3 row+=20; /* Reset Perm timer*/ GUI_CreateLabelBox(&gui->resetpermlbl[i], COL1, row, COL2-COL1, 18, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Reset")); GUI_CreateButton(&gui->resetperm[i], COL2, row, BUTTON_96x16, show_timerperm_cb, reset_timerperm_cb, (void *)(long)timer_num); if(Model.mixer_mode != MIXER_STANDARD) { /* or Reset switch */ GUI_CreateLabelBox(&gui->resetlbl[i], COL1, row, COL2-COL1, 18, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Reset sw")); GUI_CreateTextSource(&gui->resetsrc[i], COL2, row, TEXTSELECT_96, toggle_resetsrc_cb, set_resetsrc_cb, set_input_rstsrc_cb, (void *)(long)timer_num); row+=20; } //Row 4 GUI_CreateLabelBox(&gui->startlbl[i], COL1, row, COL2-COL1, 18, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Start")); GUI_CreateTextSelect(&gui->start[i], COL2, row, TEXTSELECT_96, NULL, set_start_cb, (void *)(long)timer_num); if(Model.mixer_mode == MIXER_STANDARD) row += 20; GUI_CreateButton(&gui->setperm[i], COL2, row, BUTTON_96x16, show_timerperm_cb, reset_timerperm_cb, (void *)(long)(timer_num | 0x80)); update_countdown(timer_num); int tmpselectable = (Model.timer[timer_num].type < TIMER_COUNTDOWN) ? 2 : 3; if (Model.mixer_mode == MIXER_ADVANCED) tmpselectable++; if(HAS_PERMANENT_TIMER && Model.timer[timer_num].type == TIMER_PERMANENT) tmpselectable = 4; selectable += tmpselectable; COL1 = 270; COL2 = 343; } return selectable; }
#include "config/tx.h" #ifdef MODULAR //Some versions of gcc applythis to definitions, others to calls //So just use long_calls everywhere //#pragma long_calls_off extern unsigned _data_loadaddr; const unsigned long protocol_type = (unsigned long)&_data_loadaddr; #endif #ifdef PROTO_HAS_CC2500 #include "iface_cc2500.h" static const char *const corona_opts[] = { _tr_noop("Format"), "V1", "V2", "FDV3", NULL, _tr_noop("Freq-Fine"), "-127", "127", NULL, NULL }; enum { PROTO_OPTS_FORMAT = 0, PROTO_OPTS_FREQFINE, LAST_PROTO_OPT, }; enum { FORMAT_V1, FORMAT_V2, FORMAT_FDV3, };
static void _show_page() { // PAGE_ShowHeader(_tr_noop("Trim")); // no title for devo10 GUI_CreateLabelBox(&gui->inputlbl, 0, 0, TEXTSEL_X, HEADER_HEIGHT, &TITLE_FONT, GUI_Localize, NULL, _tr_noop("Input")); GUI_CreateLabelBox(&gui->steplbl, TEXTSEL_X, STEP_Y, TRIMPOS_X - TEXTSEL_X, LINE_HEIGHT, &TITLE_FONT, GUI_Localize, NULL, _tr_noop("Step")); // no enought space in Devo10, so just display trim + in the 1st page GUI_CreateLabelBox(&gui->trimposlbl, TRIMPOS_X, STEP_Y, LCD_WIDTH - TRIMPOS_X, LINE_HEIGHT, &TITLE_FONT, GUI_Localize, NULL, _tr_noop("Trim +")); GUI_CreateScrollable(&gui->scrollable, 0, HEADER_HEIGHT, LCD_WIDTH, LCD_HEIGHT - HEADER_HEIGHT, LINE_SPACE, NUM_TRIMS, row_cb, getobj_cb, NULL, NULL); PAGE_SetScrollable(&gui->scrollable, ¤t_selected); }