Exemple #1
0
//turn backlight on/off (1/0)
void lcd_backlight(char state)
{
  if (state == 0)
    ioPins_setValue(LCD_BACKLIGHT_PIN, 0);  // lcd backlight low
  else
    ioPins_setValue(LCD_BACKLIGHT_PIN, 1);  // lcd backlight high
}
Exemple #2
0
static void alarmCallback()
{
	static struct RTC_time t_now;
	static struct unicast_message *tmp, sMsg;
	static struct sensor_data sens_data;
	static uint16_t samplingDelay = 280;
	static uint16_t delay = 40; // ADC requires minimum 20 us of sampling time.
	static uint16_t sleepDelay = 9680;
	static uint16_t avg;
	static uint8_t count = 0;
	if(count==0)
	RTC_getTime(&t_now);
	int len;
	uint8_t i, numSampl = 20;

	static uint16_t v = 0, v1;

	ioPins_configurePin(8, USEGPIO, OUTPUT, NOPULLUP, HYSTERESIS_OFF);
	ioPins_configurePin(7, USEGPIO, OUTPUT, NOPULLUP, HYSTERESIS_OFF);
	ioPins_setValue(8, 1);
	ioPins_setValue(7, 1);
	

	avg = 0;
	for(i=0;i<numSampl;i++)
	{
		ioPins_setValue(8, 0);
		clock_delay_usec(samplingDelay);
		v = ioPins_getValue(16);
		avg+=v;
		clock_delay_usec(delay);
		ioPins_setValue(8, 1);
		clock_delay_usec(sleepDelay);
		
	}
	
	sens_data.lraw[count] = avg&0xFF;
	sens_data.hraw[count] = (avg&0xFF00)>>8;
	
  	if(count==59)
  	{
  		sMsg.id = id;
	  	sMsg.type = DATA_REQ;
	  	sMsg.time = t_now;
	  	strcpy(sMsg.name, "Dust sensor\0");
	  	sMsg.data = sens_data;
	  	sMsg.numSampl = numSampl;
	  	packetbuf_copyfrom(&sMsg, sizeof(struct unicast_message));
		unicast_send(&unicast, &nmaddr);
		count = 0;
	}
	else
	{
		count++;
	}
}
Exemple #3
0
void ble_reset()
{
  ioPins_setValue(BLE_RST_PIN, 0);  // ble reset low
  clock_delay_msec(10);
  ioPins_setValue(BLE_RST_PIN, 1);  // ble reset high
}