Exemplo n.º 1
0
//проверка кнопок и энкодера
inline void button_check(TActElements name, TActions encact) {
    if(name != NM_NONE) { //нажали кнопку

        if(name != g_button_state.name) {

            button_init();
            g_button_state.name = name;

        } else {
            g_button_state.release = 0;
        }

        if(name != NM_ENCROTATE) {
            button_check_press();
        }
        else {
            encoder_check_rotate(encact);
        }
    }
    else if(g_button_state.on == _ON) {
        //отпустили кнопень
        if(g_button_state.release >= BUTTON_RELEASE) {
            button_init();
        }
        else {
            g_button_state.release ++;
        }
    }
}
Exemplo n.º 2
0
void init_platform() {
	button_init(&select_btn, PIN_PA14);
	button_init(&down_btn, PIN_PA15);
	device.speed = 255;
	device.inclination = 255;
	
	gfx_mono_init();
	ssd1306_init();
	configure_tc_cadence();
	cadence_sensor_init();
	
	
	// The page address to write to
	uint8_t page_address = 0;
	// The column address, or the X pixel.
	uint8_t column_address = 0;
	
	ssd1306_clear_buffer();
	gfx_mono_draw_string("Accelerometer",1, 18, &sysfont);
	gfx_mono_draw_string("Setup",37, 32, &sysfont);
	ssd1306_write_display();
	
	gfx_mono_active_menu = SPEED_VIEW;
	
}
Exemplo n.º 3
0
int main(void)
{
	sched_init(); /* initialize the scheduler */
	led_init(); /* initialize led */
	button_init(); /* initialize button */
	adc_init(); /* initialize ADC (battery voltage measurement) */
	serial_init(); /* initialize serial communication */
	wheel_init(); /* initialize encoders, PWM output, PID etc. */
	pid_interval = 50; /* default PID update interval 50ms */ 
	pid_rate = 1000/pid_interval; /* [Hz] always remember after setting pid_interval */
	pfbst_interval = 20; /* send $PFBST at 20 ms interval */
	nmea_wd_timeout = 1; /* set PFBCT watchdog timeout to 100ms */
	nmea_wd = NMEA_WD_TOUT+1; /* make sure we begin in watchdog timeout state */
	voltage_min = VOLTAGE_MIN_DEFAULT;
	battery_low_warning = false;
	state_update();
	sei(); /* enable interrupts */
	nmea_init(); /* initialize nmea protocol handler */

	for (;;) /* go into an endless loop */
	{
		/* motor_update(); */

		if (t1ms != 0) /* if the interrupt has timed out after 10ms */
		{
			t1ms --;
			sched_update(); /* run the scheduler */
		}
		else
		{
			nmea_rx_update();
		}
	}
	return 0; /* just for the principle as we never get here */
}
Exemplo n.º 4
0
bool usb_cb_set_configuration(uint8_t config) {
	if (config <= 1) {
		button_init();
		return true;
	}
	return false;
}
Exemplo n.º 5
0
void system_init()
{
	system_watchdog_timer_stop();

	 // Init all ports
	 PADIR = 0xFF;
	 PAOUT = 0x00;
	 PBDIR = 0xFF;
	 PBOUT = 0x00;
	 PCDIR = 0xFF;
	 PCOUT = 0x00;

    //PMM_setVCore(PMMCOREV_2);
    PMM_SetVCore(2);

    PMM_SetStdSVSM(0x8088, 2, 4);

    clock_init();

    led_init();
    button_init();
    uart_init();

    system_get_unique_id(device_id);
}
Exemplo n.º 6
0
//The setup function is called once at startup of the sketch
void setup()
{
	// Add your initialization code here
	// Note : This will initialize Serial port on Arduino at 115200 bauds
	OC_LOG_INIT();
	OC_LOG(DEBUG, TAG, ("Demoserver is starting..."));

	// Connect to Ethernet or WiFi network
	if (ConnectToNetwork() != 0) {
		OC_LOG(ERROR, TAG, ("Unable to connect to network"));
		return;
	}

	// Initialize the OC Stack in Server mode
	if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) {
		OC_LOG(ERROR, TAG, ("OCStack init error"));
		return;
	}

	// Initialize Grove related Devices
	sensor_init();
	led_init();
	lcd_init();
	buzzer_init();
	button_init();

	// Declare and create the resource: grove
	createDemoResource();
}
Exemplo n.º 7
0
int main()
{	
	unsigned int adc;
	float vol;
	int n;
	
	copy_vec();
	irq_init();
	button_init();
	uart0_init();
	timer_init();
//	timer4_init();

	lcd_init();
	lcd_clean(0xffff);
	adc_ts_init();
	ts_init();
	while(1);

	while(1)
	{
		adc = read_adc(0);
		vol = adc * 3.3 / 0x3ff;
		n = (vol - (int)vol) * 1000;
		
		printf("AIN0: adc = %u	voltage:%d.%03d\r\n", adc, (int)vol, n);
		delayms(1000);
	}
	
	return 0;
}
Exemplo n.º 8
0
/** \brief This is the task function for monitoring the button and joysticks.
 *  \details This function monitors the "Target Set" button, and when it is pressed,
 *  updates shared variables "motor1_power_SHARED", and "motor2_power_SHARED" with adc_channel
 *  readings. If the button is NOT pressed, the motor power shareds are set to the effective
 *  "zero power" value of 512.(1024 adc values corresponding to full forward(1023), and
 *  full reverse(0);
 */
