Beispiel #1
0
void loop() {
	am2312_ACInfo ac = {0};
	char buff[32] = "";

	hal_w2_enable(true);
	ac = am2312_read_ac();
	hal_w2_enable(false);

	if (ac.isOK) {
		sprintf(buff, "TEMP: %0.1fC", ac.temperature/10.0f);
		puts8x16(1, 0, buff);

		sprintf(buff, "HUMI: %0.1f%c", ac.humidity/10.0f, '%');
		puts8x16(2, 0, buff);

		puts6x8(7, 122, " ");
	}
	else {
		puts6x8(7, 122, "E");
		++stat_error;
	}

	sprintf(buff, "%s", ANIM_PROGRESS_KEYFRAMES[keyframe]);
	puts8x16(0, 98, buff);
	keyframe = (keyframe+1) % countof(ANIM_PROGRESS_KEYFRAMES);

	stat_all += 1;
	sprintf(buff, "%d/%d", stat_error, stat_all);
	puts6x8(7, 0, buff);

	delay_s(2);
}
Beispiel #2
0
void hal_w2_configure_master(hal_w2_clk_freq_t mode)
{
  hal_w2_enable(true);
  hal_w2_set_clk_freq(mode);
  hal_w2_set_op_mode(HAL_W2_MASTER);

  INTEXP |= 0x04;                         // Enable 2 wire interrupts
  W2CON1 = 0x00;
  hal_w2_all_irq_enable(true);             // Enable interrupts in the 2-wire  
  SPIF = 0;
}