/* Never returns */ void led_flash (int led_pattern1, int led_pattern2) { while (1) { set_leds (led_pattern1); sleep(HZ/2); clear_leds (led_pattern1); set_leds(led_pattern2); sleep(HZ/2); clear_leds (led_pattern2); } }
void light_led(void) { clear_leds(); if (cur_menu == 0) _LED0 = VCC; else if (cur_menu == 1) _LED1 = VCC; else if (cur_menu == 2) _LED2 = VCC; else if (cur_menu == 3) _LED3 = VCC; else if (cur_menu == 4) _LED4 = VCC; else if (cur_menu == 5) _LED5 = VCC; else if (cur_menu == 6) _LED6 = VCC; else if (cur_menu == 7) _LED7 = VCC; else if (cur_menu == 8) _LED8 = VCC; else if (cur_menu == 9) _LED8 = VCC; }
/* ===================================================================*/ void wheel_StartColumn() { bool finished = FALSE; uint16_t periodOffset; static windowT window; static bool topFromBeginning; surfaceT leftside; switch (wait_mode) { case TO_FIRST: currColumn = 0; if (front) { // front wheel -> upper window is first window = UPPER; // left (standard, TOP on left) // -> display from back (TOP) topFromBeginning = FALSE; // bottom is vice versa } else { // rear wheel -> lower window is first window = LOWER; // left (standard, TOP on left) // -> display from the beginning topFromBeginning = TRUE; // bottom is vice versa } display_column(topFromBeginning, window, currColumn); periodOffset = rotTimerCh0 + columnPeriodTicks; RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); wait_mode = IN_FIRST; break; case IN_FIRST: if (++currColumn >= MAX_COLUMN) { // window finished // set time (delay between) for the second window if (front) { periodOffset = rotTimerCh0 + (rotationTime * (between_front / 360.0)) / TIMER_TICK; } else { periodOffset = rotTimerCh0 + (rotationTime * (between_rear / 360.0)) / TIMER_TICK; } RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); clear_leds(TOPSIDE); write_ledColumn(TOPSIDE); wait_ledColumn(); clear_leds(BOTTOMSIDE); write_ledColumn(BOTTOMSIDE); wait_ledColumn(); wait_mode = TO_SECOND; if (displayMode[TOPSIDE][UPPER] == LIGHT) { wait_mode = NOT_WAITING; } enable_bling[TOPSIDE] = TRUE; enable_bling[BOTTOMSIDE] = TRUE; } else { display_column(topFromBeginning, window, currColumn); // timeout for the next column periodOffset = rotTimerCh0 + columnPeriodTicks; RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); } break; case TO_SECOND: currColumn = 0; if (front) { // front wheel -> bottom window is second window = LOWER; // left (standard, TOP on left) // -> display from the beginning topFromBeginning = TRUE; // bottom is vice versa } else { // rear wheel -> top window is second window = UPPER; // left (standard, TOP on left) // -> display from back (TOP) topFromBeginning = FALSE; // bottom is vice versa } display_column(topFromBeginning, window, currColumn); // timeout for the next column periodOffset = rotTimerCh0 + columnPeriodTicks; RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); wait_mode = IN_SECOND; break; case IN_SECOND: if (++currColumn >= MAX_COLUMN) { // window finished RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, 0xffff); clear_leds(TOPSIDE); write_ledColumn(TOPSIDE); wait_ledColumn(); clear_leds(BOTTOMSIDE); write_ledColumn(BOTTOMSIDE); wait_ledColumn(); wait_mode = NOT_WAITING; enable_bling[TOPSIDE] = TRUE; enable_bling[BOTTOMSIDE] = TRUE; } else { display_column(topFromBeginning, window, currColumn); // timeout for the next column periodOffset = rotTimerCh0 + columnPeriodTicks; RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); } break; case NOT_WAITING: break; } }
/* ===================================================================*/ void set_Mode() { windowT win; operating_mode = MODE_BUTTON; clear_leds(TOPSIDE); LEDred_SetVal(); LEDgreen_SetVal(); LEDblue_SetVal(); // button pressed while (! ButtonReleased) { // wait till button released wait_10ms(2); } if (ButtonLongPressed) { ButtonLongPressed = FALSE; // toggle low energy mode if (energy_mode == ENERGY_LOW || energy_mode == ENERGY_ALWAYS_ON) { if (energy_mode == ENERGY_LOW) { energy_mode = ENERGY_STANDARD; } set_led(TOPSIDE, LED1, WHITE); LEDred_ClrVal(); LEDgreen_ClrVal(); LEDblue_ClrVal(); oled_setState(OLED_ON); } else { energy_mode = ENERGY_LOW; set_led(TOPSIDE, LED1, YELLOW); LEDred_ClrVal(); LEDgreen_ClrVal(); oled_setState(OLED_OFF); } write_ledColumn(TOPSIDE); wait_10ms(100); clear_leds(TOPSIDE); LEDred_SetVal(); LEDgreen_SetVal(); LEDblue_SetVal(); write_ledColumn(TOPSIDE); wait_ledColumn(); ButtonReleased = FALSE; ButtonPressed = FALSE; ButtonLongPressed = FALSE; } else { // start/stop trip ButtonPressed = FALSE; ButtonReleased = FALSE; if (tripMode == TRIP_STOPPED) { // stopped -> start trip tripMode = TRIP_STARTED; chronoMode = TRIP_STARTED; set_led(TOPSIDE, LED1, GREEN); LEDgreen_ClrVal(); } else { // started (or paused) -> stop trip tripMode = TRIP_STOPPED; chronoMode = TRIP_STOPPED; set_led(TOPSIDE, LED1, RED); LEDred_ClrVal(); // save the configuration and data set_params(); save_params(); } write_ledColumn(TOPSIDE); wait_10ms(100); if (ButtonPressed) { // reset trip set_led(TOPSIDE, LED1, BLUE); LEDblue_ClrVal(); LEDred_SetVal(); LEDgreen_SetVal(); write_ledColumn(TOPSIDE); tripDistance = 0.0; maxSpeed = 0.0; avgSpeed = 0.0; tripElevationGain = 0.0; maxAltitude = 0.0; chronoTime = 0.0; tripTime = 0.0; while (! ButtonReleased) { // wait till button released wait_10ms(2); } ButtonPressed = FALSE; ButtonReleased = FALSE; ButtonLongPressed = FALSE; wait_10ms(100); } clear_leds(TOPSIDE); write_ledColumn(TOPSIDE); wait_ledColumn(); } operating_mode = NORMAL; }
int main(void) { unsigned char* loadbuffer; int buffer_size; int rc; int(*kernel_entry)(void); led_init(); clear_leds(LED_ALL); /* NB: something in system_init() prevents H-JTAG from downloading */ /* system_init(); */ kernel_init(); /* enable_interrupt(IRQ_FIQ_STATUS); */ backlight_init(); lcd_init(); lcd_setfont(FONT_SYSFIXED); button_init(); dma_init(); uart_init(); uart_init_device(DEBUG_UART_PORT); /* mini2440_test(); */ /* Show debug messages if button is pressed */ int touch_data; if(button_read_device(&touch_data) & BUTTON_MENU) verbose = true; printf("Rockbox boot loader"); printf("Version " RBVERSION); rc = storage_init(); if(rc) { reset_screen(); error(EATA, rc, true); } disk_init(IF_MD(0)); rc = disk_mount_all(); if (rc<=0) { error(EDISK,rc, true); } printf("Loading firmware"); /* Flush out anything pending first */ commit_discard_idcache(); loadbuffer = (unsigned char*) 0x31000000; buffer_size = (unsigned char*)0x31400000 - loadbuffer; rc = load_firmware(loadbuffer, BOOTFILE, buffer_size); if(rc <= 0) error(EBOOTFILE, rc, true); printf("Loaded firmware %d\n", rc); /* storage_close(); */ system_prepare_fw_start(); commit_discard_idcache(); kernel_entry = (void*) loadbuffer; rc = kernel_entry(); /* end stop - should not get here */ led_flash(LED_ALL, LED_NONE); while (1); /* avoid warning */ }
void set_state(LpState st, u8 setup) { if (lp_state == st && flag_is_set(lp_flags, LP_IS_SETUP) == setup) { return; } if (lp_state == LP_SESSION_MODE) { if (flag_is_set(lp_flags, LP_IS_SETUP)) { session_setup_become_inactive(); } else { session_mode_become_inactive(); } } else if (lp_state == LP_NOTES_MODE) { if (flag_is_set(lp_flags, LP_IS_SETUP)) { notes_setup_become_inactive(); } else { notes_mode_become_inactive(); } } else if (lp_state == LP_SEQUENCER_MODE) { if (flag_is_set(lp_flags, LP_IS_SETUP)) { sequencer_setup_become_inactive(); } else { sequencer_mode_become_inactive(); } } else if (lp_state == LP_USER_MODE) { if (flag_is_set(lp_flags, LP_IS_SETUP)) { user_setup_become_inactive(); } else { user_mode_become_inactive(); } } clear_leds(); if (st == LP_SESSION_MODE) { plot_pad(LP_SESSION, number_colors[LP_SESSION_MODE]); if (setup) { session_setup_become_active(); plot_setup(on_color); session_setup_draw(); } else { session_mode_become_active(); plot_setup(number_colors[LP_SESSION_MODE]); session_mode_draw(); } } else if (st == LP_NOTES_MODE) { plot_pad(LP_NOTE, number_colors[LP_NOTES_MODE]); if (setup) { notes_setup_become_active(); plot_setup(on_color); notes_setup_draw(); } else { notes_mode_become_active(); plot_setup(number_colors[LP_NOTES_MODE]); notes_mode_draw(); } } else if (st == LP_SEQUENCER_MODE) { plot_pad(LP_DEVICE, number_colors[LP_SEQUENCER_MODE]); if (setup) { sequencer_setup_become_active(); plot_setup(on_color); sequencer_setup_draw(); } else { sequencer_mode_become_active(); plot_setup(number_colors[LP_SEQUENCER_MODE]); sequencer_mode_draw(); } } else if (st == LP_USER_MODE) { plot_pad(LP_USER, number_colors[LP_USER_MODE]); if (setup) { user_setup_become_active(); plot_setup(on_color); user_setup_draw(); } else { user_mode_become_active(); plot_setup(number_colors[LP_USER_MODE]); user_mode_draw(); } } sequencer_play_draw(&lp_sequencer); lp_state = st; lp_flags = assign_flag(lp_flags, LP_IS_SETUP, setup); }