[CODE] [C] Simple Butterfly LCD driver

Go To Last Post
123 posts / 0 new

Pages

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

Maybe he fails to realize that this is page 3 of the thread...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

hehehe..
sorry guys...

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

hey there..

the code that dean post on the first page of this forum really help me
but my question is which code i want to use.is it .c or .h.

when i build the .c code using avr studio it stated that this code have error but when i build with .h code there is no error

could someone tell me which code are suitable for this software?(avr studio)

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

You need both .c and .h files. The question reveals that your knowledge of the C programming language is close to none. You should get a good book on C and start reading.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

i still can't build the code

there are errors and warning

these are the error that my avr show when i build that code

Quote:
Build started 25.3.2009 at 23:37:15
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -O0 -MD -MP -MT demo1.o -MF dep/demo1.o.d -c ../demo1.c
../demo1.c:2:24: error: LCD_Driver.h: No such file or directory
../demo1.c:5: error: 'LCD_TEXTBUFFER_SIZE' undeclared here (not in a function)
../demo1.c:5: error: 'LCD_DISPLAY_SIZE' undeclared here (not in a function)
../demo1.c:5: error: empty scalar initializer
../demo1.c:5: error: (near initialization for 'TextBuffer')
../demo1.c:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'StrStart'
../demo1.c:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'StrEnd'
../demo1.c:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ScrollCount'
../demo1.c:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'UpdateDisplay'
../demo1.c:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ShowColons'
../demo1.c:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ScrollFlags'
../demo1.c:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'LCD_SegTable'
../demo1.c: In function 'LCD_Init':
../demo1.c:82: warning: implicit declaration of function 'LCD_CONTRAST_LEVEL'
../demo1.c:85: error: 'LCDCRB' undeclared (first use in this function)
../demo1.c:85: error: (Each undeclared identifier is reported only once
../demo1.c:85: error: for each function it appears in.)
../demo1.c:85: error: 'LCDCS' undeclared (first use in this function)
../demo1.c:85: error: 'LCDMUX0' undeclared (first use in this function)
../demo1.c:85: error: 'LCDPM0' undeclared (first use in this function)
../demo1.c:88: error: 'LCDFRR' undeclared (first use in this function)
../demo1.c:88: error: 'LCDPS0' undeclared (first use in this function)
../demo1.c:88: error: 'LCDCD0' undeclared (first use in this function)
../demo1.c:91: error: 'LCDCRA' undeclared (first use in this function)
../demo1.c:91: error: 'LCDEN' undeclared (first use in this function)
../demo1.c:91: error: 'LCDAB' undeclared (first use in this function)
../demo1.c:91: error: 'LCDIE' undeclared (first use in this function)
../demo1.c: In function 'LCD_puts_f':
../demo1.c:107: warning: implicit declaration of function 'strcpy_P'
../demo1.c:108: warning: implicit declaration of function 'LCD_puts'
../demo1.c: At top level:
../demo1.c:118: warning: conflicting types for 'LCD_puts'
../demo1.c:108: warning: previous implicit declaration of 'LCD_puts' was here
../demo1.c: In function 'LCD_puts':
../demo1.c:119: error: 'uint8_t' undeclared (first use in this function)
../demo1.c:119: error: expected ';' before 'LoadB'
../demo1.c:120: error: expected ';' before 'CurrByte'
../demo1.c:124: error: 'CurrByte' undeclared (first use in this function)
../demo1.c:131: error: 'LoadB' undeclared (first use in this function)
../demo1.c:136: error: 'LCD_SPACE_OR_INVALID_CHAR' undeclared (first use in this function)
../demo1.c:141: error: 'ScrollFlags' undeclared (first use in this function)
../demo1.c:141: error: 'LCD_FLAG_SCROLL' undeclared (first use in this function)
../demo1.c:143: error: expected ';' before 'Nulls'
../demo1.c:143: error: 'Nulls' undeclared (first use in this function)
../demo1.c:148: error: 'StrStart' undeclared (first use in this function)
../demo1.c:149: error: 'StrEnd' undeclared (first use in this function)
../demo1.c:150: error: 'ScrollCount' undeclared (first use in this function)
../demo1.c:150: error: 'LCD_SCROLLCOUNT_DEFAULT' undeclared (first use in this function)
../demo1.c:150: error: 'LCD_DELAYCOUNT_DEFAULT' undeclared (first use in this function)
../demo1.c:151: error: 'UpdateDisplay' undeclared (first use in this function)
../demo1.c:151: error: 'true' undeclared (first use in this function)
../demo1.c: At top level:
../demo1.c:161: warning: return type defaults to 'int'
../demo1.c: In function 'ISR':
../demo1.c:162: error: 'ScrollFlags' undeclared (first use in this function)
../demo1.c:162: error: 'LCD_FLAG_SCROLL' undeclared (first use in this function)
../demo1.c:164: error: 'ScrollCount' undeclared (first use in this function)
../demo1.c:166: error: 'UpdateDisplay' undeclared (first use in this function)
../demo1.c:166: error: 'true' undeclared (first use in this function)
../demo1.c:167: error: 'LCD_SCROLLCOUNT_DEFAULT' undeclared (first use in this function)
../demo1.c:173: error: 'uint8_t' undeclared (first use in this function)
../demo1.c:173: error: expected ';' before 'Character'
../demo1.c:173: error: 'Character' undeclared (first use in this function)
../demo1.c:175: error: expected ';' before 'Byte'
../demo1.c:177: error: 'Byte' undeclared (first use in this function)
../demo1.c:177: error: 'StrEnd' undeclared (first use in this function)
../demo1.c:180: warning: implicit declaration of function 'LCD_WriteChar'
../demo1.c:183: error: 'StrStart' undeclared (first use in this function)
../demo1.c:184: error: 'LCD_FLAG_SCROLL_DONE' undeclared (first use in this function)
../demo1.c:189: error: 'ShowColons' undeclared (first use in this function)
../demo1.c:190: error: expected expression before ')' token
../demo1.c:190: error: 'LCD_LCDREGS_START' undeclared (first use in this function)
../demo1.c:192: error: expected expression before ')' token
../demo1.c:194: error: 'false' undeclared (first use in this function)
../demo1.c:196: warning: control reaches end of non-void function
../demo1.c: At top level:
../demo1.c:204: warning: type defaults to 'int' in declaration of 'uint8_t'
../demo1.c:204: error: expected ';', ',' or ')' before 'Byte'
../demo1.c:232: warning: type defaults to 'int' in declaration of 'uint8_t'
../demo1.c:232: error: expected ';', ',' or ')' before 'ColonsOn'
In file included from ../demo1.c:253:
c:/winavr/bin/../avr/include/avr/pgmspace.h:857: error: conflicting types for 'strcpy_P'
../demo1.c:107: error: previous implicit declaration of 'strcpy_P' was here
../demo1.c:283: warning: conflicting types for 'LCD_WriteChar'
../demo1.c:283: error: static declaration of 'LCD_WriteChar' follows non-static declaration
../demo1.c:180: error: previous implicit declaration of 'LCD_WriteChar' was here
make: *** [demo1.o] Error 1
Build failed with 67 errors and 11 warnings...

