Ejemplo n.º 1
0
/**
 * First init
 */
static void firstInit(void) {

	//Hardware init
	GPIO_init();
	USART1_init();//midi
	USART6_init();//debug
	usb_midi_init(); //Init everything for midiUSB

	ADC_init_all(); //ADC init
	SD_DMA_activate();
	//Display
	delayms(400);
#ifdef WS0010_GRAPHICS
	hd44780_init();
	hd44780_display( HD44780_DISP_ON, HD44780_DISP_CURS_OFF, HD44780_DISP_BLINK_OFF);
	ws0010_Graphics_mode();
	ws0010_Draw_buffer(pictureVMK188);
    delayms(20000);
	ws0010_Character_mode();
	hd44780_init();
#else
	hd44780_init();
	hd44780_display( HD44780_DISP_ON, HD44780_DISP_CURS_OFF, HD44780_DISP_BLINK_OFF);
	hd44780_message_center(APP_NAME, 1);
	hd44780_message_center(APP_VERSION, 2);
    delayms(3000);
#endif

}
Ejemplo n.º 2
0
int main(void)
{
    char msg[]="A nice long message for you to read !!!!"
               "A second very long message to read :) !!";

    /* set up systick */
    if(SysTick_Config(SystemCoreClock/1000))
    {
        while(1);
    }

    /* set the pins up */
    init_io();
    /* start the lcd */
    hd44780_init();

    hd44780_write_string(msg);

    while(1)
    {
        delayms(300);
        hd44780_shift(0,1);
    }

    return 0;
}
Ejemplo n.º 3
0
int16_t parse_cmd_lcd_init(char *cmd, char *output, uint16_t len)
{
	uint8_t cursor, blink;

#ifdef TEENSY_SUPPORT
	/* Skip leading spaces. */
	while(*cmd == ' ') cmd ++;

	/* Seek space (blink argument), chop and atoi to `blink'.  */
	char *p = cmd;
	while(*p && *p != ' ') p ++;
	if(!*p)
		return ECMD_ERR_PARSE_ERROR; /* Required argument `blink' missing. */

	*p = 0;
	blink = atoi(p + 1);
	cursor = atoi(cmd);
#else
	int ret = sscanf_P(cmd, PSTR("%hhu %hhu"), &cursor, &blink);
	if(ret != 2)
		return ECMD_ERR_PARSE_ERROR;
#endif

    hd44780_init();
    hd44780_config(cursor, blink,1);
    return ECMD_FINAL_OK;
}
Ejemplo n.º 4
0
/*
 * Setup the LCD controller.  First, call the hardware initialization
 * function, then adjust the display attributes we want.
 */
