uint8_t lcd_write(unsigned char chr, enum lcd_rs_t rs, uint8_t timeout) { unsigned char status; do { status = lcd_status(); } while(lcd_is_busy(status) && timeout--); if(lcd_is_busy(status)) { lcd_info_set_write_timeout(); return 0; } lcd_tris_set(0x00); lcd_en_pin = LCD_EN_LOW; lcd_rs_pin = rs; lcd_rw_pin = LCD_RW_WRITE; lcd_send_nibble(chr >> 4); lcd_send_nibble(chr); return 1; }
/** * @brief Sends a single symbol to the display. * @details This will send a symbol to the current DDRAM address on the display controller * and automatically increment the display cursor. * * @param symbol The symbol to be printed. */ void lcd_send_symbol(char symbol) { while (lcd_is_busy()) _delay_ms(1); PORTB |= 1 << 0; PORTA = symbol; PORTB |= 1 << 2; _delay_us(50); // lcd controller execution time PORTB &= ~(1 << 2); }
void scroll_screen(char c){ uint8_t offset; for (offset=0;offset<8;offset++) { scroll_line(c,offset); if (!(offset%2)) { while (lcd_is_busy()); lcd_dma_start(); } // delay_ms(150); } }
/** * @brief Sends a command to the display controller. * * @param cmd The command code to be sent. */ void lcd_send_command(char cmd) { while (lcd_is_busy()) _delay_ms(1); PORTB &= ~(1 << 0); PORTA = cmd; PORTB |= 1 << 2; if (cmd == 0b01 || cmd == 0b10) // if clear or return home instruction _delay_ms(1.5); // then execution time is longer else _delay_us(50); PORTB &= ~(1 << 2); }
int main(void) { uint32_t x = 0; uint32_t y = 0; RCC_DeInit(); RCC_HSEConfig(RCC_HSE_ON); if(RCC_WaitForHSEStartUp() == SUCCESS) { RCC_HCLKConfig(RCC_SYSCLK_Div1); RCC_PCLKConfig(RCC_HCLK_Div1); RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_8); RCC_PLLCmd(ENABLE); while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET); RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); while(RCC_GetSYSCLKSource() != 0x08); } generator_init(); generator_start(); delay_init(); lcd_init(); lcd_clear(); lcd_dma_start(); for (x=0;x<50;x++) { while (lcd_is_busy()); lcd_noise(); lcd_dma_start(); } while (lcd_is_busy()); for (x=0;x<patternWidthPages*patternHeightPixels;x++) lcd_buf[x] = patternBitmaps[x]; print(1,0,"PLEASE",6); print(0,7,"STAND_BY",8); while (lcd_is_busy()); lcd_dma_start(); delay_ms(20000); for (x=0;x<patternWidthPages*patternHeightPixels;x++) lcd_buf[x] = patternBitmaps[x]; for (x=9;x>0;x--) { putchar_big(3,3,'0'+x); while (lcd_is_busy()); lcd_dma_start(); delay_ms(3000); } lcd_clear(); print(1,1,"URGENT",6); print(0,6,"MESSAGE!",8); while (lcd_is_busy()); lcd_dma_start(); delay_ms(3000); scroll_text(MESSAGE); delay_ms(3000); lcd_clear(); print(1,1,"THAT'S",6); print(3,3,"ALL",3); print(1,5,"FOLKS!",6); while (lcd_is_busy()); lcd_dma_start(); delay_ms(100000); for (x=0;x<10000;x++) { while (lcd_is_busy()); lcd_noise(); lcd_dma_start(); } lcd_clear(); while (lcd_is_busy()); lcd_dma_start(); scroll_text(SECRET_MESSAGE); while(1) //Infinite loop! { while (lcd_is_busy()); lcd_noise(); lcd_dma_start(); } }