hope you can help me

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

As often the case the only important error in all thta is:

../demo1.c:2:24: error: LCD_Driver.h: No such file or directory 

I'd concentrate on that one first and once you've resolved it I'm guessing the other errors will evaporate.

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

oh ok..
so i must install the LCD driver 1st rite??

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

"install" - what are you talking about?

You go to the first post in this thread. You select all the text under LCD_Driver.c you copy it, you create a blank file called LCD_Driver.c and paste it in then save it. You then do the same with the text under LCD_Driver.h and save that to LCD_Driver.h. You make sure these two files are in the same directory as your other project files. In one of your own .c files where you plan to use functions in LCD_Driver.c you simply add the line:

#include "LCD_Driver.h"

Then in the list of files to be built in the project you add LCD-Driver.c to the list. Now build the project and it should all just work.

Cliff

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

Make sure that a copy of both the .c and the .h file are in the directory used by your AVRStudio project. In the AVR GCC directory tree on the left of AVRStudio click on 'Source Files' and 'Add Existing File(s)' to add the .c file, then in the 'Header Files' also use 'Add Existing File(s)' to add the .h file. Now when you click Compile AVRStudio should be able to find both files.

Smiley

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

i follow what you ask me to do and i can build it.
but the prob is the program shows warning there

Quote:
rm -rf fyp.o fyp.elf dep/* fyp.hex fyp.eep
Build succeeded with 0 Warnings...
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -DF_CPU=1000000UL -O0 -fsigned-char -std=gnu99 -MD -MP -MT fyp.o -MF dep/fyp.o.d -c ../fyp.c
In file included from ../fyp.c:2:
../LCD_Driver.h:48:8: warning: no newline at end of file
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -DF_CPU=1000000UL -O0 -fsigned-char -std=gnu99 -MD -MP -MT LCD_Driver.o -MF dep/LCD_Driver.o.d -c ../LCD_Driver.c
In file included from ../LCD_Driver.c:21:
../LCD_Driver.h:48:8: warning: no newline at end of file
../LCD_Driver.c:255:3: warning: no newline at end of file

avr-gcc.exe -mmcu=atmega169 fyp.o LCD_Driver.o -lm -o fyp.elf
avr-objcopy -O ihex -R .eeprom fyp.elf fyp.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex fyp.elf fyp.eep || exit 0
c:\WinAVR\bin\avr-objcopy.exe: there are no sections to be copied!

AVR Memory Usage
----------------
Device: atmega169

Program: 1718 bytes (10.5% Full)
(.text + .data + .bootloader)

Data: 33 bytes (3.2% Full)
(.data + .bss + .noinit)

Build succeeded with 3 Warnings...

what the problem with that warning

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

Quote:

warning: no newline at end of file

Well what do you THINK that warning means?

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

Quote:

what the problem with that warning

The problem is exactly what the warning says. There is no newline at the end of the file. How can that be unclear?

IIRC this can be a problem for the some compilers (not seeing the last token in the file). The simple remedy is to edit those files. Go to the last line. Place the caret after that last character on the line. Hit enter. Save the file and exit. Repeat for all files that generate the warning.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

i follow what you ask me to do and i can build it.
but the prob is the program shows warning there

Quote:
rm -rf fyp.o fyp.elf dep/* fyp.hex fyp.eep
Build succeeded with 0 Warnings...
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -DF_CPU=1000000UL -O0 -fsigned-char -std=gnu99 -MD -MP -MT fyp.o -MF dep/fyp.o.d -c ../fyp.c
In file included from ../fyp.c:2:
../LCD_Driver.h:48:8: warning: no newline at end of file
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -DF_CPU=1000000UL -O0 -fsigned-char -std=gnu99 -MD -MP -MT LCD_Driver.o -MF dep/LCD_Driver.o.d -c ../LCD_Driver.c
In file included from ../LCD_Driver.c:21:
../LCD_Driver.h:48:8: warning: no newline at end of file
../LCD_Driver.c:255:3: warning: no newline at end of file

avr-gcc.exe -mmcu=atmega169 fyp.o LCD_Driver.o -lm -o fyp.elf
avr-objcopy -O ihex -R .eeprom fyp.elf fyp.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex fyp.elf fyp.eep || exit 0
c:\WinAVR\bin\avr-objcopy.exe: there are no sections to be copied!

AVR Memory Usage
----------------
Device: atmega169

Program: 1718 bytes (10.5% Full)
(.text + .data + .bootloader)

Data: 33 bytes (3.2% Full)
(.data + .bss + .noinit)

Build succeeded with 3 Warnings...

what the problem with that warning

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

I'm out.

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

sorry about the double post..
internet connection at my place so slow so it cause error like that

anyway thanks for the advice
my program now work properly without warning
you are really nice people

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

Hye,
I have compile both keypad and lcd butterfly code C in a AVR Studio without warning and error.
But after i downloaded to AVR there was a buzzing sound appear.
Why is it happened?? Is it my coding mistake or AVR problem?

I attach the code for reference. Hope someone can help.. :cry:

Attachment(s): 

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

Look at the Butterfly schematic to see which pin is attached to the piezo element (buzzer) then note which part of you code is toggling that pin at an audio frequency.

Smiley

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

i already change my keypad from PORTB to PORTD and i don't hear any "buzzing" sound.

but my problem now is the LCD doesn't show anything when i download the program to AVR

i'm using LCD driver which i get on the 1st thread of this forum

could anybody help me

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

You really need to look at the Butterfly schematic.

Also read:
http://www.smileymicros.com/down...

Smiley

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

i already look the butterfly schematic but i still got the problem..

my keypad cannot sent data to buttefly lcd

this is my keypad code

Quote:

#include

int main()

{

//high nibble for output(columns) low for input(rows);

DDRB=0xF0;

//enable internal pullups for PB0-PB3

PORTB=0x0F;

//Port D for indication only

DDRD=0xFF;

while (1) //loop key check forever

{

//first column

PORTB =0b01111111;

//check for rows and send key number to portD

//instead sending key number to PORTD you can use

// any function that serves pressed button

if (bit_is_set(PINB, 3)) PORTD=1;

if (bit_is_set(PINB, 2)) PORTD=2;

if (bit_is_set(PINB, 1)) PORTD=3;

if (bit_is_set(PINB, 0)) PORTD=4;

//second column

PORTB =0b10111111;

if (bit_is_set(PINB, 3)) PORTD=5;

if (bit_is_set(PINB, 2)) PORTD=6;

if (bit_is_set(PINB, 1)) PORTD=7;

if (bit_is_set(PINB, 0)) PORTD=8;

//third column

PORTB =0b11011111;

if (bit_is_set(PINB, 3)) PORTD=9;

if (bit_is_set(PINB, 2)) PORTD=10;

if (bit_is_set(PINB, 1)) PORTD=11;

if (bit_is_set(PINB, 0)) PORTD=12;

//fourth column

PORTB =0b11101111;

if (bit_is_set(PINB, 3)) PORTD=13;

if (bit_is_set(PINB, 2)) PORTD=14;

if (bit_is_set(PINB, 1)) PORTD=15;

if (bit_is_set(PINB, 0)) PORTD=16;

}

}

what's the problem of this code because i can compile it on avr studio

is there any additional connection to interface this keypad and this butterfly lcd??

i really appreciate your kindest to help me find this problem

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

I must be misunderstanding your question since both the Butterfly schematics and the 'Butterfly Alternate Pin Uses' document that I provided a link to for you both show that PORTD is connected to the PORTD pad AND to 8 of the LCD pins - so as one should see on the schematic or read in the document, you cannot use PORTD for both the LCD and as an input port at the same time.

And I just looked at your code and now my question is: what function in your code is sending data to the LCD? Earlier you said you changed your keypad from PORTB to PORTD and the buzzing stopped, but your code doesn't show this. Were you trying to turn on individual LCD elements with the write to PORTD?

And looking further back, I see that Dean suggested you use his LCD driver, so now I'm even more confused about what you are asking.

Please answer:
1. Did you try to use Dean's driver?
2. If so, why doe's it not show up in you code listing?
3. If you read the Butterfly Schematics how could you not know that your code would cause the Piezo element to buzz?
4. You said that after you changed ports the buzzing stopped, but you show the same code unchanged?
4. And if you read the Schematics and the Alternate Pin Use document, how could you not know that moving the keypad to PORTD would interfere with the LCD?

Again, I must be missing something in your question.

Smiley

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

oh sorry..
i didn't mention it to you before..
after read the schematic i know that the Piezo element is in PINB5.
It's true that in the early i try to connect my keypad to PORTD but after reading the schematic, i change it back to PORTB because i realize PORTD will interfere the LCD.

my answer for your question..

1. yes, i 'm using dean's driver.
2. i send you the full code of my program include Dean's driver.
3. i already ask my friends.they said maybe the connection from the keypad to butterfly makes the buzzing sound.
your question 4 and 5 i already explain at above

sorry again because sending you the not update program

here i send you my new program

hope i already answer your question..

thanks

Attachment(s): 

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

Your keypad.c code:

#include 
#include "LCD_Driver.h"

int main()

{

//high nibble for output(columns) low for input(rows);

DDRD=0xF0;

//enable internal pullups for PB0-PB3

PORTD=0x0F;

//Port D for indication only

DDRB=0xFF;

while (1) //loop key check forever

	{

		//first column

		PORTD =0b01111111;

		//check for rows and send key number to portD

		//instead sending key number to PORTD you can use

		// any function that serves pressed button

		if (bit_is_set(PIND, 3)) PORTB=1;

		if (bit_is_set(PIND, 2)) PORTB=2;

		if (bit_is_set(PIND, 1)) PORTB=3;

		if (bit_is_set(PIND, 0)) PORTB=4;

		//second column

		PORTD =0b10111111;

		if (bit_is_set(PIND, 3)) PORTB=5;

		if (bit_is_set(PIND, 2)) PORTB=6;

		if (bit_is_set(PIND, 1)) PORTB=7;

		if (bit_is_set(PIND, 0)) PORTB=8;

		//third column

		PORTD =0b11011111;

		if (bit_is_set(PIND, 3)) PORTB=9;

		if (bit_is_set(PIND, 2)) PORTB=10;

		if (bit_is_set(PIND, 1)) PORTB=11;

		if (bit_is_set(PIND, 0)) PORTB=12;

		//fourth column

		PORTD =0b11101111;

		if (bit_is_set(PIND, 3)) PORTB=13;

		if (bit_is_set(PIND, 2)) PORTB=14;

		if (bit_is_set(PIND, 1)) PORTB=15;

		if (bit_is_set(PIND, 0)) PORTB=16;

	}

}

Now I know I'm missing your question because this code has nothing in it that uses Dean's LCD code. I thought your question was about getting the output of a keypad to show on a the Butterfly LCD using Dean's code, but I don't see anywhere that you use Dean's code, so what am I missing?

Smiley

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

sorry..
i really confuse now..
what do you mean by this keypad code has nothing in it that uses Dean's LCD code.
am i using a wrong coding for this keypad?
what the function of #include "LCD_Driver.h"

if my keypad program is wrong, can you help and guide me how to make my project works or can you give some suggestion what link should i go and guidelines to settle this problem

thanks :?

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

Quote:

what do you mean by this keypad code has nothing in it that uses Dean's LCD code.

Just #include'ing a .h file does NOT make use of any of the facilities it provides. This only happens when you call one or more of the functions that it documents.

To USE the LCD library you should be calling LCD_Init() near the start of your program and then later (probably) LCD_puts() to put message strings on the display. Otherwise what were you expecting to see on the display?

Cliff

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

amiraliff wrote:
sorry..
i really confuse now..
what do you mean by this keypad code has nothing in it that uses Dean's LCD code.
am i using a wrong coding for this keypad?
what the function of #include "LCD_Driver.h"

if my keypad program is wrong, can you help and guide me how to make my project works or can you give some suggestion what link should i go and guidelines to settle this problem

thanks :?

Please read:
https://www.avrfreaks.net/index.p...
Then get the Butterfly Quick Start Guide from my website along with the Butterfly FAQ and a few other free and helpful documents that you can use to get started. I would further suggest you look at some of the source code I provide and at the Smiley's Workshops to learn the fundamentals before attempting a keypad.

After reading all this then if you have additional questions please start a new thread on using a keypad with a Butterfly. This tread is not the appropriate place for this discussion.

Smiley

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

hi again
im having a problem with dean's lcd driver

when i try to compile this driver, there is an error's appear

Quote:
c:/winavr/bin/../lib/gcc/avr/4.1.1/../../../../avr/lib/avr5/crtm169p.o:(.init9+0x0): undefined reference to `main'
make: *** [lcd.elf] Error 1

hope u guys out there can help me

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

Well that's telling you that no where in the files being compiled is there a function called main() - all C programs must have this.

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

oh...

so where should i put the main() function

i try to write it but there still have an error

so can u tell me where the best place i should write this function

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

hi
i already download dean's driver on my butterfly but it shows nothing on my butterfly lcd.

what's the problem?

and what's the function of this code (i take from dean's driver)

Quote:
0xEAA8, // '*'
0x2A80, // '+'
0x4000, // ','
0x0A00, // '-'
0x0A51, // '.' Degree sign
0x4008, // '/'
0x5559, // '0'
0x0118, // '1'
0x1e11, // '2
0x1b11, // '3
0x0b50, // '4
0x1b41, // '5
0x1f41, // '6
0x0111, // '7
0x1f51, // '8
0x1b51, // '9'
0x0000, // ':' (Not defined)
0x0000, // ';' (Not defined)
0x8008, // '<'
0x1A00, // '='
0x4020, // '>'
0x0000, // '?' (Not defined)
0x0000, // '@' (Not defined)
0x0f51, // 'A' (+ 'a')
0x3991, // 'B' (+ 'b')
0x1441, // 'C' (+ 'c')
0x3191, // 'D' (+ 'd')
0x1e41, // 'E' (+ 'e')
0x0e41, // 'F' (+ 'f')
0x1d41, // 'G' (+ 'g')
0x0f50, // 'H' (+ 'h')
0x2080, // 'I' (+ 'i')
0x1510, // 'J' (+ 'j')
0x8648, // 'K' (+ 'k')
0x1440, // 'L' (+ 'l')
0x0578, // 'M' (+ 'm')
0x8570, // 'N' (+ 'n')
0x1551, // 'O' (+ 'o')
0x0e51, // 'P' (+ 'p')
0x9551, // 'Q' (+ 'q')
0x8e51, // 'R' (+ 'r')
0x9021, // 'S' (+ 's')
0x2081, // 'T' (+ 't')
0x1550, // 'U' (+ 'u')
0x4448, // 'V' (+ 'v')
0xc550, // 'W' (+ 'w')
0xc028, // 'X' (+ 'x')
0x2028, // 'Y' (+ 'y')
0x5009, // 'Z' (+ 'z')
0x1441, // '['
0x8020, // '\'
0x1111, // ']'
0x0000, // '^' (Not defined)
0x1000 // '_'

hope anyone can explain it to me

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

That's just data saying which segments should be lit to display the character listed in each comment

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

hi
i already download dean's driver on my butterfly but it shows nothing on my butterfly lcd.

what's the problem?

anyone can help??

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

Quote:

so where should i put the main() function

In one of your C source files.

In the earlier posts in this thread you reported that you succeeded to build and download a complete AVR application. This implies that you have at least some knowledge about the main function, why it is needed and where it should go, yes? If not, now is a good time to get a good book on the C programming language and start reading.

You do realise that Deans code in LCD_driver.c and LCD_driver.h is the LCD driver only with no main program? (In the Tutorial thread where he presented the driver he has posted a small main program a few posts down).

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Hey Guys,

I´m bit confused about the test program from Dean he wrote:

LCD_puts_f(PSTR("AVR BUTTERFLY GCC"));
LCD_puts("AVR BUTTERFLY GCC");

So in according to the LCD_Driver.c:
LCD_puts_f is storing data in the flash and LCD_puts in the SRAM (so its volatile).

If I write something only wit LCD_puts_f on the LCD screen it will disappear after the power was shutted of, but it´s not the case.

So the questition is why the data is still there?

Thanks

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

Quote:

So the questition is why the data is still there?

Well two options:

1) you've actually found a bistable (aka "Zero power") LCD - http://en.wikipedia.org/wiki/Liq... or

2) there's still power (maybe just a trickle capacitance?) to the LCD

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

Ok, but normally under no-power conditions after switching of the data from SRAM should be erased, isn´t it so?

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

In no power conditions nothing should appear - the crystals in the LCD need an AC biasing voltage continually applied to keep them twisted so they block the polarised light. If you remove power that process stops (except in "bistable") and they all untwist so that the display appears blank. If you are seeing something other than this then there MUST be power still applied or you have ghosts in the machine!

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

hi
i'm trying to use keypad and want to display it on my butterfly lcd
can i use dean's lcd driver?

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

Quote:

i'm trying to use keypad and want to display it on my butterfly lcd
can i use dean's lcd driver?

Maybe, but you have to prove it to us...

Point is: Given the vague technical description the answer probably is "yes, Deans driver should be usable in such a case".

Give us a stronger technical description and the answer will be more definite.

Or, do what I suspect you wanted to all along and ask "How?". In that case you must supply us with a more definite description of your project at this stage, or you will get no meaningful answers at all.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Hey,

I´ve tried to display a variable over the LCD_puts function, but it didn´t work.

So I wrote simple into the main function:

int x = 1;
LCD_puts(x);

But it comes nothing. It works, however, if I write insted: LCD_puts("x");

Where is the problem?

Thanks!

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

LCD_puts() is looking for a string as it's argument (ie, an array of characters with a null at the end).
To print the value of a variable, you need to convert it to a string first. You can use sprintf, itoa, or convert it yourself.
/mike

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

Thanks for the fast anwser! Now I got it, it was just too long that I programmed the last time.

But I noticed, that sprintf needs a lot of memory, is there another possibility to convert it to a string by myself?

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

Quote:

is there another possibility to convert it to a string by myself?

1. Look for a function itoa(...) in your run-time library.

2. Yes, you could write it yourself. Repeated integer division and remainder by 10 should give you the digits (from least to most significant) in the remainder and the number for the next repetition in the division result. In order to convert a single digit integer value to the corresponding character representation yuo just add the integer representation of the digit '0', like so

digitAsCharacter = digitInAnInteger + '0';

You build up your string from right to left (that order is the tricky part), and don't forget that the string should have a terminating zero char!

If you do a search of this site you will probably find several discussions on alternative implementations that might be more efficient in some aspect.

Unless you are in a real trouble with flash memory and really know what you are doing, I'd stay with itoa(...).

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

@JohanEkdahl: Thanks and greetings from Lulea!

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

Just to drag up a really old post . . . quick question on the interrupt routine. You say that the LCD ISR allows other interrupts, but I don't see anything explicitly allowing it. I would expect an sei() or similar, is that the case? In my application, I'm running TC1 at Fclk/8, and need to get a OC1B to do something. It seems like that just isn't happening frequently, and I'm guessing that if that interrupt doesn't get the timer value in the 8 clock cycles where the timer value and OC1B match, the interrupt is lost. I've checked all my other interrupts, and they're a couple clock cycles long at worst. Am I at least looking in the right place?
Thanks!

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

Hi,

You are correct that the latest version does not explicitly re-enable interrupts in the ISR to allow other interrupts to interrupt it while the ISR is running (boy, that's a mouthful to say!). The fix is as simple as changing:

ISR(LCD_vect)

To:

ISR(LCD_vect, ISR_NOBLOCK)

In a recent version of avr-libc (i.e. less than a year or two old).

- Dean :twisted:

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

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

Cool, thanks for the input. I'll give it a shot. I had tried manually enabling interrupts (sei) and disabling the LCD interrupt at the beginning of the interrupt, and re-enabling it at the end (again, a mouthful that is way to confusing), but no result. I ended up just changing my code around a bit to do a hardware PWM mode rather than software, but on the butterfly, that means PB5 is the only option when using the joystick, and it's tied to the speaker, very annoying results :P Time to start looking at a different controller and an external LCD if I get serious about this project! Thanks again!

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

I was getting all kinds of errors when I tried to compile code containing Atmel's LCD drivers, so I decided to use this one. I got the sample code Dean wrote to compile with no errors or warnings using WinAVR.

When I download the HEX file to my board using AVR Studio, nothing happens. I'm pretty sure I'm downloading it right, because when I put the default Butterfly program back on there, it works fine.

Any suggestions?

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

wegstar wrote:
thanks! :lol:
adding a sei(); before the init solved the problem.

I added sei() and the program worked!!! I've been working on this for 2 weeks!!! I'm so happy!! Here's the code I used:

#include
#include

int main(void)
{
sei();
LCD_Init();

LCD_puts_f(PSTR("AVR BUTTERFLY GCC"));
LCD_puts("AVR BUTTERFLY GCC");

for (;;) {}

return 0;
}

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

I also had trouble getting the LCD_WriteChar() function to work until I added universalist's macro and took "static inline" off of the original definition. Which I don't understand but guess I don't need to at this point. It took me a couple of tries to see that the order of the arguments was reversed ... not sure if that was intentional.

I appreciate Dean's tutorial. I'm new to using C on MCUs although I've been playing with them in assembler for quite some time. Lots to learn! I'm pursing two paths: first, starting with tiny programs that, for example, beep the piezo sounder when the joystick is moved, and second, trying to use other people's code (such as this driver) -- which I suppose is one of the big advantages of C.

Nick

Pages