void
lcd_init(void)
{

  hd44780_init();

  /*
   * Clear the display.
   */
  hd44780_outcmd(HD44780_CLR);
  hd44780_wait_ready();

  /*
   * Entry mode: auto-increment address counter, no display shift in
   * effect.
   */
  hd44780_outcmd(HD44780_ENTMODE(1, 0));
  hd44780_wait_ready();

  /*
   * Enable display, activate non-blinking cursor.
   */
  hd44780_outcmd(HD44780_DISPCTL(1, 1, 0));
  hd44780_wait_ready();
}
Ejemplo n.º 5
0
void main(void) {

	// lcd display
	struct dev_hd44780_ctx lcd_ctx;
	memset((void *)&lcd_ctx, 0x00, sizeof(struct dev_hd44780_ctx));

	lcd_ctx.rs.port = &LCD_RS_PORT;
	lcd_ctx.rs.pin = LCD_RS_PIN;
	lcd_ctx.e.port = &LCD_E_PORT;
	lcd_ctx.e.pin = LCD_E_PIN;

	// setup data lines
	for (uint8_t x = 0; x<4; x++) {
		lcd_ctx.data[x].port = &LCD_DB_PORT;
		lcd_ctx.data[x].pin = LCD_DB_PIN_FIRST + x;
	}

	// display specifics
	lcd_ctx.lines = LCD_NUMBER_OF_LINES;
	lcd_ctx.font = HD44780_FONT_5X8;

	// initialize the device
	hd44780_init(&lcd_ctx);

	// clear the display initially 
	hd44780_clrscr(&lcd_ctx);

	hd44780_goto(&lcd_ctx, 0x00);
	hd44780_puts(&lcd_ctx, "Hello World");

	// execution loop
	for (;;);
}
Ejemplo n.º 6
0
void LcdLogic::wireHook(avr_t *avr)
{
    this->avr = avr;

    hd44780_init(avr, &hd44780, WIDTH, HEIGHT, this, LcdLogic::displayChanged);

    /* Connect data lines to Port C, 4-7 (bidirectional). */
    for (int i = 0; i < 4; i++) {
        avr_irq_t * iavr = avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 4 + i);
        avr_irq_t * ilcd = hd44780.irq + IRQ_HD44780_D4 + i;
        // AVR -> LCD
        avr_connect_irq(iavr, ilcd);
        // LCD -> AVR
        avr_connect_irq(ilcd, iavr);
    }

    avr_connect_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 2),
                    hd44780.irq + IRQ_HD44780_RS);
    avr_connect_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 3),
                    hd44780.irq + IRQ_HD44780_E);
    /* RW is set to GND. */

    avr_vcd_init(avr, "lcd.vcd", &vcdFile, 100000);
    avr_vcd_add_signal(&vcdFile,
            avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), IOPORT_IRQ_PIN_ALL),
            4 /* bits */, "D4-D7");
    avr_vcd_add_signal(&vcdFile,
            avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 2),
            1 /* bits */, "RS");
    avr_vcd_add_signal(&vcdFile,
            avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 3),
            1 /* bits */, "E");
}
Ejemplo n.º 7
0
int16_t main(void)
{
    char c = 'g';
    
    /* Configure the oscillator for the device */
    ConfigureOscillator();

    /* Initialize IO ports and peripherals */
    InitApp();

    hd44780_init(N_2LINE,FONT_8);
    //hd44780_setCursorPosition(0, 0);
    hd44780_write_char(' ');
    hd44780_write_char('G');
    hd44780_write_char('K');
    hd44780_write_string("hat DE Lieb");

    while(1)
    {
        if(UART1RXRdy()==1){//check for data waiting
			c=UART1RX();//get the character
			if(c=='0')
            {
                T1CONbits.TON = ~T1CONbits.TON;  /* enable Timer 1 and start the count */
                if(!T1CONbits.TON) //if timer is off, turn off LED
                {
                    UART1TX('T');
                    UART1TX('1');
                    UART1TX('-');
                    UART1TX('O');
                    UART1TX('F');
                    UART1TX('F');
                    UART1TX('\n');
                    UART1TX('\r');
                    MSLED_O = 0;
                }
                else
                {
                    UART1TX('T');
                    UART1TX('1');
                    UART1TX('-');
                    UART1TX('O');
                    UART1TX('N');
                    UART1TX('\n');
                    UART1TX('\r');
                    MSLED_O=1;
                }
			}
            else
            {
                UART1TX(c);//echo the character back
                hd44780_write_char(c);
            }
  		}
    }
}
Ejemplo n.º 8
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());

    i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);

    hd44780_t lcd = {
        .i2c_dev.bus = I2C_BUS,
        .i2c_dev.addr = ADDR,
        .font = HD44780_FONT_5X8,
        .lines = 2,
        .pins = {
            .rs = 0,
            .e  = 2,
            .d4 = 4,
            .d5 = 5,
            .d6 = 6,
            .d7 = 7,
            .bl = 3
        },
        .backlight = true
    };

    hd44780_init(&lcd);
    hd44780_upload_character(&lcd, 0, char_data);
    hd44780_upload_character(&lcd, 1, char_data + 8);

    hd44780_gotoxy(&lcd, 0, 0);
    hd44780_puts(&lcd, "\x08 Hello world!");
    hd44780_gotoxy(&lcd, 0, 1);
    hd44780_puts(&lcd, "\x09 ");

    char time[16];

    while (true)
    {
        hd44780_gotoxy(&lcd, 2, 1);

        snprintf(time, 7, "%u     ", sdk_system_get_time() / 1000000);
        time[sizeof(time) - 1] = 0;

        hd44780_puts(&lcd, time);

        for (uint32_t i = 0; i < 1000; i++)
            sdk_os_delay_us(1000);
    }
}
Ejemplo n.º 9
0
int main()
{
  hd44780_init();
  /*
   * Clear the display.
   */
  hd44780_outcmd(HD44780_CLR);
  hd44780_wait_ready(1);   // long wait

  /*
   * Entry mode: auto-increment address counter, no display shift in effect.
   */
  hd44780_outcmd(HD44780_ENTMODE(1, 0));
  hd44780_wait_ready(0);

  /*
   * Enable display, activate non-blinking cursor.
   */
  hd44780_outcmd(HD44780_DISPCTL(1, 1, 0));
  hd44780_wait_ready(0);

  EICRA = (1 << ISC00);
  EIMSK = (1 << INT0);

  sei();

  while (1) {
    while (!update_needed)
      sleep_mode();
    update_needed = 0;
    char buffer[16];

    hd44780_outcmd(HD44780_CLR);
    hd44780_wait_ready(1);   // long wait
    hd44780_outcmd(HD44780_DDADDR(4));
    hd44780_wait_ready(0);
    sprintf(buffer, "%2d:%02d:%02d", hour, minute, second);

    char *s = buffer;
    while (*s) {
      hd44780_outdata(*s++);
      hd44780_wait_ready(0);
    }
  }
}
Ejemplo n.º 10
0
/** Inicjalizacja urządzeń wejścia / wyjścia.
*/
void ioinit(void)
{
	uint8_t i;
	hd44780_init();
	hd44780_outcmd(HD44780_CLR);
	hd44780_wait_ready();
	hd44780_outcmd(HD44780_ENTMODE(1, 0));
	hd44780_wait_ready();
	hd44780_outcmd(HD44780_DISPCTL(1, 1, 1));
	hd44780_wait_ready();
	hd44780_outcmd(HD44780_CGADDR(0));
	for(i=0; i<64; i++) {
		hd44780_outdata(pgm_read_byte(&extraChar[i]));
	}

	TCCR1B = _BV(WGM12) | _BV(CS11);                        // licznik / 8 - wyzerwoanie na porownanie
	TIMSK = _BV(OCIE1A);                                    // przerwanie na porownanie wartosci
	OCR1A = TAU1;                                           // warto licznika porownania

	usart_init(UBRR_VALUE);

	onewire_init();

	twi_init();

	outputs_init();

	top_off_init();

	qbuttons_init();

	ui_init();

	BUZZER_DDR |= _BV(BUZZER_SWITCH);
	buzzer_off();

	wdt_enable(WDTO_2S);
}