void debug_buttons() { u32 data = ScanButtons(); while(1) { u32 val = ScanButtons(); u32 delta = val ^ data; for(int i = 1; i < BUT_LAST; i++) { if(delta & (1 << (i-1))) { printf("%s(%s) ", INPUT_ButtonName(i), (val &(1 << (i-1)))? "Down" : "Up"); } } if (delta) { printf("\n"); data = val; } if(PWR_CheckPowerSwitch()) PWR_Shutdown(); } }
void BUTTON_Handler() { static u32 last_buttons = 0; static u32 last_buttons_pressed = 0; static u32 long_press_at = 0; static u8 longpress_release = 0; static u32 last_button_time = 0; u32 ms = CLOCK_getms(); //debounce if (ms < last_button_time) return; u32 buttons = ScanButtons(); u32 buttons_pressed= buttons & (~last_buttons); u32 buttons_released=(~buttons) & last_buttons; if (buttons != last_buttons) last_button_time = ms; if(buttons_pressed && !longpress_release) { //printf("pressed: %08d\n", buttons_pressed); AUTODIMMER_Check(); exec_callbacks(buttons_pressed, BUTTON_PRESS); last_buttons_pressed = buttons_pressed; long_press_at = ms+500; longpress_release = 0; interrupt_longpress = 0; } if(buttons_released) { //printf("release: %08d\n", buttons_released); interrupt_longpress = 0; longpress_release = 0; if(!longpress_release) { exec_callbacks(buttons_released, BUTTON_RELEASE); } else { exec_callbacks(buttons_released, BUTTON_RELEASE | BUTTON_HAD_LONGPRESS); } } if(buttons && (buttons == last_buttons) && !interrupt_longpress) { if(ms > long_press_at) { //printf("long_press: %08d\n", buttons_released); exec_callbacks(last_buttons_pressed, BUTTON_LONGPRESS); longpress_release=1; long_press_at += 100; } } last_buttons=buttons; }
static void wait_release() { printf("Wait Release\n"); while(1) { CLOCK_ResetWatchdog(); u32 buttons = ScanButtons(); if (! CHAN_ButtonIsPressed(buttons, BUT_ENTER)) break; if(PWR_CheckPowerSwitch()) PWR_Shutdown(); } printf("Released\n"); }
int main() { Init(); #ifndef MODULAR //Banner(); #endif if(PWR_CheckPowerSwitch()) PWR_Shutdown(); LCD_Clear(0x0000); #ifdef TEST_ADC ADC_ScanChannels(); while(1); #endif u32 buttons = ScanButtons(); if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) { LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT); USB_Connect(); LCD_Clear(0x0000); FS_Mount(NULL, NULL); } CONFIG_LoadTx(); SPI_ProtoInit(); CONFIG_ReadDisplay(); CONFIG_ReadModel(CONFIG_GetCurrentModel()); CONFIG_ReadLang(Transmitter.language); BACKLIGHT_Brightness(Transmitter.backlight); LCD_Contrast(Transmitter.contrast); LCD_SetFont(DEFAULT_FONT.font); LCD_SetFontColor(DEFAULT_FONT.font_color); #if !HAS_EXTENDED_AUDIO // If Extended Audio is present, move startup msg to Splash page to allow additional audio hardware initialization time MUSIC_Play(MUSIC_STARTUP); #else if (Transmitter.splash_delay < 5) MUSIC_Play(MUSIC_STARTUP); // if no splash page startup msg is used force playing here #endif GUI_HandleButtons(1); MIXER_Init(); PAGE_Init(); CLOCK_StartWatchdog(); #if HAS_DATALOG DATALOG_Init(); #endif priority_ready = 0; CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC); CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC); // We need to wait until we've actually measured the ADC before proceeding while(! (priority_ready & (1 << LOW_PRIORITY))) ; //Only do this after we've initialized all channel data so the saftey works PROTOCOL_InitModules(); GUI_DrawScreen(); #ifdef HAS_EVENT_LOOP start_event_loop(); #else while(1) { if(priority_ready) { EventLoop(); } //This does not appear to have any impact on power //and has been disabled in common/devo/power.c //but it helps a huge amount for the emulator PWR_Sleep(); } #endif }
static void show_button_page() { // show elements where they are located on the real tx enum { OFFSET_X = ((LCD_WIDTH - 320) / 2), // center on Devo12-screen OFFSET_Y = ((LCD_HEIGHT - 240) / 2), }; enum {X = 0, Y = 1}; struct LabelDesc alignRight = { .font = DEFAULT_FONT.font, .align = ALIGN_RIGHT, .font_color = DEFAULT_FONT.font_color, .fill_color = DEFAULT_FONT.fill_color, .outline_color = DEFAULT_FONT.outline_color }; const int label_pos[NUM_TX_BUTTONS][2] = CHANTEST_BUTTON_PLACEMENT; cp->is_locked = 3; GUI_CreateLabelBox(&gui->lock, OFFSET_X, 34, 320, 20, &NARROW_FONT, lockstr_cb, NULL, NULL); for (int i = 0; i < NUM_TX_BUTTONS; i++) { if ((1 << (i + 1)) & Transmitter.ignore_buttons) continue; GUI_CreateLabelBox(&gui->value[i], OFFSET_X + (label_pos[i][X] > 0 ? label_pos[i][X] + 50 : -label_pos[i][X] -20), // >0? box at left side of label, otherwise right OFFSET_Y + label_pos[i][Y], 16, 16, &SMALLBOX_FONT, NULL, NULL, (void *)""); GUI_CreateLabelBox(&gui->chan[i], OFFSET_X + abs(label_pos[i][X]), // no differencing for the label OFFSET_Y + label_pos[i][Y], 48, 16, label_pos[i][X] > 0 ? &alignRight : &DEFAULT_FONT, button_str_cb, NULL, (void *)(long)i); } } void _handle_button_test() { if (cp->is_locked == 0 && SPITouch_IRQ()) { BUTTON_RegisterCallback(&cp->action, 0xFFFFFFFF, BUTTON_PRESS | BUTTON_RELEASE | BUTTON_LONGPRESS | BUTTON_PRIORITY, button_capture_cb, NULL); GUI_Redraw(&gui->lock); //Textbox cp->is_locked++; } else if (cp->is_locked == 1 && ! SPITouch_IRQ()) { cp->is_locked++; } else if (cp->is_locked == 2 && SPITouch_IRQ()) { BUTTON_UnregisterCallback(&cp->action); GUI_Redraw(&gui->lock); //Textbox cp->is_locked++; } else if (cp->is_locked == 3 && ! SPITouch_IRQ()) { cp->is_locked = 0; } u32 buttons = ScanButtons(); for (int i = 0; i < NUM_TX_BUTTONS; i++) { GUI_SetLabelDesc(&gui->value[i], CHAN_ButtonIsPressed(buttons, i+1) ? &SMALLBOXNEG_FONT : &SMALLBOX_FONT); } return; } static inline guiObject_t *_get_obj(int chan, int objid) { return objid == ITEM_GRAPH ? (guiObject_t *)&gui->bar[chan] : (guiObject_t *)&gui->value[chan]; } static const char *channum_cb(guiObject_t *obj, const void *data) { (void)obj; int disp = (long)data; int ch = get_channel_idx(cur_row * NUM_BARS_PER_ROW + disp); if (cp->type) { char *p = tempstring; if (disp & 0x01) { *p = '\n'; p++; } CONFIG_EnableLanguage(0); //Disable translation because tiny font is limited in character set INPUT_SourceName(p, ch+1); CONFIG_EnableLanguage(1); if (! (disp & 0x01)) { sprintf(p + strlen(p), "\n"); } } else { ch -= NUM_INPUTS; if (ch < NUM_OUT_CHANNELS) { sprintf(tempstring, "\n%d", ch+1); } else { ch -= NUM_OUT_CHANNELS; if (Model.virtname[ch][0]) { tempstring_cpy(Model.virtname[ch]) ; } else { sprintf(tempstring, "%s%d", _tr("Virt"), ch+1); } } } return tempstring; }
int main() { Init(); #ifndef MODULAR //Banner(); #endif if(PWR_CheckPowerSwitch()) PWR_Shutdown(); LCD_Clear(0x0000); #ifdef TEST_ADC ADC_ScanChannels(); while(1); #endif u32 buttons = ScanButtons(); if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) { LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT); USB_Connect(); LCD_Clear(0x0000); FS_Mount(NULL, NULL); } CONFIG_LoadTx(); SPI_ProtoInit(); CONFIG_ReadDisplay(); CONFIG_ReadModel(CONFIG_GetCurrentModel()); CONFIG_ReadLang(Transmitter.language); BACKLIGHT_Brightness(Transmitter.brightness); LCD_Contrast(Transmitter.contrast); LCD_SetFont(DEFAULT_FONT.font); LCD_SetFontColor(DEFAULT_FONT.font_color); MUSIC_Play(MUSIC_STARTUP); GUI_HandleButtons(1); MIXER_Init(); PAGE_Init(); CLOCK_StartWatchdog(); #if DATALOG_ENABLED DATALOG_Init(); #endif priority_ready = 0; CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC); CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC); // We need to wait until we've actually measured the ADC before proceeding while(! (priority_ready & (1 << LOW_PRIORITY))) ; //Only do this after we've initialized all channel data so the saftey works PROTOCOL_Init(0); GUI_DrawScreen(); #ifdef HAS_EVENT_LOOP start_event_loop(); #else while(1) { if(priority_ready) { EventLoop(); } //PWR_Sleep(); //This does not appear to have any impact on power } #endif }
int main() { Init(); #ifndef ENABLE_MODULAR //Banner(); #endif if(PWR_CheckPowerSwitch()) PWR_Shutdown(); LCD_Clear(0x0000); #ifdef TEST_ADC ADC_ScanChannels(); while(1); #endif u32 buttons = ScanButtons(); if (CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Init()) { LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT); USB_Connect(); LCD_Clear(0x0000); FS_Init(); } CONFIG_LoadTx(); SPI_ProtoInit(); CONFIG_ReadDisplay(); CONFIG_ReadModel(CONFIG_GetCurrentModel()); CONFIG_ReadLang(Transmitter.language); BACKLIGHT_Brightness(Transmitter.backlight); LCD_Contrast(Transmitter.contrast); LCD_SetFont(DEFAULT_FONT.font); LCD_SetFontColor(DEFAULT_FONT.font_color); GUI_HandleButtons(1); MIXER_Init(); PAGE_Init(); CLOCK_StartWatchdog(); #if HAS_DATALOG DATALOG_Init(); #endif priority_ready = 0; CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC); CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC); // We need to wait until we've actually measured the ADC before proceeding while(! (priority_ready & (1 << LOW_PRIORITY))) PWR_Sleep(); //Only do this after we've initialized all channel data so the saftey works PROTOCOL_InitModules(); GUI_DrawScreen(); // Add startup delay to make sure audio player is initialized // AUDIO_Init() has already been called by CONFIG_ReadModel() #if HAS_EXTENDED_AUDIO audio_queue_time = CLOCK_getms() + 1500; num_audio=1; next_audio=1; #if (LCD_WIDTH == 480) || (LCD_WIDTH == 320) if(Display.background.drawn_background) while(CLOCK_getms() < audio_queue_time - 1200); #endif AUDIO_SetVolume(); // Initial setting of voice volume #endif MUSIC_Play(MUSIC_STARTUP); #ifdef HAS_EVENT_LOOP start_event_loop(); #else while(1) { if(priority_ready) { EventLoop(); } //This does not appear to have any impact on power //and has been disabled in common/devo/power.c //but it helps a huge amount for the emulator PWR_Sleep(); } #endif }