void task_sensors(void* pvParameters){
	uint8_t default_sensor_prio = uxTaskPriorityGet(NULL);
	portTickType xLastWakeTime;
    xLastWakeTime = xTaskGetTickCount();
    adc_init();
    uint16_t joystick_y;
    uint16_t joystick_x;
    button_init();
       
    while(1)
    {
        if(button_pressed()){
            joystick_y = adc_read(ADC_JOYSTICK_Y);
            joystick_x = adc_read(ADC_JOYSTICK_X);
            vTaskPrioritySet(NULL, configMAX_PRIORITIES - 1);
    	        motor1_power_SHARED = joystick_y;
    	        motor2_power_SHARED = joystick_x;
    	    vTaskPrioritySet(NULL, default_sensor_prio);
    	}
    	else{
	    vTaskPrioritySet(NULL, configMAX_PRIORITIES - 1);
    	        motor1_power_SHARED = 512;
    	        motor2_power_SHARED = 512;
    	    vTaskPrioritySet(NULL, default_sensor_prio);
	    }
    	vTaskDelayUntil(&xLastWakeTime, 100/portTICK_RATE_MS);
    }

	
}
Exemplo n.º 9
0
/**
 * @brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;

    //Initialize.
    app_trace_init();
    leds_init();
    scheduler_init();
    timers_init();
    iot_timer_init();
    button_init();
    ble_stack_init();
    advertising_init();
    ip_stack_init ();

    //Start execution.
    advertising_start();

    //Enter main loop.
    for (;;)
    {
        //Execute event schedule.
        app_sched_execute();

        //Sleep waiting for an application event.
        err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
    }
}
Exemplo n.º 10
0
int
main()
{
  Button button;

  struct counter_data data = {
    (ShiftRegister){12, 10, 11},
    0
  };

  shift_register_init(&data.reg);
  shift_register_set(&data.reg, 1);
  button_init(&button);

  button.pin = 7;
  button.closed_on = LOW;
  button.debounce_delay = 10;
  button.hold_delay = 250;
  button.toggle_callback = &toggled;
  button.hold_callback = &hold;
  button.data = &data;

  pin_set_mode(7, INPUT);
  pin_set_value(7, PULLUP); // enable the internal pull-up resistor

  while(true) {
    button_check(&button);
    delay_ms(1); // TODO do not depend on delaying
  }

  return 0;
}
Exemplo n.º 11
0
void init_platform( void )
{
  button_init_t init;

  MicoGpioInitialize( (mico_gpio_t)MICO_SYS_LED, OUTPUT_PUSH_PULL );
  MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
  MicoGpioInitialize( (mico_gpio_t)MICO_RF_LED, OUTPUT_OPEN_DRAIN_NO_PULL );
  MicoGpioOutputHigh( (mico_gpio_t)MICO_RF_LED );
  
  MicoGpioInitialize((mico_gpio_t)BOOT_SEL, INPUT_PULL_UP);
  MicoGpioInitialize((mico_gpio_t)MFG_SEL, INPUT_PULL_UP);

  init.gpio = EasyLink_BUTTON;
  init.pressed_func = PlatformEasyLinkButtonClickedCallback;
  init.long_pressed_func = PlatformEasyLinkButtonLongPressedCallback;
  init.long_pressed_timeout = 5000;

  button_init( IOBUTTON_EASYLINK, init );
  
#ifdef USE_MiCOKit_EXT
  dc_motor_init( );
  dc_motor_set( 0 );
  
  rgb_led_init();
  rgb_led_open(0, 0, 0);
#endif
}
void init_all(){
	ticks_init(); // for delay_ms() and for time sync
	button_init();	//init button
	led_init();		//init led
	tft_init(0, WHITE, BLACK, RED);		//initialize LCD screen
	xbc_init(0);	//initialize Xbox controller
}
Exemplo n.º 13
0
/* This function is meant to contain board-specific initialization code
 * for, e.g., the I/O pins. The initialization can rely on application-
 * specific board configuration, found in conf_board.h.
 */
