|
www.elektronik.si Forum o elektrotehniki in računalništvu
|
Poglej prejšnjo temo :: Poglej naslednjo temo |
Avtor |
Sporočilo |
trot Član
Pridružen-a: Čet 18 Jan 2007 20:25 Prispevkov: 1270 Aktiv.: 6.05 Kraj: glej fogl
|
Objavljeno: Čet Sep 11, 2008 12:04 pm Naslov sporočila: |
|
|
lojzek je napisal/a: |
Povsem enak efekt bi torej dobil tudi z maskami. Npr. ADCSRA |= 0b01000100 |
Točno tako, to premikanje enke je samo način generiranja maske, ki je enostavnejši, poleg tega pa je tudi koda bolj razumljiva, ker če bi direktno pisal masko čez en teden ne bi več vedel, kaj dela koda v tej vrstici. _________________ lp, Klemen |
|
Nazaj na vrh |
|
|
jstajnko Član
Pridružen-a: Sre 03 Sep 2008 11:19 Prispevkov: 10 Aktiv.: 0.05 Kraj: koracice
|
Objavljeno: Ned Sep 21, 2008 8:27 pm Naslov sporočila: |
|
|
Mene pa zanima kako narediti števec, ko pritisnem na tipko se naj na lcd-ju izpiše 1, ko ponovno pritisnem se naj izpiše 2 itd.
koda ki sem jo napisal:
while (1)
if (PIND.4 == 1)
{
i+=1;
lcd_putchar(i);
}
Ampak ta koda ne deluje, samo čudni znaki se izpisujejo po celem lcd-ju. |
|
Nazaj na vrh |
|
|
VolkD Član
Pridružen-a: Pet 24 Sep 2004 21:58 Prispevkov: 14228 Aktiv.: 63.86 Kraj: Divača (Kačiče)
|
Objavljeno: Ned Sep 21, 2008 9:18 pm Naslov sporočila: |
|
|
jstajnko je napisal/a: |
Ampak ta koda ne deluje, samo čudni znaki se izpisujejo po celem lcd-ju. |
Ja saj potem dela prav. Mislim... točno tako kot si napisal.
Če boš tole:
spremenil v
bodo pa čudni znaki na lcd-ju leteli le če boš tipko pritisnil... _________________ Dokler bodo ljudje mislili, da živali ne čutijo, bodo živali čutile, da ljudje ne mislijo. |
|
Nazaj na vrh |
|
|
lojzek Član
Pridružen-a: Pet 25 Jan 2008 8:00 Prispevkov: 3353 Aktiv.: 16.97
|
Objavljeno: Pon Sep 22, 2008 6:37 am Naslov sporočila: |
|
|
Pa še nekaj.. Ali ne napiše putchar ASCII znak s tisto številko?
Se pravi, bi moral nekako šteti pritiske, potem bi moral šteti spuste tipk, potem pa to številko predelati v kombinacijo ASCII znakov in te izpisati na LCD. Pa vsakič, ko kličeš funkcijo putchar, ti bo napisalo na naslednje mesto in boš imel hitro poln ekran. Se pravi.. Vsakič, ko boš pisal, se postavi na isto pozicijo na LCDju.
PS še 1× ali pa tudi večkrat preberi tole celotno temo. Je notri marsikaj koristnega! Mogoče tudi rešitev tvojega problema. |
|
Nazaj na vrh |
|
|
nakamichi Član
Pridružen-a: Pon 21 Avg 2006 18:51 Prispevkov: 845 Aktiv.: 3.93 Kraj: Nova Gorica
|
Objavljeno: Pet Dec 19, 2008 10:11 pm Naslov sporočila: |
|
|
Danes sem prvič naletel na to napako
Koda: |
rm -rf utripanje_ledice.o utripanje_ledice.elf dep/* utripanje_ledice.hex utripanje_ledice.eep utripanje_ledice.lss utripanje_ledice.map
Build succeeded with 0 Warnings...
avr-gcc.exe -mmcu=atmega168 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT utripanje_ledice.o -MF dep/utripanje_ledice.o.d -c ../utripanje_ledice.c
../utripanje_ledice.c: In function 'main':
../utripanje_ledice.c:5: error: 'DDRA' undeclared (first use in this function)
../utripanje_ledice.c:5: error: (Each undeclared identifier is reported only once
../utripanje_ledice.c:5: error: for each function it appears in.)
../utripanje_ledice.c:6: error: 'DATAA' undeclared (first use in this function)
make: *** [utripanje_ledice.o] Error 1
|
Kljub kar nekaj programiranja do sedaj te napake, da PORT-a nebi našel še nisem videl. Ima kdo izkušnje, rešitve? Mikrokrmilnik je definiran, pišem v AVR Studio.
Koda: |
#include <avr\io.h>
int main(void)
{
DDRA = 0xff;
DATAA = 0x01;
} |
L.P.,
Miha |
|
Nazaj na vrh |
|
|
jvolk Član
Pridružen-a: Ned 05 Mar 2006 1:14 Prispevkov: 737 Aktiv.: 3.34 Kraj: okolica Divače
|
Objavljeno: Pet Dec 19, 2008 10:45 pm Naslov sporočila: |
|
|
@nakamichi:
Verjetno tvoj mikrokontroler (oz tistega, ki si si zbral v projektu) nima porta A.
Z DATAA si pa verjetno mislil PORTA. |
|
Nazaj na vrh |
|
|
nakamichi Član
Pridružen-a: Pon 21 Avg 2006 18:51 Prispevkov: 845 Aktiv.: 3.93 Kraj: Nova Gorica
|
Objavljeno: Sob Dec 20, 2008 12:02 am Naslov sporočila: |
|
|
Res je, zatipkal sem se v sili pisanja testnega programa.
No prav si imel, očitno nisem prav pri sebi, saj sem samoumevno sklepal, da ga ima brez pogledat datasheet in tako izpadel precej....
Hvala za hiter odgovor.
L.P.,
Miha |
|
Nazaj na vrh |
|
|
RGorazd Član
Pridružen-a: Čet 20 Maj 2004 15:57 Prispevkov: 1712 Aktiv.: 7.68 Kraj: Ig
|
Objavljeno: Ned Feb 22, 2009 5:07 pm Naslov sporočila: |
|
|
Naj me prosim nekdo razsvetli ali pa ustreli.
Kam za vraga moram shraniti eno *.h datoteko (konkretneje lcd_lib) ali kaj za boga moram narediti z njo, da jo bo WinAvr prepoznal in jo pravilno tudi vključil?! Sploh se ne znajdem več. Preglodal sem avrfrike, strani od Winavr in bolj ko berem, bolj sem glup...ali pa so GCC orodja...
Prosim za pomoč. Samo en k*** displej bi rad oživel v tem okolju... _________________ .
._. _ _ ._. _.__. _|
[ (_](_)[ (_] /_(_]
._| |
|
Nazaj na vrh |
|
|
jjakob Član
Pridružen-a: Pet 19 Nov 2004 14:12 Prispevkov: 1348 Aktiv.: 6.05
|
Objavljeno: Ned Feb 22, 2009 5:40 pm Naslov sporočila: |
|
|
Potrebuješ .h in .c v mapi v kateri imaš main, vključiš pa ju z #include (...).h. |
|
Nazaj na vrh |
|
|
Sokrat Član
Pridružen-a: Čet 25 Avg 2005 11:00 Prispevkov: 5584 Aktiv.: 25.06
|
Objavljeno: Ned Feb 22, 2009 6:09 pm Naslov sporočila: |
|
|
Normalno v C-ju je, da gre za headerje, ki so v < > pogledat v include direktorij oz. pregleda cel include path, za tiste, ki so v " " pa v isti direktorij, kjer se nahaja .c. _________________ Ka ti bo pa torba ce si kupu kolo ? |
|
Nazaj na vrh |
|
|
RGorazd Član
Pridružen-a: Čet 20 Maj 2004 15:57 Prispevkov: 1712 Aktiv.: 7.68 Kraj: Ig
|
Objavljeno: Ned Feb 22, 2009 6:16 pm Naslov sporočila: |
|
|
Saj imam...
edino stvar ki jo uspem pridelati je cel kup rdečih pik v build listi
Nevem no...a je tako težko al sem tako tumpast? Kar se teh stvari tiče je Bascom res zakon! No, sam se moram navaditi. Vsaka pomoč bi mi prišla prav. A imaš mogoče ti kako delujočo knjižnico za 16x2 LCDje, kateri se da določiti na katerih pinih imaš obešen LCD (brez R/W) ter da se to da enotavno klicati?!
Hvala. _________________ .
._. _ _ ._. _.__. _|
[ (_](_)[ (_] /_(_]
._| |
|
Nazaj na vrh |
|
|
Sokrat Član
Pridružen-a: Čet 25 Avg 2005 11:00 Prispevkov: 5584 Aktiv.: 25.06
|
Objavljeno: Ned Feb 22, 2009 6:17 pm Naslov sporočila: |
|
|
Pripni relevantni del kode in izpisa build procesa, od ugibanja ne bo nobene koristi. _________________ Ka ti bo pa torba ce si kupu kolo ? |
|
Nazaj na vrh |
|
|
RGorazd Član
Pridružen-a: Čet 20 Maj 2004 15:57 Prispevkov: 1712 Aktiv.: 7.68 Kraj: Ig
|
Objavljeno: Ned Feb 22, 2009 6:25 pm Naslov sporočila: |
|
|
Ja. Evo, poizkusil sem samo inicializirati LCD...pa...
Koda: |
#include "lcd_lib.h"
void main(void)
{
while(1)
{
LCDinit();
}
}
|
lcd_lib.h
Koda: |
#ifndef LCD_LIB
#define LCD_LIB
#include <inttypes.h>
//Uncomment this if LCD 4 bit interface is used
//******************************************
#define LCD_4bit
//***********************************************
#define LCD_RS 1 //define MCU pin connected to LCD RS
#define LCD_RW 2 //define MCU pin connected to LCD R/W
#define LCD_E 0 //define MCU pin connected to LCD E
#define LCD_D0 0 //define MCU pin connected to LCD D0
#define LCD_D1 1 //define MCU pin connected to LCD D1
#define LCD_D2 2 //define MCU pin connected to LCD D1
#define LCD_D3 3 //define MCU pin connected to LCD D2
#define LCD_D4 7 //define MCU pin connected to LCD D3
#define LCD_D5 6 //define MCU pin connected to LCD D4
#define LCD_D6 5 //define MCU pin connected to LCD D5
#define LCD_D7 4 //define MCU pin connected to LCD D6
#define LDP PORTD //define MCU port connected to LCD data pins
#define LCP PORTD //define MCU port connected to LCD control pins
#define LDDR DDRD //define MCU direction register for port connected to LCD data pins
#define LCDR DDRD //define MCU direction register for port connected to LCD control pins
#define LCD_CLR 0 //DB0: clear display
#define LCD_HOME 1 //DB1: return to home position
#define LCD_ENTRY_MODE 2 //DB2: set entry mode
#define LCD_ENTRY_INC 1 //DB1: increment
#define LCD_ENTRY_SHIFT 0 //DB2: shift
#define LCD_ON_CTRL 3 //DB3: turn lcd/cursor on
#define LCD_ON_DISPLAY 2 //DB2: turn display on
#define LCD_ON_CURSOR 1 //DB1: turn cursor on
#define LCD_ON_BLINK 0 //DB0: blinking cursor
#define LCD_MOVE 4 //DB4: move cursor/display
#define LCD_MOVE_DISP 3 //DB3: move display (0-> move cursor)
#define LCD_MOVE_RIGHT 2 //DB2: move right (0-> left)
#define LCD_FUNCTION 5 //DB5: function set
#define LCD_FUNCTION_8BIT 4 //DB4: set 8BIT mode (0->4BIT mode)
#define LCD_FUNCTION_2LINES 3 //DB3: two lines (0->one line)
#define LCD_FUNCTION_10DOTS 2 //DB2: 5x10 font (0->5x7 font)
#define LCD_CGRAM 6 //DB6: set CG RAM address
#define LCD_DDRAM 7 //DB7: set DD RAM address
// reading:
#define LCD_BUSY 7 //DB7: LCD is busy
#define LCD_LINES 2 //visible lines
#define LCD_LINE_LENGTH 16 //line length (in characters)
// cursor position to DDRAM mapping
#define LCD_LINE0_DDRAMADDR 0x00
#define LCD_LINE1_DDRAMADDR 0x40
#define LCD_LINE2_DDRAMADDR 0x14
#define LCD_LINE3_DDRAMADDR 0x54
// progress bar defines
#define PROGRESSPIXELS_PER_CHAR 6
void LCDsendChar(uint8_t); //forms data ready to send to 74HC164
void LCDsendCommand(uint8_t); //forms data ready to send to 74HC164
void LCDinit(void); //Initializes LCD
void LCDclr(void); //Clears LCD
void LCDhome(void); //LCD cursor home
void LCDstring(uint8_t*, uint8_t); //Outputs string to LCD
void LCDGotoXY(uint8_t, uint8_t); //Cursor to X Y position
void CopyStringtoLCD(const uint8_t*, uint8_t, uint8_t);//copies flash string to LCD at x,y
void LCDdefinechar(const uint8_t *,uint8_t);//write char to LCD CGRAM
void LCDshiftRight(uint8_t); //shift by n characters Right
void LCDshiftLeft(uint8_t); //shift by n characters Left
void LCDcursorOn(void); //Underline cursor ON
void LCDcursorOnBlink(void); //Underline blinking cursor ON
void LCDcursorOFF(void); //Cursor OFF
void LCDblank(void); //LCD blank but not cleared
void LCDvisible(void); //LCD visible
void LCDcursorLeft(uint8_t); //Shift cursor left by n
void LCDcursorRight(uint8_t); //shif cursor right by n
// displays a horizontal progress bar at the current cursor location
// <progress> is the value the bargraph should indicate
// <maxprogress> is the value at the end of the bargraph
// <length> is the number of LCD characters that the bargraph should cover
//adapted from AVRLIB - displays progress only for 8 bit variables
void LCDprogressBar(uint8_t progress, uint8_t maxprogress, uint8_t length);
#endif
|
Ter lcd_lib.c
Koda: |
#include "lcd_lib.h"
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
const uint8_t LcdCustomChar[] PROGMEM=//define 8 custom LCD chars
{
0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, // 0. 0/5 full progress block
0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, // 1. 1/5 full progress block
0x00, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, // 2. 2/5 full progress block
0x00, 0x1F, 0x1C, 0x1C, 0x1C, 0x1C, 0x1F, 0x00, // 3. 3/5 full progress block
0x00, 0x1F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x00, // 4. 4/5 full progress block
0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, // 5. 5/5 full progress block
0x03, 0x07, 0x0F, 0x1F, 0x0F, 0x07, 0x03, 0x00, // 6. rewind arrow
0x18, 0x1C, 0x1E, 0x1F, 0x1E, 0x1C, 0x18, 0x00 // 7. fast-forward arrow
};
void LCDsendChar(uint8_t ch) //Sends Char to LCD
{
#ifdef LCD_4bit
//4 bit part
LDP=(ch&0b11110000);
LCP|=1<<LCD_RS;
LCP|=1<<LCD_E;
_delay_ms(1);
LCP&=~(1<<LCD_E);
LCP&=~(1<<LCD_RS);
_delay_ms(1);
LDP=((ch&0b00001111)<<4);
LCP|=1<<LCD_RS;
LCP|=1<<LCD_E;
_delay_ms(1);
LCP&=~(1<<LCD_E);
LCP&=~(1<<LCD_RS);
_delay_ms(1);
#else
//8 bit part
LDP=ch;
LCP|=1<<LCD_RS;
LCP|=1<<LCD_E;
_delay_ms(1);
LCP&=~(1<<LCD_E);
LCP&=~(1<<LCD_RS);
_delay_ms(1);
#endif
}
void LCDsendCommand(uint8_t cmd) //Sends Command to LCD
{
#ifdef LCD_4bit
//4 bit part
LDP=(cmd&0b11110000);
LCP|=1<<LCD_E;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
LDP=((cmd&0b00001111)<<4);
LCP|=1<<LCD_E;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
#else
//8 bit part
LDP=cmd;
LCP|=1<<LCD_E;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
#endif
}
void LCDinit(void)//Initializes LCD
{
#ifdef LCD_4bit
//4 bit part
_delay_ms(15);
LDP=0x00;
LCP=0x00;
LDDR|=1<<LCD_D7|1<<LCD_D6|1<<LCD_D5|1<<LCD_D4;
LCDR|=1<<LCD_E|1<<LCD_RW|1<<LCD_RS;
//---------one------
LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4; //4 bit mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//-----------two-----------
LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4; //4 bit mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//-------three-------------
LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|0<<LCD_D4; //4 bit mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//--------4 bit--dual line---------------
LCDsendCommand(0b00101000);
//-----increment address, invisible cursor shift------
LCDsendCommand(0b00001100);
//init 8 custom chars
uint8_t ch=0, chn=0;
while(ch<64)
{
LCDdefinechar((LcdCustomChar+ch),chn++);
ch=ch+8;
}
#else
//8 bit part
_delay_ms(15);
LDP=0x00;
LCP=0x00;
LDDR|=1<<LCD_D7|1<<LCD_D6|1<<LCD_D5|1<<LCD_D4|1<<LCD_D3
|1<<LCD_D2|1<<LCD_D1|1<<LCD_D0;
LCDR|=1<<LCD_E|1<<LCD_RW|1<<LCD_RS;
//---------one------
LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4|0<<LCD_D3
|0<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//-----------two-----------
LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4|0<<LCD_D3
|0<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//-------three-------------
LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4|0<<LCD_D3
|0<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//--------8 bit dual line----------
LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4|1<<LCD_D3
|0<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//-----increment address, invisible cursor shift------
LDP=0<<LCD_D7|0<<LCD_D6|0<<LCD_D5|0<<LCD_D4|1<<LCD_D3
|1<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(5);
//init custom chars
uint8_t ch=0, chn=0;
while(ch<64)
{
LCDdefinechar((LcdCustomChar+ch),chn++);
ch=ch+8;
}
#endif
}
void LCDclr(void) //Clears LCD
{
LCDsendCommand(1<<LCD_CLR);
}
void LCDhome(void) //LCD cursor home
{
LCDsendCommand(1<<LCD_HOME);
}
void LCDstring(uint8_t* data, uint8_t nBytes) //Outputs string to LCD
{
register uint8_t i;
// check to make sure we have a good pointer
if (!data) return;
// print data
for(i=0; i<nBytes; i++)
{
LCDsendChar(data[i]);
}
}
void LCDGotoXY(uint8_t x, uint8_t y) //Cursor to X Y position
{
register uint8_t DDRAMAddr;
// remap lines into proper order
switch(y)
{
case 0: DDRAMAddr = LCD_LINE0_DDRAMADDR+x; break;
case 1: DDRAMAddr = LCD_LINE1_DDRAMADDR+x; break;
case 2: DDRAMAddr = LCD_LINE2_DDRAMADDR+x; break;
case 3: DDRAMAddr = LCD_LINE3_DDRAMADDR+x; break;
default: DDRAMAddr = LCD_LINE0_DDRAMADDR+x;
}
// set data address
LCDsendCommand(1<<LCD_DDRAM | DDRAMAddr);
}
//Copies string from flash memory to LCD at x y position
//const uint8_t welcomeln1[] PROGMEM="AVR LCD DEMO\0";
//CopyStringtoLCD(welcomeln1, 3, 1);
void CopyStringtoLCD(const uint8_t *FlashLoc, uint8_t x, uint8_t y)
{
uint8_t i;
LCDGotoXY(x,y);
for(i=0;(uint8_t)pgm_read_byte(&FlashLoc[i]);i++)
{
LCDsendChar((uint8_t)pgm_read_byte(&FlashLoc[i]));
}
}
//defines char symbol in CGRAM
/*
const uint8_t backslash[] PROGMEM=
{
0b00000000,//back slash
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
0b00000000,
0b00000000
};
LCDdefinechar(backslash,0);
*/
void LCDdefinechar(const uint8_t *pc,uint8_t char_code){
uint8_t a, pcc;
uint16_t i;
a=(char_code<<3)|0x40;
for (i=0; i<8; i++){
pcc=pgm_read_byte(&pc[i]);
LCDsendCommand(a++);
LCDsendChar(pcc);
}
}
void LCDshiftLeft(uint8_t n) //Scrol n of characters Right
{
for (uint8_t i=0;i<n;i++)
{
LCDsendCommand(0x1E);
}
}
void LCDshiftRight(uint8_t n) //Scrol n of characters Left
{
for (uint8_t i=0;i<n;i++)
{
LCDsendCommand(0x18);
}
}
void LCDcursorOn(void) //displays LCD cursor
{
LCDsendCommand(0x0E);
}
void LCDcursorOnBlink(void) //displays LCD blinking cursor
{
LCDsendCommand(0x0F);
}
void LCDcursorOFF(void) //turns OFF cursor
{
LCDsendCommand(0x0C);
}
void LCDblank(void) //blanks LCD
{
LCDsendCommand(0x08);
}
void LCDvisible(void) //Shows LCD
{
LCDsendCommand(0x0C);
}
void LCDcursorLeft(uint8_t n) //Moves cursor by n poisitions left
{
for (uint8_t i=0;i<n;i++)
{
LCDsendCommand(0x10);
}
}
void LCDcursorRight(uint8_t n) //Moves cursor by n poisitions left
{
for (uint8_t i=0;i<n;i++)
{
LCDsendCommand(0x14);
}
}
//adapted fro mAVRLIB
void LCDprogressBar(uint8_t progress, uint8_t maxprogress, uint8_t length)
{
uint8_t i;
uint16_t pixelprogress;
uint8_t c;
// draw a progress bar displaying (progress / maxprogress)
// starting from the current cursor position
// with a total length of "length" characters
// ***note, LCD chars 0-5 must be programmed as the bar characters
// char 0 = empty ... char 5 = full
// total pixel length of bargraph equals length*PROGRESSPIXELS_PER_CHAR;
// pixel length of bar itself is
pixelprogress = ((progress*(length*PROGRESSPIXELS_PER_CHAR))/maxprogress);
// print exactly "length" characters
for(i=0; i<length; i++)
{
// check if this is a full block, or partial or empty
// (u16) cast is needed to avoid sign comparison warning
if( ((i*(uint16_t)PROGRESSPIXELS_PER_CHAR)+5) > pixelprogress )
{
// this is a partial or empty block
if( ((i*(uint16_t)PROGRESSPIXELS_PER_CHAR)) > pixelprogress )
{
// this is an empty block
// use space character?
c = 0;
}
else
{
// this is a partial block
c = pixelprogress % PROGRESSPIXELS_PER_CHAR;
}
}
else
{
// this is a full block
c = 5;
}
// write character to display
LCDsendChar(c);
}
}
|
Vse tri. Test_lcd.c (moj main program), lcd_lib.h ter lcd_lib.c se nahajajo v isti mapi.
Build proess javi tole:
rm -rf TestLCD.o TestLCD.elf dep/* TestLCD.hex TestLCD.eep TestLCD.lss TestLCD.map
Build succeeded with 0 Warnings...
avr-gcc -I"C:\Documents and Settings\Gorazd\My Documents\TestLCD\." -mmcu=atmega8 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=12000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT TestLCD.o -MF dep/TestLCD.o.d -c ../Te
stLCD.c
../TestLCD.c:3: warning: return type of 'main' is not 'int'
avr-gcc -mmcu=atmega8 -Wl,-Map=TestLCD.map TestLCD.o -l -o TestLCD.elf
avr-gcc: TestLCD.elf: No such file or directory
make: *** [TestLCD.elf] Error 1
Build failed with 1 errors and 1 warnings...
Hvala za pomoč. _________________ .
._. _ _ ._. _.__. _|
[ (_](_)[ (_] /_(_]
._| |
|
Nazaj na vrh |
|
|
jjakob Član
Pridružen-a: Pet 19 Nov 2004 14:12 Prispevkov: 1348 Aktiv.: 6.05
|
Objavljeno: Ned Feb 22, 2009 6:53 pm Naslov sporočila: |
|
|
popravi v
Za drugo napako pa pripni makefile, tam imaš nekaj narobe nastavljeno. |
|
Nazaj na vrh |
|
|
RGorazd Član
Pridružen-a: Čet 20 Maj 2004 15:57 Prispevkov: 1712 Aktiv.: 7.68 Kraj: Ig
|
Objavljeno: Ned Feb 22, 2009 6:56 pm Naslov sporočila: |
|
|
1. popravil
2.
Koda: |
###############################################################################
# Makefile for the project TestLCD
###############################################################################
## General Flags
PROJECT = TestLCD
MCU = atmega8
TARGET = TestLCD.elf
CC = avr-gcc
## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)
## Compile options common for all C compilation units.
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=12000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS += -Wl,-Map=TestLCD.map
## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
## Include Directories
INCLUDES = -I"C:\Documents and Settings\Gorazd\My Documents\TestLCD\."
## Libraries
LIBS = -l
## Objects that must be built in order to link
OBJECTS = TestLCD.o
## Objects explicitly added by the user
LINKONLYOBJECTS =
## Build
all: $(TARGET) TestLCD.hex TestLCD.eep TestLCD.lss size
## Compile
TestLCD.o: ../TestLCD.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
##Link
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
%.hex: $(TARGET)
avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@
%.eep: $(TARGET)
-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
%.lss: $(TARGET)
avr-objdump -h -S $< > $@
size: ${TARGET}
@echo
@avr-size -C --mcu=${MCU} ${TARGET}
## Clean target
.PHONY: clean
clean:
-rm -rf $(OBJECTS) TestLCD.elf dep/* TestLCD.hex TestLCD.eep TestLCD.lss TestLCD.map
## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
|
_________________ .
._. _ _ ._. _.__. _|
[ (_](_)[ (_] /_(_]
._| |
|
Nazaj na vrh |
|
|
|
|
Ne, ne moreš dodajati novih tem v tem forumu Ne, ne moreš odgovarjati na teme v tem forumu Ne, ne moreš urejati svojih prispevkov v tem forumu Ne, ne moreš brisati svojih prispevkov v tem forumu Ne ne moreš glasovati v anketi v tem forumu Ne, ne moreš pripeti datotek v tem forumu Ne, ne moreš povleči datotek v tem forumu
|
Uptime: 70 dni
Powered by phpBB © 2001, 2005 phpBB Group
|