Exemple #1
0
static void lcd_enable(void)
{
	setup_memory();

	if (clcd_init())
	{
		printf("CLCD init failed!\n");
		return;
	}
}
Exemple #2
0
int main(void)
{
	uint8_t is_halted;

	rtc_init();
	clcd_init();

	/* Initialize the clock to 2075.June.1st Sat 03:07:00 */
	if (rtc_set(75, 6, 1, 7, 3, 7, 0) == 0)
	{
		clcd_move_to(0);
		clcd_print_string(date);
		clcd_move_to(16);
		clcd_print_string(time);
	}
	else
	{
		clcd_move_to(25);
		clcd_print_string("init :(");
		while (1);
	}
	rtc_set_sq_wave(hz_1);

	while (1)
	{
		if (rtc_get_str(&is_halted, date, time) == 0)
		{
			clcd_move_to(0);
			clcd_print_string(date);
			clcd_move_to(16);
			clcd_print_string(time);
			if (is_halted)
			{
				clcd_move_to(25);
				clcd_print_string("Halted");
			}
		}
		else
		{
			clcd_move_to(25);
			clcd_print_string("read :(");
		}

		_delay_ms(200);
	}

	return 0;
}
void init_parallel_pgmer(void)
{
#ifdef USE_CLCD
	clcd_init();
	clcd_print_string("DDK PProgrammer");
#endif

	// 1 = output, 0 = input
	// PC0 -> XTAL1, PC2 -> OEb, PC3 -> WRb, PC4 -> BS1, PC5 -> XA0, PC6 -> XA1,
	// PC7 -> PAGEL, PB5 -> BS2, PB6 -> RESETb = output;
	// PC1 <- RDY/BSYb = input; PA <-> DATA = both

	DDRC |= (XTAL1 | OEb | WRb | BS1 | XA0 | XA1 | PAGEL);
	BUTTON_INIT; // TODO
	DDRB |= (BS2 | RESETb);
	DDRC &= ~RDY_BSYb;
	// DDRA aka DATA_CTL will be controlled as needed
}
Exemple #4
0
int main(void)
{
	uint16_t luminance;
	char buf[16];

	init_adc();
	clcd_init();

	clcd_move_to(0);
	clcd_print_string("Luminance: ");
	clcd_move_to(16);
	clcd_print_string("Lights   : ");
	while (1)
	{
		while (!(ADCSRA & (1 << ADIF)))
			;
		ADCSRA |= (1 << ADIF);
		// Multiply ADCL by 100 & Divide by 1024 (actually 1023)
		luminance = (ADCL * 100) >> 10;
		// Multiply ADCH by 256, then 100 & Divide by 1024 (actually 1023)
		luminance += (ADCH * 100) >> 2;
		luminance = 100 - luminance;
		sprintf(buf, "%d%%", luminance);
		clcd_move_to(11);
		clcd_print_string(buf);
		clcd_move_to(27);
		if (luminance < 50) // Darkness
		{
			PORTB |= (1 << 7); // LED On
			clcd_print_string(" On");
		}
		else
		{
			PORTB &= ~(1 << 7); // LED Off
			clcd_print_string("Off");
		}
		_delay_ms(1000);
		// Restart ADC conversion
		ADCSRA |= (1 << ADSC);
	}

	return 0;
}