void v2x_board_init(void)
{
	irq_initialize_vectors();
	pmic_init();
	sysclk_init();							//configure clock sources for core and USB
	sleepmgr_init();						// Initialize the sleep manager
	ioport_init();							//Initializes the IOPORT service
	pin_init();								//whole chip pin init, modes and initial conditions
	spi_start();							//start SPI driver
	PWR_init();								//sets SR to default states - holds power up
	cpu_irq_enable();
	eeprom_init();							//verifies eeprom safe for use
	menu_init();							//loads menu settings
	time_init();							//starts the RTC
	button_init();							//init button stuffs
	ACL_init();								//configures, but does not start sampling
	GSM_usart_init();						//starts direct serial channel to the SIM module
	CAN_uart_start();						//starts direct serial channel to the ELM module
	canbus_serial_routing(AVR_ROUTING);		//cause the serial 3-state buffer to route the serial path from the ELM to the FTDI 
	udc_start();							//start stack and vbus monitoring
	PWR_hub_start();						//connect the hub to the computer

	//autostart all systems
	delay_ms(500);
	GSM_modem_init();
	CAN_elm_init();
	ACL_set_sample_on();
	PWR_host_start();
}
void system_init()
{
	 system_watchdog_timer_stop();

    PMM_SetVCore(vCore_level);

    PMM_SetStdSVSM(0x8088, 2, 4);

    clock_init();

    if (init_IO)
    {
    	// Init all ports
		PADIR = 0xFF;
		PAOUT = 0x00;
		PBDIR = 0xFF;
		PBOUT = 0x00;
		PCDIR = 0xFF;
		PCOUT = 0x00;

    	led_init();
    	button_init();
    	uart_init();
    }

    system_get_unique_id(device_id);
}
Exemplo n.º 15
0
Arquivo: main.c Projeto: zonbrisad/LEF
/**
 * Initiate hardware peripherials.
 */
