Anonymní profil Ring – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil Ring – Programujte.comAnonymní profil Ring – Programujte.com

 

Příspěvky odeslané z IP adresy 89.177.245.–

3310
Mikrokontroléry › LCD PDC8544 + ATmega16 --- v…
28. 7. 2014   #192418

#1 3310
Tak jsem se trošku posunul. Našel jsem nějaké chyby v mých 2 funkcích.:

unsigned char char_start=0;

void LCD_writeChar_megaFont (unsigned char ch)
{
   unsigned char i, j;
   
   if(ch == '.')
    ch = 10;
   else if (ch == '+')
    ch = 11;
   else if (ch == '-')
    ch = 12;
   else
    ch = ch & 0x0f;
	
    
   /*for(i=0;i<3;i++)
   {	
	 LcdGotoXYFont (4 + char_start, i+2);
 
     for(j=0; j<16; j++)	
       		LcdSend( (pgm_read_byte(&number[ch][i][j])),LCD_DATA);
   } */

   	for (i=0;i<3;i++) {
		LcdGotoXYFont (char_start, i);

		for (j=0; j<16; j++) {
			LcdSend( (pgm_read_byte(&number[ch][i][j])),LCD_DATA);
         }
	}
   
   if(ch == '.') 
     char_start += 5;
   else
     char_start += 12;
}
void LCD_writeString_megaFont ( unsigned char *string )
{
    char_start = 0;
	
    while ( *string )
        LCD_writeChar_megaFont( *string++ );
}

Připojen obrázek.

3310
Mikrokontroléry › LCD PDC8544 + ATmega16 --- v…
27. 7. 2014   #192408

Ahoj kamarádi.

Už třetí den bojuju s fontem u tohoto displeje.

Displej funguje, ale chtěl bych mít druhý font, velké čísla, ale nedaří se.

Problém bych viděl u funkcí, které jsem se snažil přidat. Jde o tyto:

void LCD_writeChar_megaFont ( unsigned char character );
void LCD_writeString_megaFont ( unsigned char *string );


Font s velkýma číslama mám zde:

//******* VERY LARGE FONTS ********** 
//used here for displaying temperature

static const unsigned char number[13][3][16] PROGMEM = {

{{0,128,192,224,224,96,224,224,  //'0'
192,128,0,0,0,0,0,0}
,
{112,255,255,1,0,0,0,0,
255,255,254,0,0,0,0,0}
,
{0,15,31,60,56,48,56,56,
31,15,3,0,0,0,0,0}
},
{
{0,0,0,0,128,224,224,0, 		   //'1'
0,0,0,0,0,0,0,0}
,
{0,0,3,3,3,255,255,0,
0,0,0,0,0,0,0,0}
,
{0,0,56,56,56,63,63,56,
56,56,0,0,0,0,0,0}
},
{
{0,192,192,224,96,96,224,224,   //'2'
192,128,0,0,0,0,0,0}
,
{0,1,0,0,128,192,224,249,
63,31,0,0,0,0,0,0}
,
{0,60,62,63,63,59,57,56,
56,56,56,0,0,0,0,0}
},
{
{0,192,224,224,96,96,224,224,   //'3'
192,192,0,0,0,0,0,0}
,
{0,1,0,0,48,48,56,125,
239,207,0,0,0,0,0,0}
,
{0,28,56,56,48,48,56,60,
31,15,1,0,0,0,0,0}
},
{
{0,0,0,0,0,128,192,224, 		   //'4'
224,0,0,0,0,0,0,0}
,
{224,240,248,222,207,199,193,255,
255,192,192,0,0,0,0,0}
,
{0,0,0,0,0,0,0,63,
63,0,0,0,0,0,0,0}
},
{
{0,224,224,224,224,224,224,224,	//'5'
224,224,224,0,0,0,0,0}
,
{0,63,63,63,56,56,48,112,
240,224,0,0,0,0,0,0}
,
{0,28,56,56,48,48,56,60,
31,15,1,0,0,0,0,0}
},
{
{0,0,128,192,192,224,96,96,		//'6'
224,224,0,0,0,0,0,0}
,
{224,254,255,55,57,24,24,56,
240,240,192,0,0,0,0,0}
,
{0,15,31,28,56,48,48,56,
31,15,7,0,0,0,0,0}
},
{
{0,224,224,224,224,224,224,224,		 //'7'
224,224,224,0,0,0,0,0}
,
{0,0,0,0,128,224,248,126,
31,7,1,0,0,0,0,0}
,
{0,0,56,62,31,7,1,0,
0,0,0,0,0,0,0,0}
},
{
{0,128,192,224,224,96,96,224,		 //'8'
192,192,0,0,0,0,0,0}
,
{0,207,255,127,56,48,112,112,
255,239,199,0,0,0,0,0}
,
{3,15,31,60,56,48,48,56,
31,31,15,0,0,0,0,0}
},
{
{0,128,192,224,224,96,224,224,		 //'9'
192,128,0,0,0,0,0,0}
,
{12,63,127,241,224,192,192,225,
255,255,254,0,0,0,0,0}
,
{0,0,56,48,48,56,56,30,
15,7,0,0,0,0,0,0}
},
{

{0,0,0,0,0,0,0,0,	  		  		 //'.'
0,0,0,0,0,0,0,0}
,
{0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0}
,
{60,60,60,0,0,0,0,0,
0,0,0,0,0,0,0,0} 
},
{
{0,0,0,0,0,0,0,0,   					 //'+'
0,0,0,0,0,0,0,0}
,
{0,0,64,64,64,64,64,254,
254,64,64,64,64,64,0,0}
,
{0,0,0,0,0,0,0,15,
15,0,0,0,0,0,0,0}
},
{
{0,0,0,0,0,0,0,0, 	   				 //'-'
0,0,0,0,0,0,0,0}
,
{0,64,64,64,64,64,64,0,
0,0,0,0,0,0,0,0}
,
{0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0}
}};


