Esempio n. 1
0
//select menu state machine
void menu_select() {

  if(menu_state == 1) {
        P1OUT &= ~BIT0;
        send_on_bool = 1;
        MAP_Interrupt_disableInterrupt(INT_ADC14);
        active_bool = 0;
        view_activity_menu();
        state2 = 0;
        menu_state = 6;
  } else if (menu_state == 2) {
        P1OUT |= BIT0;
        send_on_bool = 1;
        steps_taken = 0;
        active_bool = 1;
        MAP_Interrupt_enableInterrupt(INT_ADC14);
        menu_state = 0;
        backlight_off();
  } else if (menu_state == 3) {
        goal_steps = 10;
        set_goal_menu1();
        menu_state = 5;
  } else if (state2) {
        view_activity_menu();
        state2 = 0;
        menu_state = 6;
  } else if (menu_state == 5) {
        send_goal_bool = 1;
        menu_state = 0;
        backlight_off();
  } else if (menu_state == 6) {
        menu_state = 0;
        backlight_off();
  }
}
Esempio n. 2
0
/**
 * \name Main user interface functions
 * @{
 */
void ui_init(void)
{
	/* Initialize LEDs */
	LED_Off(LED0);
	/* Initialize backlight */
	backlight_off();
}
Esempio n. 3
0
//open menu for user
void menu() {

  if(menu_state == 0) {
    menu1();
    state2 = 0;
    menu_state++;
  } else if (menu_state == 1) {
    menu2();
    menu_state++;
  } else if (menu_state == 2) {
    menu3();
    menu_state++;
  } else if (menu_state == 3) {
    menu4();
    menu_state = 0;
    state2 = 4;
  } else if (menu_state == 4) {

  } else if (menu_state == 5) {
    goal_steps+= 10;
    set_goal_menu1();

  } else if (menu_state == 6) {

    //on activity menu
    menu_state = 0;
    backlight_off();

  } else if (menu_state == 7) {

  } else if (menu_state == 4) {

  }

}
Esempio n. 4
0
void ui_powerdown(void)
{
	backlight_stop_pwm();
	backlight_off();
	adc_disable(&LIGHT_SENSOR_ADC_MODULE);
	led_power_off();
}
Esempio n. 5
0
void ui_init(void)
{
	c42048a_init();
	ui_display_text(lcd_welcome,sizeof(lcd_welcome));
	c42048a_set_pixel(ICON_AVR);
	backlight_off();
}
Esempio n. 6
0
void ui_usb_connection_event(uhc_device_t *dev, bool b_present)
{
	UNUSED(dev);
	if (!b_present) {
		LED_On(LED0);
		backlight_off();
		ui_enum_status = UHC_ENUM_DISCONNECT;
	}
}
Esempio n. 7
0
/**
 * \name Main user interface functions
 * @{
 */
void ui_init(void)
{
	/* Initialize LEDs */
	LED_Off(LED0);
	/* Initialize backlight */
	backlight_off();
	/* Initialize Board Monitor */
	bm_init();
	bm_mouse_pointer_ctrl(false);
}
Esempio n. 8
0
int my_handler(struct binder_state *bs, struct binder_transaction_data *txn,
                              struct binder_io *msg, struct binder_io *reply)
{
	printf("[led_service] my_handler\n");

