Beispiel #1
0
/**
 *  Clears a row of the display.
 *
 *  @param row A display row (Y address).
 */
void lcd_clear_row(unsigned int row) {
	// Start from the beginning of the row.
	lcd_set_pos(0, row);

	// Fill the row with blank pixels.
	for (unsigned int i = 0; i < LCDWIDTH; i++) {
		lcd_command(0, 0);
	}

	// Go back to where everything started.
	lcd_set_pos(0, row);
}
Beispiel #2
0
/**
 *  Clears the screen
 */
void lcd_clear() {
	// Start from (0,0).
	lcd_set_pos(0, 0);

	// Fill the whole screen with blank pixels.
	for (unsigned int i = 0; i < (LCDWIDTH * (LCDHEIGHT / 8)); i++) {
		lcd_command(0, 0);
	}

	// Go back to (0,0).
	lcd_set_pos(0, 0);
}
Beispiel #3
0
int lcd_set_pixel( struct lcd_pixel * pix )
{
	int y=0;
	int val;
	int bit=0;
	int v;

	if ( pix->y >= (LCD_ROWS*8) ) {
		return -EINVAL;
	}

	if ( pix->x >= LCD_COLS ) {
		return -EINVAL;
	}

	if (pix->y) {
		y = (pix->y/8);
	}

	bit = pix->y - (y*8);

	// set dram pointer
	lcd_set_pos( y, pix->x );
	lcd_read_dummy();

	val = lcd_read_byte();

	v = pix->v;

	// invertieren
	if ( v == 2 ) {
		v = (((~val)>>bit)&1);
	}
Beispiel #4
0
// Halt board on init failure and print message
void board_fail_P(PGM_P msg) {
    printf(str_boot_fail, msg);
    // print message
#ifdef LCD_DEBUG
    lcd_set_pos(16);
    lcd_printf(msg);
    lcd_set_pos(31);
    lcd_print_char('\3', NULL);
#endif
    // and stop
    while (1) {
        for (int i = 0; i < 2; i++) {
            LED_COMM(1);
            pause(100);
            LED_COMM(0);
            pause(150);
        }
        pause(800);
    }
}
Beispiel #5
0
// Initialise board
void board_init (void) {

	#ifndef SIMULATE
    io_init(); // Init GPIOs
    uart_init(BAUD_RATE);
    stderr = &uartio;
    printf(str_boot_uart,BAUD_RATE);
    printf(str_boot_start);
	#else
	printf("Skipping UART initialization...\n");
	#endif
	#ifndef SIMULATE
    digital_init();
	#endif
    encoder_init();
	#ifndef SIMULATE
    spi_init();
    motor_init();
    servo_init();
#ifdef LCD_DEBUG
    lcd_init(); //consider wrapping this in an #ifdef LCD_DEBUG tag?
    stdout = &lcdout;
#else
    stdout = &uartio;
    stdin = &uartio;
#endif
    adc_init();
    isr_init();
    memory_init();
	#endif

    // load config, or fail if invalid
    if (!board_load_config())
        board_fail("Bad Config");
    printf(str_boot_conf);
    printf(str_boot_board,
            board_config.version>>8,
            board_config.version&0xFF);
    printf(str_boot_id, board_config.id);

    // print boot text to screen
    printf(str_boot_message, board_config.version>>8, board_config.version&0xFF);

    // check battery, fail if <7.5V
    printf(str_boot_batt,read_battery());
#ifdef CHECK_BATTERY
    if (!(read_battery()>=7200)) {
        // NOTE: in the current 2-battery version of the HappyBoard, the 
        // battery voltage is the motor battery (P+).  Holding GO overrides
        // the check so you can run the HappyBoard without a motor battery.
        if (go_press())
            printf("WARNING: LOW BATTERY\n");
        else 
            board_fail("Low battery");
    } else {
        printf("Battery OK\n");
    }
#endif

	#ifndef SIMULATE
    // initialise FPGA
    if (!fpga_init(FPGA_CONFIG_ADDRESS, board_config.fpga_len))
        board_fail("FPGA failure");
    printf(str_boot_fpga, fpga_get_version_major(), fpga_get_version_minor());
	#else
	printf("Skipping FPGA initialization...\n");
	#endif

    // all ok
#ifndef SIMULATE
#ifdef LCD_DEBUG
    lcd_set_pos(31);
    lcd_print_char('\1', NULL);
#else
	printf("Board init complete.\n");
#endif
#else
    printf("Board init complete.\n");
#endif

#ifndef SIMULATE
    LED_COMM(0);
#endif

}