void init_hw() {

  ARD_LED_INIT();                   // init arduino LED port

  uart_init(UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU));		// init uarts

	stdout = &mystdio;                // configure stdout to UART 0

	TIMER0_PRES_1024();               // set prescaler of timer 0
	TIMER0_OVF_IE();                  // enable overflow interrupt of timer 0
	TIMER0_RELOAD(TIMER0_10MS);       // reload counter of timer 0

	TIMER1_PRES_1024();               // set prescaler of timer 1
	TIMER1_OVF_IE();                  // enable overflow interrupt of timer 1
	TIMER1_RELOAD(TIMER1_CNT);        // reload counter of timer 1


  but.port = &PINB;                 // initiate button
  but.bit  = PB4;
  button_init(&but, &PORTB);

  LEF_TimerInit(&eTimer1);
  LEF_TimerInit(&eTimer2);
  LEF_TimerInit(&eTimer3);
  LEF_TimerStartRepeat(&eTimer1, 100);  // set as 100 ticks repeating timer
  LEF_TimerStartRepeat(&eTimer2, 200);  // set as 100 ticks repeating timer

  sev_cmd_init(cmdTable);

	sei();														// enable interrupts
}
Exemplo n.º 16
0
int main()
{
    pic_init();
    logging_init();
    button_init();
    bumper_init();
    pwm_init();
    motor_timer_init();
    button_timer_init();
    sound_config_timer_init();

    //put_str_ln("Initialising DMA...");
    //init_DMA();

    //put_str_ln("Initialising ADC...");
    init_ADC();

    // setup des interrupts
    INTCONSET = _INTCON_MVEC_MASK;
    __builtin_enable_interrupts();

    if (VERBOSE_PIC_STATUS)
        put_str_ln("Ready.");

    while (1)
    {
        WDTCONbits.WDTCLR = 1;  // ecrire un 1 dans ce bit force la reinitialisation du watchdog
    }
}
Exemplo n.º 17
0
int
main (void)
{
    led_t led1;
    button_t button1;

    /* Initialise LED.  */
    led1 = led_init (&led1_cfg);

    /* Turn on LED.  */
    led_set (led1, 1);

    /* Initialise button.  */
    button1 = button_init (&button1_cfg);

    button_poll_count_set (BUTTON_POLL_COUNT (BUTTON_POLL_RATE));

    pacer_init (BUTTON_POLL_RATE);

    while (1)
    {
        pacer_wait ();

        button_poll (button1);

        if (button_pushed_p (button1))
        {
            /* Turn off LED.  */
            led_set (led1, 0);        

            sleep_setup ();
        }
    }
    return 0;
}
Exemplo n.º 18
0
void uos_init (void)
{
        led_init();
	button_init ();
	timer_init (&timer, KHZ, 10);
	lcd_init (&line1, &line2, &timer);
	task_create (poll_buttons, 0, "poll", 1, task, sizeof (task));
}
Exemplo n.º 19
0
task_t *task_init(void)
{
	gpio_dev_init(&gpio_b, &GPIOB);
	gpio_b.init(&gpio_b, &_PORTB, 0, 1);
	button = button_init(1);
	task.run = task_run;
	return &task;
}
Exemplo n.º 20
0
void model_contral_init(void)
{
  button_init();
  screen_is_on = 1;
  model = COUNT_MODEL;
  two_click_function_point = NULL;
  
  model_change();
}
Exemplo n.º 21
0
si_t save_as_button_callback(void* btn, void* msg)
{
    union message* m = (union message*)msg;
	struct button* b = NULL;
	switch(m->base.type)
	{
	case MESSAGE_TYPE_MOUSE_SINGLE_CLICK:
		if(NULL == save_window)
		{
			save_window = window_init("save window");
            /* 申请失败 */
            if(NULL == main_window)
            {
				EGUI_PRINT_ERROR("failed to init save window");
				application_exit();
                return -1;
            }
			window_set_bounds(save_window, main_window->area.x + 30, main_window->area.y + 30, 300, 60);
			window_set_color(save_window, NULL, &barely_blue);

			save_text_line = text_line_init(FILE_MAX, 0);
			if(NULL == save_text_line)
			{
				EGUI_PRINT_ERROR("failed to init save_text_line on save window");
				application_exit();
				return -1;
			}
			text_line_set_bounds(save_text_line, 5, 5, 230, 50);
			text_line_set_placeholder(save_text_line, "input file name");
			text_line_set_color(save_text_line, &dark_blue, NULL, &light_green);

			b = button_init("ok");
			if(NULL == b)
			{
				EGUI_PRINT_ERROR("failed to init ok button on save window");
				application_exit();
				return -1;
			}
			button_set_bounds(b, 240, 10, 50, 40);
			button_set_color(b, &dark_blue, &light_green);
			button_set_font(b, FONT_MATRIX_12);
			b->callback = save_window_ok_button_callback;

			object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(b));
			object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(save_text_line));
			application_add_window(NULL, save_window);
			break;
		}
		else
		{
			EGUI_PRINT_ERROR("save window already open!");
		}
	default:
		button_default_callback(btn, msg);
	}
	return 0;
}
Exemplo n.º 22
0
static void init(void) {
	sysclock_init();
	_delay_ms(100);
	button_init();
	can_init();

	sei();
	puts_P(PSTR("Init complete\n\n"));
}
Exemplo n.º 23
0
int main ()
{
	init_HSI ();
	init_PLL ();
	//encoder_init ();
	segled_init ();
	button_init ();
	tim14_init ();
	buffer (5632);
	
	while (1)
	{
		
		if (flag1==1)
		{
			GPIOA->ODR ^= 1 << 15;
			flag1=0;
		}	
		if (flag1==2)
		{
			NVIC_DisableIRQ(TIM14_IRQn);
			flag_seg ^= 1;	
			flag1=0;
			NVIC_EnableIRQ (TIM14_IRQn);
		}
			if (flag1==3)
		{
			NVIC_DisableIRQ(TIM14_IRQn);
			GPIOA->ODR |= 1 << 15;
			delay_ms (500);
			GPIOA->ODR &= ~(1 << 15);
			delay_ms (500);
			GPIOA->ODR |= 1 << 15;
			delay_ms (500);
			GPIOA->ODR &= ~(1 << 15);
			delay_ms (500);			
			flag1=0;
			NVIC_EnableIRQ (TIM14_IRQn);
		}	
			if (flag1==4)
		{
			NVIC_DisableIRQ(TIM14_IRQn);
			GPIOA->ODR |= 1 << 15;
			delay_ms (1500);
			GPIOA->ODR &= ~(1 << 15);
			delay_ms (1500);
			GPIOA->ODR |= 1 << 15;
			delay_ms (1500);
			GPIOA->ODR &= ~(1 << 15);
			delay_ms (1500);			
			flag1=0;
			NVIC_EnableIRQ (TIM14_IRQn);
		}			
	}
}
Exemplo n.º 24
0
int main (void)
{
    led_init();
    button_init();
    timer_init();
    sei(); /* enable interrupts globally */
    while(true)
    {
        sleep_mode();
    }
}
Exemplo n.º 25
0
int main(void) {
	WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

	led_init();
	button_init();

	while (1) {
		testButton1();
		testButton2();
	}
}
Exemplo n.º 26
0
/**
 * @brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;

    //Initialize.
    app_trace_init();
    leds_init();
    timers_init();
    iot_timer_init();
    button_init();

#ifdef COMMISSIONING_ENABLED
    err_code = pstorage_init();
    APP_ERROR_CHECK(err_code);
#endif // COMMISSIONING_ENABLED

    static ipv6_medium_init_params_t ipv6_medium_init_params;
    memset(&ipv6_medium_init_params, 0x00, sizeof(ipv6_medium_init_params));
    ipv6_medium_init_params.ipv6_medium_evt_handler    = on_ipv6_medium_evt;
    ipv6_medium_init_params.ipv6_medium_error_handler  = on_ipv6_medium_error;
    ipv6_medium_init_params.use_scheduler              = false;
#ifdef COMMISSIONING_ENABLED
    ipv6_medium_init_params.commissioning_id_mode_cb   = commissioning_id_mode_cb;
    ipv6_medium_init_params.commissioning_power_off_cb = commissioning_power_off_cb;
#endif // COMMISSIONING_ENABLED

    err_code = ipv6_medium_init(&ipv6_medium_init_params, \
                                IPV6_MEDIUM_ID_BLE,       \
                                &m_ipv6_medium);
    APP_ERROR_CHECK(err_code);

    eui48_t ipv6_medium_eui48;
    err_code = ipv6_medium_eui48_get(m_ipv6_medium.ipv6_medium_instance_id, \
                                     &ipv6_medium_eui48);

    ipv6_medium_eui48.identifier[EUI_48_SIZE - 1] = 0x00;

    err_code = ipv6_medium_eui48_set(m_ipv6_medium.ipv6_medium_instance_id, \
                                     &ipv6_medium_eui48);
    APP_ERROR_CHECK(err_code);

    ip_stack_init();

    //Start execution.
    connectable_mode_enter();

    //Enter main loop.
    for (;;)
    {
        //Sleep waiting for an application event.
        err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
    }
}
Exemplo n.º 27
0
/*
void adc_init (void)
{
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC1EN);
  rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
  rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);



  gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);	//PA1   joint_1
  gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO2);	//PA2   joint_2
  gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO3);	//PA3   joint_3
  gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);	//PC1   joint_4
  gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO2);	//PC2   joint_5
  gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO5);	//PC5   joint_6

  adc_set_clk_prescale(ADC_CCR_ADCPRE_BY2);
  adc_disable_scan_mode(ADC1);
  adc_set_single_conversion_mode(ADC1);

  adc_set_sample_time(ADC1, ADC_CHANNEL1, ADC_SMPR_SMP_3CYC);   //joint_1
  adc_set_sample_time(ADC1, ADC_CHANNEL2, ADC_SMPR_SMP_3CYC);   //joint_2
  adc_set_sample_time(ADC1, ADC_CHANNEL3, ADC_SMPR_SMP_3CYC);   //joint_3
  adc_set_sample_time(ADC1, ADC_CHANNEL11, ADC_SMPR_SMP_3CYC);  //joint_4
  adc_set_sample_time(ADC1, ADC_CHANNEL12, ADC_SMPR_SMP_3CYC);  //joint_5
  adc_set_sample_time(ADC1, ADC_CHANNEL15, ADC_SMPR_SMP_3CYC);  //joint_6

  adc_set_multi_mode(ADC_CCR_MULTI_INDEPENDENT);
  adc_power_on(ADC1);

  //nvic_enable_irq(NVIC_ADC_IRQ);
  //adc_enable_eoc_interrupt(ADC1);
  //adc_disable_eoc_interrupt(ADC1);
}
*/
void system_init(void) 
{
  rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
  leds_init();
  button_init();
  DTC_SVM_tim_init();
  //adc_init();
  //cdcacm_init();
  //printled(4, LRED);

}
Exemplo n.º 28
0
void init()
{
    srand(0); /* Obviously not a very good seed but useful for testing... */
    memset(&counts, 0, sizeof(counts));
    time_init();
    led_init();
    menu_init();
    button_init();
    enable_leds();
    sei();
}
Exemplo n.º 29
0
void processTWI( void )
{
	uint8_t b,p1,p2;

	b = usiTwiReceiveByte();

	switch (b) {
	case 0x81: // set slave address
		p1 = usiTwiReceiveByte();
		if(p1 < 128) // Address is 7 bit
		{
			eeprom_update_byte(&b_slave_address, p1);
			usiTwiSlaveInit(eeprom_read_byte(&b_slave_address));
		}
		break;
	case 0x82: // clear led
		led_clear();
		break;
	case 0x83: // set led brightness, p1=led, p2=brightness
		p1 = usiTwiReceiveByte();
		p2 = usiTwiReceiveByte();
		set_led_pulse(p1,0); // Turn off pulsing
		set_brightness(p1,p2);
		break;
	case 0x84: // Set to pulse led, p1=led, p2 = (0 = OFF, 1 = ON)
		set_led_pulse(usiTwiReceiveByte(),usiTwiReceiveByte());
		break;
	case 0x85: // Dim up/down led to specific value, p1=led, p2=value to dim to
		dim_led(usiTwiReceiveByte(),usiTwiReceiveByte());
		break;
	case 0x86: // get firmware revision
		usiTwiTransmitByte(FIRMWARE_REVISION);
		break;
	case 0x90: // get keyUp Event
		usiTwiTransmitByte(getKeyUp());
		break;
	case 0x91: // get KeyDown Event
		usiTwiTransmitByte(getKeyDown());
		break;
	case 0x92: // set keyrepeat
		set_keyrepeat(usiTwiReceiveByte(),usiTwiReceiveByte());
		break;
	case 0xFE: // reset to known state
		led_clear();
		button_init();
		flushTwiBuffers();
		break;
	case 0xFF: // flush the bus
		break;
	default:
		break;
	}
}
Exemplo n.º 30
0
si_t pop_window()
{
    switch(save_or_rename_flag)
    {
        case 0:
            save_window = window_init("save_directory_window");
            break;
        case 1:
            save_window = window_init("save_file_window");
            break;
        case 2:
            save_window = window_init("rename_window");
            break;
        default:
            break;
     }
    if(NULL == save_window)
    {
        //EGUI_PRINT_ERROR("failed to init save window");
		application_exit();
        return -1;
    }
    window_set_bounds(save_window,200, 200, 300, 60);
    window_set_color(save_window, NULL, &ground_purple);
    save_text_line = text_line_init(100, 0);
    if(NULL == save_text_line)
    {
        //EGUI_PRINT_ERROR("failed to init save_text_line on save window");
        application_exit();
        return -1;
    }
    text_line_set_bounds(save_text_line, 5, 5, 230, 50);
    text_line_set_placeholder(save_text_line, "input file name");
    text_line_set_color(save_text_line, &heavy_blue, NULL, &heavy_blue );
    save_button = button_init("OK");
    if(NULL == save_button)
	{
	    //EGUI_PRINT_ERROR("failed to init ok button on save window");
        application_exit();
        return -1;
	}
    button_set_bounds(save_button, 240, 10, 50, 40);
    button_set_color(save_button, &ground_purple, &heavy_blue );
    button_set_font(save_button, FONT_MATRIX_12);
	save_button->callback = rename_window_ok_button_callback;
    object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(save_button));
    object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(save_text_line));
    application_add_window(Desktop_w, save_window);
    return 0;

}