	switch(txn->code)
	{
		case 1: backlight_on(); break;
		case 2: backlight_off(); break;
	}
	return 0;
}
Esempio n. 9
0
void lowlevel_init(void* cur,void * target)
{
#if 0    
	if(cur != target) //r0!=r1
	{
	    //running from spi
    	// take me as a spi rom boot mode
		romboot_info->por_cfg = POR_INTL_SPI |
		    (READ_CBUS_REG(ASSIST_POR_CONFIG)&(~POR_INTL_CFG_MASK));
		romboot_info->boot_id = 0;//boot from spi
		/// Release pull up registers .
	}
#endif	

	power_hold();
	backlight_off();

	//changed by Elvis, add uart rx pull up
	//pull up LINUX_RX(B15--->GPIOE_19) reg (7422y v1.pdf)
	//GPIOE_19(M1-Apps v25- 2010-07-19-BGA372_297-6.xls serach B15)
	WRITE_CBUS_REG( PAD_PULL_UP_REG3, READ_CBUS_REG(PAD_PULL_UP_REG3) & ~(1<<2) );	// Meson-pull-up-down_table.xlsx ( GPIOE_19 is PAD_PULL_UP_REG3---0x203e 2bits)

	//Adjust 1us timer base
	WRITE_CBUS_REG_BITS(PREG_CTLREG0_ADDR,CONFIG_CRYSTAL_MHZ,4,5);
	/*
        Select TimerE 1 us base
    	*/
	clrsetbits_le32(P_ISA_TIMER_MUX,0x7<<8,0x1<<8);
    	memory_pll_init(0,NULL);
	serial_puts("\nFirmware start at: ");
	serial_put_dword(get_timer(0));
#if CONFIG_ENABLE_SPL_DEBUG_ROM
    __udelay(100000);//wait for a uart input 
	if(serial_tstc())
	{
	    debug_rom(__FILE__,__LINE__);
	}
#else
    __udelay(1000);//delay 1 ms , wait pll ready	
#endif	
//	writel((0<<22)|1000000,P_WATCHDOG_TC);//enable Watchdog
	unsigned por_cfg;
#if CONFIG_ENABLE_SPL_DEBUG_ROM	
	if(ddr_init_test())
	    debug_rom(__FILE__,__LINE__);
#else
    do{
    }while(ddr_init_test());

#endif	    
	serial_puts("\nFirmware started, now starting u-boot...");
}
Esempio n. 10
0
void ui_usb_sof_event(void)
{
	bool b_btn_state;
	static bool btn_suspend = false;
	static uint16_t counter_sof = 0;
	static uint16_t counter_sof_move_refresh = 0;

	if (ui_enum_status == UHC_ENUM_SUCCESS) {
		/* Display device enumerated and in active mode */
		if (++counter_sof > ui_device_speed_blink) {
			counter_sof = 0;
			if (ui_hid_mouse_plug || ui_msc_plug) {
				LED_Toggle(LED0);
			} else {
				LED_On(LED0);
			}
			if (ui_test_done && !ui_test_result) {
				/* Test fail then blink BL */
				backlight_toggle();
			}
		}
		/* Scan button to enter in suspend mode and remote wakeup */
		b_btn_state = (!ioport_get_pin_level(GPIO_PUSH_BUTTON_0)) ?
				true : false;
		if (b_btn_state != btn_suspend) {
			/* Button have changed */
			btn_suspend = b_btn_state;
			if (b_btn_state) {
				/* Button has been pressed */
				LED_Off(LED0);
				backlight_off();
				ui_enable_asynchronous_interrupt();
				uhc_suspend(true);
				return;
			}
		}

		/* Move the remote mouse pointer on the Board Monitor screen */
		if (++counter_sof_move_refresh > 100) {
			counter_sof_move_refresh = 0;
			bm_mouse_pointer_move(bm_x / 8, bm_y / 8);
		}

		/* Power on a LED when the mouse button down */
		if (ui_nb_down) {
			LED_On(LED0);
		}
	}
}
Esempio n. 11
0
void init_lcd() {
    TRISBbits.RB7 = 0;
    TRISBbits.RB6 = 0;
    TRISBbits.RB5 = 0;

    TRISAbits.RA0 = 0;
    TRISAbits.RA1 = 0;
    TRISAbits.RA2 = 0;
    TRISAbits.RA3 = 0;

    RS = 0;
    RW = 0;
    E = 0;

    delay_s(1);

    nibble(0x03);
    __delay_ms(5);
    nibble(0x03);
    __delay_ms(5);
    nibble(0x03);
    delay_10us(15);
    nibble(0x02);

    send_command(LCD_FUNCTIONSET | LCD_4BITMODE | LCD_2LINE | LCD_5x8DOTS);
    send_command(LCD_DISPLAYCONTROL | LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF);

    TRISCbits.RC0 = 0;
    backlight_on();

    clear();
    home();

    splash(SPLASH_MSG);

    clear();
    home();

    backlight_off();
}
Esempio n. 12
0
void backlight_stop_pwm()
{
	tc_disable_cc_channels(&BACKLIGHT_TIMER,TC_CCBEN);
	backlight_off();
	tc_disable(&BACKLIGHT_TIMER);
}
Esempio n. 13
0
void main_hid_generic_disable(void)
{
	backlight_off();
	main_b_generic_enable = false;
}
Esempio n. 14
0
void ui_test_flag_reset(void)
{
	backlight_off();
	ui_test_done = false;
}
Esempio n. 15
0
/*
 * Application's entry point dynamic schedule.  Main is somewhat too large because of the MQTT stuff
 * allmighty whileloop
 */
int main(int argc, char** argv)
{

    /* Stop WDT and initialize lcd, clcks, main interfaces */
    stopWDT();
    init_clocks(); //init clock for LCD
    init_lcd();
    initClk(); //init clock for wifi
    Delay(5);
    init_main();
    Delay(5);

    load_data();

    int rc = 0;
    unsigned char buf[100];
    unsigned char readbuf[100];

    NewNetwork(&n);
    rc = ConnectNetwork(&n, MQTT_BROKER_SERVER, 1883);

    if (rc != 0) {
        CLI_Write(" Failed to connect to MQTT broker \n\r");
    }

    MQTTClient(&hMQTTClient, &n, 1000, buf, 100, readbuf, 100);
    MQTTPacket_connectData cdata = MQTTPacket_connectData_initializer;
    cdata.MQTTVersion = 3;
    cdata.clientID.cstring = "daniel";
    rc = MQTTConnect(&hMQTTClient, &cdata);

    if (rc != 0) {
        CLI_Write(" Failed to start MQTT client \n\r");
        //LOOP_FOREVER();
    }

    rc = MQTTSubscribe(&hMQTTClient, SUBSCRIBE_TOPIC, QOS0, messageArrived);

    if (rc != 0) {
        CLI_Write(" Failed to subscribe to /msp/cc3100/demo topic \n\r");
        //LOOP_FOREVER();
    }

    MQTTYield(&hMQTTClient, 10);
    int8_t buffer[2] = "on";
    MQTTMessage msg;
    msg.dup = 0;
    msg.id = 0;
    msg.payload = buffer;
    msg.payloadlen = 8;
    msg.qos = QOS0;
    msg.retained = 0;
    MQTTPublish(&hMQTTClient, PUBLISH_TOPIC, &msg);
    Delay(20);

    backlight_off();
    while(1) {
        MQTTYield(&hMQTTClient, 10);
        debounce++;

        if(send_goal_bool) {
            int8_t buffer2[15] = "               ";
            sprintf(buffer2, "%d", goal_steps);
            msg;
            msg.dup = 0;
            msg.id = 0;
            msg.payload = buffer2;
            msg.payloadlen = 15;
            msg.qos = QOS0;
            msg.retained = 0;
            MQTTPublish(&hMQTTClient, PUBLISH_TOPIC, &msg);
            Delay(20);
            send_goal_bool = 0;
        }else if(send_on_bool) {
            int8_t buffer2[2] = "on";
            msg;
            msg.dup = 0;
            msg.id = 0;
            msg.payload = buffer2;
            msg.payloadlen = 2;
            msg.qos = QOS0;
            msg.retained = 0;
            MQTTPublish(&hMQTTClient, PUBLISH_TOPIC, &msg);
            Delay(20);
            send_on_bool = 0;
        } else if( (P3IN & BIT5) == 0 && debounce > 20) {
          debounce = 0;
          menu_select();
        } else if ( (P1IN & BIT4) == 0 && debounce > 10) {
          debounce = 0;
          menu();
        } else if ( steps_taken >= goal_steps && active_bool == 1 ) {
          P1OUT &= ~BIT0;
          int8_t buffer2[1] = "g";
          msg;
          msg.dup = 0;
          msg.id = 0;
          msg.payload = buffer2;
          msg.payloadlen = 1;
          msg.qos = QOS0;
          msg.retained = 0;
          MQTTPublish(&hMQTTClient, "on", &msg);
          Delay(20);
          MAP_Interrupt_disableInterrupt(INT_ADC14);
          active_bool = 0;
          view_goal_menu();
        }
    }
}