예제 #1
0
static void altitude_activate(void)
{

	/* display -- symbol while a measure is not performed */
	display_chars(0, LCD_SEG_L1_3_0, "----", SEG_SET);
    update(SYS_MSG_FAKE);

	sys_messagebus_register(&update, consumption_array[consumption-1]);
    
    sys_messagebus_register(&time_callback, SYS_MSG_RTC_MINUTE
                        | SYS_MSG_RTC_HOUR
#ifdef CONFIG_MOD_CLOCK_BLINKCOL
                        | SYS_MSG_RTC_SECOND
#endif
    );
    
    lcd_screens_create(6);
    display_chars(ALT_SCREEN_CLIMB, LCD_SEG_L2_5_0, " CLIMB", SEG_SET);
    display_symbol(ALT_SCREEN_CLIMB, LCD_SEG_L1_DP0, SEG_ON);
    display_symbol(ALT_SCREEN_CLIMB, LCD_UNIT_L1_PER_S, SEG_ON);
    display_chars(ALT_SCREEN_MIN,   LCD_SEG_L2_5_0, " MIN  ", SEG_SET);
    display_chars(ALT_SCREEN_MAX,   LCD_SEG_L2_5_0, " MAX  ", SEG_SET);
    display_chars(ALT_SCREEN_ACC_N, LCD_SEG_L2_5_0, " ACC N", SEG_SET);
    display_chars(ALT_SCREEN_ACC_P, LCD_SEG_L2_5_0, " ACC P", SEG_SET);
}
예제 #2
0
static void edit_save()
{
	sys_messagebus_register(&update, consumption_array[consumption-1]);
    
    sys_messagebus_register(&time_callback, SYS_MSG_RTC_MINUTE
                        | SYS_MSG_RTC_HOUR
#ifdef CONFIG_MOD_CLOCK_BLINKCOL
                        | SYS_MSG_RTC_SECOND
#endif
    );
    
	update(SYS_MSG_FAKE);
}
예제 #3
0
/* NUM (#) button pressed callback */
static void num_pressed()
{
	/* this cycles between all alarm/chime combinations and overflow */
	alarm_state.state++;

	/* Register RTC only if needed, saving CPU cycles.. */
	if (alarm_state.state)
		sys_messagebus_register(alarm_event, SYS_MSG_RTC_ALARM);
	else
		sys_messagebus_unregister(alarm_event);

	if (alarm_state.alarm) {
		display_symbol(0, LCD_ICON_ALARM, SEG_ON);
		rtca_enable_alarm();
	} else {
		display_symbol(0, LCD_ICON_ALARM, SEG_OFF);
		rtca_disable_alarm();
	}

	if (alarm_state.chime) {
		display_symbol(0, LCD_ICON_BEEPER2, SEG_ON);
		display_symbol(0, LCD_ICON_BEEPER3, SEG_ON);
	} else {
		display_symbol(0, LCD_ICON_BEEPER2, SEG_OFF);
		display_symbol(0, LCD_ICON_BEEPER3, SEG_OFF);
	}

}
예제 #4
0
/************************ menu callbacks **********************************/
static void clock_activated()
{
	sys_messagebus_register(&clock_event, SYS_MSG_RTC_MINUTE
						| SYS_MSG_RTC_HOUR
						| SYS_MSG_RTC_DAY
						| SYS_MSG_RTC_MONTH
#ifdef CONFIG_MOD_CLOCK_BLINKCOL
						| SYS_MSG_RTC_SECOND
#endif
	);

	/* create two screens, the first is always the active one */
	lcd_screens_create(2);

	/* display stuff that won't change with time */
	display_symbol(0, LCD_SEG_L1_COL, SEG_ON);
	display_char(0, LCD_SEG_L2_2, '-', SEG_SET);

	/* update screens with fake event */
	clock_event(SYS_MSG_RTC_YEAR
					| SYS_MSG_RTC_MONTH
					| SYS_MSG_RTC_DAY
					| SYS_MSG_RTC_HOUR
					| SYS_MSG_RTC_MINUTE);
}
예제 #5
0
/*
  Polls the button driver.

  This functions exists to delay registering callbacks
  while within PORT2_ISA and risk breaking the messagebus.
*/
void ports_buttons_poll(void)
{
       if (timer_20Hz_requested == 1) {
 	        sys_messagebus_register(&callback_20Hz, SYS_MSG_TIMER_20HZ);
                timer_20Hz_requested = 2;
        }
}
예제 #6
0
void mod_tide_init(void)
{
	sys_messagebus_register(&minuteTick, SYS_MSG_RTC_MINUTE);
	menu_add_entry("TIDE", &buttonUp, &buttonDown, NULL, &longStarButton, NULL, NULL, &activate, &deactivate);
	tide = timeFromMinutes(90); /* fullTideTime); */
	minuteTick(); /* initla display setup */
}
예제 #7
0
void ir_init(void)
{
    __disable_interrupt();
    IR_SEL &= ~IR_PIN;
    IR_DIR &= ~IR_PIN;
    timer_a1_init();
    __enable_interrupt();
    sys_messagebus_register(&ir_isr, SYS_MSG_TIMER1_CCR0);
    ir_resume();
}
예제 #8
0
파일: i2c_fcts.c 프로젝트: rodan/ampy
void i2c_iface_init(void)
{
    sys_messagebus_register(&i2c_rx_irq, SYS_MSG_I2C_RX);

    // when the i2c data request comes in this is the address 
    // from which to start sending
    i2c_slave_tx_data_start_addr = (uint8_t *) &s;
    i2c_slave_rx_data_start_addr = i2c_rx_buff;
    i2c_rx_rdy = 1;
}
예제 #9
0
static void intertechno_activated()
{
    sys_messagebus_register(&it_tx_end, SYS_MSG_RADIO);
    _printf(0, LCD_SEG_L1_3_2, "%02u", it_family);
    _printf(0, LCD_SEG_L1_1_0, "%02u", it_device);
#ifdef CONFIG_MOD_INTERTECHNO_PW
    _printf(0, LCD_SEG_L2_1_0, "%02x", it_pwr[it_pwr_level]);
#endif
    display_symbol(0, LCD_SEG_L1_DP1, SEG_ON);
}
/* Activation of the module */
static void stopwatch_activated() {
	display_symbol(0, LCD_SEG_L2_COL0, SEG_ON);
	display_symbol(0, LCD_SEG_L2_COL1, SEG_ON);
	if (sSwatch_conf.state == SWATCH_MODE_BACKGROUND) {
		sSwatch_conf.state = SWATCH_MODE_ON;
		return;
	}

	sys_messagebus_register(&stopwatch_event, SYS_MSG_TIMER_20HZ);
	drawStopWatchScreen();
}
예제 #11
0
//* ************************************************************************************************
/// @fn			temperature_activate(void)
/// @brief		Temperature screen activation. Display defaul stuff, register the mesuring loop.
/// @return		none
//* ************************************************************************************************
static void temperature_activate(void)
{
    // Create two screens, the first is always the active one
    lcd_screens_create(2);

    // Display the title of this module at the bottom
    display_chars(0, LCD_SEG_L2_3_0, "TEMP", SEG_SET);

    // Display something while a measure is not performed
    display_chars(0, LCD_SEG_L1_2_0, " - ", SEG_ON);

    // Register an event
    sys_messagebus_register(&measure_temp, SYS_MSG_TIMER_4S);
}
예제 #12
0
static void temperature_activate(void)
{
	/* display static elements */
	display_symbol(0, LCD_UNIT_L1_DEGREE, SEG_ON);
	display_symbol(0, LCD_SEG_L1_DP0, SEG_ON);
#ifdef CONFIG_TEMPERATURE_METRIC
	display_char(0, LCD_SEG_L2_4, 'C', SEG_SET);
#else
	display_char(0, LCD_SEG_L2_4, 'F', SEG_SET);
#endif
	
	/* display -- symbol while a measure is not performed */
	display_chars(0, LCD_SEG_L1_2_0, "---", SEG_ON);

	sys_messagebus_register(&measure_temp, SYS_MSG_TIMER_4S);
}
예제 #13
0
static void battery_activate(void)
{
	battery_measurement();

	sys_messagebus_register(&battery_event, SYS_MSG_BATT);

	/* display static symbols */
#ifdef CONFIG_MOD_BATTERY_SHOW_VOLTAGE
	display_symbol(0, LCD_SEG_L2_DP,    SEG_ON);
#endif
	display_symbol(0, LCD_SYMB_BATTERY, SEG_ON);
	display_symbol(0, LCD_SYMB_PERCENT, SEG_ON);

	/* refresh display */
	display_battery();
}
예제 #14
0
int main(void)
{
    main_init();
    timer_a0_init();

    // PGA2311 needs to get the digital power after a delay
    // otherwise it will lock up
    timer_a0_delay_ccr4(_1s);
    pga_enable;
    spi_init();
    spi_fast_mode();

    // set chip selects high (deselect all slaves)
    P1OUT |= 0x54;
    P2OUT |= 0x1;
    P4OUT |= 0x84;

    settings_init(FLASH_ADDR);

    get_temperature();

#ifdef USE_UART
    uart1_init();
    uart1_iface_init();
#endif

#ifdef USE_I2C
    i2c_slave_init();
    i2c_iface_init();
#endif

    sys_messagebus_register(&timer_a0_ovf_irq, SYS_MSG_TIMER0_IFG);

    led_off;

    while (1) {
        // go into low power mode until an IRQ wakes us up
        _BIS_SR(LPM0_bits + GIE);
        __no_operation();
        //wake_up();
#ifdef USE_WATCHDOG
        WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL;
#endif
        check_events();
    }
}
예제 #15
0
파일: uart_fcts.c 프로젝트: rodan/ampy
void uart1_iface_init(void)
{
    sys_messagebus_register(&uart1_rx_irq, SYS_MSG_UART1_RX);
}
예제 #16
0
/* Enter the accelerometer menu */
static void acc_activated()
{


	//register to the system bus for vti events as well as the RTC minute events
	sys_messagebus_register(&as_event, SYS_MSG_AS_INT | SYS_MSG_RTC_MINUTE | SYS_MSG_RTC_SECOND);


	/* create two screens, the first is always the active one */
	lcd_screens_create(2);

	/* screen 0 will contain the menu structure and screen 1 the raw accelerometer data */
	
	// Show warning if acceleration sensor was not initialised properly
	if (!as_ok)
	{
		display_chars(0, LCD_SEG_L1_3_0, "ERR", SEG_SET);
	}
	else
	{

		/* Initialization is required only if not in background mode! */
		if (sAccel.mode != ACCEL_MODE_BACKGROUND)
		{
			// Clear previous acceleration value
			sAccel.data = 0;
			// 2 g range
			as_config.range=2;
			// 100 Hz sampling rate
			as_config.sampling=SAMPLING_10_HZ;
			// keep mode
			as_config.mode=ACTIVITY_MODE;
			//time window is 10 msec for free fall and 100 msec for activity
			//2g multiple 71 mg: 0F=4 * 71 mg= 1.065 g
			as_config.MDTHR=2;
			as_config.MDFFTMR=1;

			// Set timeout counter
			sAccel.timeout = ACCEL_MEASUREMENT_TIMEOUT;

			// Set mode for screen 
			sAccel.mode = ACCEL_MODE_ON;

			// Start with mode selection
			submenu_state=VIEW_SET_MODE;

			// Select Axis X
			sAccel.view_style=DISPLAY_ACCEL_Z;

			// Start sensor in motion detection mode
			as_start(ACTIVITY_MODE);
			// After this call interrupts will be generated
		}

		if (!as_ok)
		{
			display_chars(0, LCD_SEG_L1_3_0, "FAIL", SEG_SET);
		}
		display_chars(0, LCD_SEG_L1_3_0 , "ACTI", SEG_SET);
		display_chars(0, LCD_SEG_L2_4_0 , "MODE", SEG_SET);


	}
	/* return to main screen */
	lcd_screen_activate(0);
}
예제 #17
0
파일: proj.c 프로젝트: glocklueng/tracy
int main(void)
{
    main_init();
    rtca_init();
    timer_a0_init();
    uart0_init();
    sim900_init_messagebus();
    sim900.next_state = SIM900_OFF;

    settings_init(SEGMENT_B, VERSION_BASED);
    //settings_apply();

    m.e = 0x0;
    m.seg[0] = 0x0;
    m.seg_num = 1;

    stat.http_post_version = POST_VERSION;
    stat.fix_id = 1;

    sim900.imei[0] = 0;
    sim900.flags = 0;


    gps_trigger_next = 0;
    gprs_trigger_next = s.gprs_loop_interval;

    rtca_set_next = 0;
    rtc_not_set = 1;
    gps_next_state = MAIN_GPS_IDLE;

    if (s.gps_invalidate_interval > s.gps_loop_interval) {
        s.gps_invalidate_interval = s.gps_loop_interval;
    }
   
    gprs_tx_trig = 0;
    gprs_tx_next = s.gprs_static_tx_interval;

    gprs_blackout_lift = 0;

#ifdef DEBUG_GPS
    uart1_init(9600);
    uart1_tx_str("gps debug state\r\n", 17);
#endif

#ifdef DEBUG_GPRS
    uart0_tx_str("gprs debug state\r\n", 18);
    display_menu();
#endif

#ifdef CALIBRATION
    sys_messagebus_register(&adc_calibration, SYS_MSG_RTC_SECOND);
#else
#ifndef DEBUG_GPRS
    sys_messagebus_register(&schedule, SYS_MSG_RTC_SECOND);
    sys_messagebus_register(&parse_gps, SYS_MSG_UART0_RX);
#else
    sys_messagebus_register(&parse_UI, SYS_MSG_UART0_RX);
#endif
#ifndef DEBUG_GPS
    sys_messagebus_register(&parse_gprs, SYS_MSG_UART1_RX);
#endif

#endif

#ifdef FM24_HAS_SLEEP_MODE
    fm24_sleep();
#endif

    // main loop
    while (1) {
        _BIS_SR(LPM3_bits + GIE);
        //wake_up();
#ifdef USE_WATCHDOG
        // reset watchdog counter
        WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL;
#endif
        // new messages can be sent from within a check_events() call, so 
        // parse the message linked list multiple times
        check_events();
        check_events();
        check_events();

#ifdef FM24_HAS_SLEEP_MODE
        // sleep
        if (fm24_status & FM24_AWAKE) {
            fm24_sleep();
        }
#endif

        // P4.0 and P4.1
        //P4SEL &= ~0x3;
        
        /*
        PMMCTL0_H = 0xA5;
        SVSMHCTL &= ~SVMHE;
        SVSMLCTL &= ~(SVSLE+SVMLE);
        PMMCTL0_H = 0x00;
        */
    }
}