[CODE] [C] Simple Butterfly LCD driver

Go To Last Post
115 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Works very well! Thanks for posting it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,

i wanna ask about how to add LCD_UpdateRequired function to dean's code..

thanks..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hakagiri wrote:
hi,

i wanna ask about how to add LCD_UpdateRequired function to dean's code..

thanks..

Please start a new thread or at least continue with the thread you already started at:
http://www.avrfreaks.net/index.p...

The purpose of the tutorial threads is to discuss the tutorial, not solve unrelated problems.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

oh.. okay, i'm sorry... :D

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

The purpose of the tutorial threads is to discuss the tutorial, not solve unrelated problems.


As such I'm going to lock this thread. If anyone has anything to add to the original article PM js, plons or clawson and ask us to temporarily unlock this.

Moderator

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

i wanna ask about how to add LCD_UpdateRequired function to dean's code..

It would just be something simple like:

void LCD_UpdateRequired(void)
{
    UpdateDisplay = true;
}

Added to the driver code.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for this LCD driver, it allowed me to get characters on the screen with next to zero nowledge of C 8)
I noticed that

LCD_WAIT_FOR_SCROLL_DONE();

Does not check if the text is long enough to scroll, and if it isnt, waits forever...

For the solar hotwater controller that I am building I need the numbers (and eventially will need the arrows). I was going to ask if you could do it for me, but I have come up with a brute force hack on your code, without really understanding it too well that gives the numbers 1-5 sequentially. i.e if 3 then you get 3,2,1. I'me sure theres a much nicer way of doing it. I havnt check the 3 as R200(?) is desoldered atm

diff /usr/src/AVR/include/LCD_Driver.c /usr/src/AVR/butterfly/LCD-test/LCD_Driver.c
29a30
> 		volatile uint8_t  LCDNumbers      = 5;
228,229c229,264
<     if (Byte != LCD_SPACE_OR_INVALID_CHAR)              // Null indicates invalid character or space 
<       SegData = pgm_read_word(&LCD_SegTable[Byte]);    
---
>     if (Byte != LCD_SPACE_OR_INVALID_CHAR) {             // Null indicates invalid character or space 
>     /* To adds pecial characters to scrolling display we have thre cases 
>      * for 1-5:
>      * 1 and 2, OR 0x4 to Digit 0 and 1 (2 and 3 on LCD) respectivly
>      * 4 and 5, OR 0x2 to Digit 2 and 3 (4 and 5 on LCD) respectivly
>      * 3, set LCDDR3=0x1, as I think this is not written to for normal CSS characters
>      * Ime sure theres a better way (and there is for just 1 and 2...
>      * But ime doing this with a long list of if statements...
>      */    
>       if (LCDNumbers >= 5 && Digit == 3)
> 	      SegData = pgm_read_word(&LCD_SegTable[Byte])|0x2;
> 		else if (LCDNumbers >= 4 && Digit == 2)
> 	      SegData = pgm_read_word(&LCD_SegTable[Byte])|0x2;
> 		else if (LCDNumbers >= 2 && Digit == 1)
> 		  SegData = pgm_read_word(&LCD_SegTable[Byte])|0x4;
> 		else if (LCDNumbers >= 1 && Digit == 0)
> 		  SegData = pgm_read_word(&LCD_SegTable[Byte])|0x4;
> 		else 
> 		  SegData = pgm_read_word(&LCD_SegTable[Byte]);	  	 
> 	 }
> 	 else
> 		 if (LCDNumbers >= 5 && Digit == 3)
> 	      SegData = 0x2;
> 		else if (LCDNumbers >= 4 && Digit == 2)
> 	      SegData = 0x2;
> 		else if (LCDNumbers >= 2 && Digit == 1)
> 		  SegData = 0x4;
> 		else if (LCDNumbers >= 1 && Digit == 0)
> 		  SegData = 0x4;
> 		else 
> 		  SegData = 0x0 ;	
> 		  
> 	if (LCDNumbers >= 3 && Digit == 0)
> 	   LCDDR3 = 0x1;
> 	 else 
> 	   LCDDR3 = 0x0;
253a289,300
>     UpdateDisplay = true; 
>  }
> 
>  /* 
>   NAME:      | LCD_ShowNumbers 
>   PURPOSE:   | Routine to sequentially turn on the LCD's numbers 
>   ARGUMENTS: | Highest number, 0 for none 
>   RETURNS:   | None 
>  */ 
>  void LCD_ShowNumbers( uint8_t LNumbers) 
>  { 
>     LNumbers    = LCDNumbers; 

the LCD_ShowNumbers() thing doesn't work, but setting the value LCDNumbers seems to, again due to my complete ignorance of C.

If you could improve on this and perhaps do it in a way that allowed for more general orring of bits to LCDDR* then I could try and fill in the rest to get arrows working. I can see myself doing it with another heap of if statements, which doesnt feel very eloquent.
I guess its more general to call LCD_Numbers() and have just this number appear, and as such LCD_Arrows() and have the corresponding arrow appear.

and... theres always one more thing... I would like to use portD, which means making sure that there is no way that anything gets put on segments 5,6,and 7 (All special segments except 9 are ok tho). How can I be sure of this by modifying your driver?

TIA

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there!
I've got a Butterfly, and I'm trying since fife weeks to write something on the display...
I'm new on AVR but I know the C-Language well. I've tried to make a new Project with AVRStudio 5 and copied the code from Dean (first comment) I've made a headerfile for the LDC_Driver.h but nothing works... :(
The only thing I can do, is to put the programm which was on it at first.
I'm becoming desperate of trying...
Can somebody help, even when it's a old thread??

THX in advence

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Will this code work with my Atmega169?

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depends if it's attached to an LCD with the same segment layout as the Atmel Butterfly or not.

However even if the segment layout is different the general technique should be adaptable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Depends if it's attached to an LCD with the same segment layout as the Atmel Butterfly or not.

However even if the segment layout is different the general technique should be adaptable.

Well, it is an AVR Butterly board.

Please let me know what you mean by "LCd with the same segment layout as the Atmel Butteryfly or not."

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Well, it is an AVR Butterly board.

This is a joke right? It's a LCD driver for the Butterfly board, which has the ATMEGA169 on it. Therefore, if you have a Butterfly board with said MEGA169 on it there's a fairly good chance it will be compatible.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks buddy....it helped me a lot!

Success is optional, choose wisely!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Dean for posting the LCD driver - it worked for me perfectly the first time.

Pages