Dvě zmíněné funkce jsou zde. Upravil jsem je pro knihovnu, kterou používám.

/*--------------------------------------------------------------------------------------------------
  Name         :  LCD_writeChar_megaFont
  Description  :  Displays a character at current cursor location and increment cursor location.
  Argument(s)  :  ch   -> Character to write.
  Return value :  None.
--------------------------------------------------------------------------------------------------*/
unsigned char char_start;
void LCD_writeChar_megaFont (unsigned char ch)
{
   unsigned char i, j;
   
   if(ch == '.')
    ch = 10;
   else if (ch == '+')
    ch = 11;
   else if (ch == '-')
    ch = 12;
   else
    ch = ch & 0x0f;
	
    
   for(i=0;i<3;i++)
   {	
	 LcdGotoXYFont (4 + char_start, i+2);
 
     for(j=0; j<16; j++)
       LcdSend( number[ch][i][j],LCD_DATA);
   } 
   
   if(ch == '.') 
     char_start += 5;
   else
     char_start += 12;
}

/*--------------------------------------------------------------------------------------------------
  Name         :  LCD_writeString_megaFont
  Description  :  Displays a character at current cursor location
  Argument(s)  :  string -> Pointer to ASCII string (stored in RAM)
  Return value :  None.
--------------------------------------------------------------------------------------------------*/
void LCD_writeString_megaFont ( unsigned char *string )
{
    char_start = 0;
	
    while ( *string )
        LCD_writeChar_megaFont( *string++ );
	
	LcdGotoXYFont(char_start+6, 3);
}


A jednotlivé funkce, které jsou funkční a ověřené, že fungují a jsou použity ve funkcích výše jsou zde:

byte LcdGotoXYFont ( byte x, byte y )
{
    /* Boundary check, slow down the speed but will guarantee this code wont fail */
    /* Version 0.2.5 - Fixed on Dec 25, 2008 (XMAS) */
    if( x > 14)
        return OUT_OF_BORDER;
    if( y > 6)
        return OUT_OF_BORDER;
    /*  Calculate index. It is defined as address within 504 bytes memory */

    LcdCacheIdx = ( x - 1 ) * 6 + ( y - 1 ) * 84;
    return OK;
}

static void LcdSend ( byte data, LcdCmdData cd )
{
    /*  Enable display controller (active low). */
    LCD_PORT &= ~( _BV( LCD_CE_PIN ) );

    if ( cd == LCD_DATA )
    {
        LCD_PORT |= _BV( LCD_DC_PIN );
    }
    else
    {
        LCD_PORT &= ~( _BV( LCD_DC_PIN ) );
    }

    /*  Send data to display controller. */
    SPDR = data;

    /*  Wait until Tx register empty. */
    while ( (SPSR & 0x80) != 0x80 );


    /* Disable display controller. */
    LCD_PORT |= _BV( LCD_CE_PIN );
}

A když už toto mám v, tak v kódu to volám takto:

		LcdGotoXYFont(3,3);
		LCD_writeString_megaFont ( tempDisplay );
		LcdUpdate();


A tempDisplay je deklrovaná takto:

unsigned char* tempDisplay = 5;

Jestli se najde dobrá duše a poradí, kde dělám chybu, budu určitě rád.

Ring
Mikrokontroléry › Chybne vycitani tlaku a tepl…
1. 3. 2014   #187792

Ahoj přátelé,

už 2 dny se snažím zobrazit teplotu a tlak z čídla CMP085, ale dostávám chybé údaje.

Výstup je nějaký takovýto:

teplota BMP085: -2550°C
tlak BMP085: 44516Pa

No hlavní smyčku mám takovouto:

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

#include "knihovny/uart.h"

#include "bmp.h"
#include "i2cmaster.h"

int32_t tlak=0, teplota=0;

int main(){

    uart_init(9600);	// inicializace uartu na rychlost 9600bd

	i2c_init();
	bmp_init();

    char text[64];	//textovy retezec k odesilani po uartu

    while(1){
        tlak=bmp_get_up();	//nacteni tlaku
        teplota=bmp_get_ut();	//nacteni teploty

        bmp_convert(&teplota, &tlak);	//zapnuti konverze
        sprintf(text, "teplota BMP085: %ld°C\n", teplota);	//vypis teploty
        uart_puts(text);
        sprintf(text, "tlak BMP085: %ldPa\n\n", tlak);	//vypis tlaku
        uart_puts(text);

        _delay_ms(1500);        // cakaj 1s
    }

    return 0;
}


Takt MCU je 16MHz.

Zde na odkazu přikládám pro jistotu i knihovny I2C a BMP085

Předem děkuji za pomoc

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý