- sziku69: Fűzzük össze a szavakat :)
- Luck Dragon: Asszociációs játék. :)
- Doky586: Windows telepítés utáni beállítások
- PSti: Total Commander - Memória duplázás!
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- Luck Dragon: Óraátállítás
- ldave: New Game Blitz - 2026
- gban: Ingyen kellene, de tegnapra
- sziku69: Szólánc.
- eBay-es kütyük kis pénzért
Új hozzászólás Aktív témák
-
#90088192
törölt tag
Hello Mindenkinek

Igen kezdő vagyok minden szinten, ezert nagyon alap kérdésem, lenne amit nehéz megfogalmazni, számomra, így nem is egyszerű megtalálni a szagirodalomban.
MPLAB-ban készítettem egy működő kódot ami egy kijelzőt vezérel, eddig jó, van két .h fajlom az egyik a hardware deklaráció, a másik maga a font.
Maga a source file screen.c neven futott és tartalmazott egy void main bejegyzést, amit alá írtam az lefutott.Amit csinálni szeretnek, létrehozni egy main.c nevű fájlt, és abba meghívni a screen.c ben összedobott szubrutinokat. Ezt így megpróbáltam, és többszörös definícióra hivatkozik folyamatosan.
Valaki el tudna mondani mit csinálok rosszul?
Maga a main.c
#include <stdlib.h>
#include "screen.c"
/*
*
*/
int main()
{
unsigned int x;
InitalizePorts_display();
//Wait for Vcc to settle
delay(100);
// Turn on display
dsp_on();
lcd_select(2);
clr_scr(0x00);
//*************************************************************************
// Test
//*************************************************************************
for(x=0;x<2000;x++)
{
float a=(73.00/5);
string_out("Spotty:", x ,1,0);
delay(10000);
}
return (EXIT_SUCCESS);
}es ez lenne a kijelző vezérlő
#include "hardware.h"
#include "font6x8.h"
void delay(unsigned int usec)
{
_delay_us(usec);
}
void lcd_select(int s)
{
if(s==0)
{
DISPLAY_CS1 = 1; //Selects Left side of the screen
DISPLAY_CS2 = 0; //Deselects Right side of the screen
delay(10);
}else if(s==1)
{
DISPLAY_CS1 = 0; //Deselects Left side of the screen
DISPLAY_CS2 = 1; //Selects Right side of the screen
delay(10);
}else{
DISPLAY_CS1 = 1; //Selects Left side of the screen
DISPLAY_CS2 = 1; //Selects Right side of the screen
delay(10);
}
}
void strobe_E(void) //Turns enabling line off/on
{
DISPLAY_EN = 0;
delay(10);
DISPLAY_EN = 1;
delay(10);
}
void set_y(int y) //Set Y coordinate 0-63 on the active side of the screen
{
//Y address
DISPLAY_RS = 0;
S_DATA_OUT = (0b01000000+y);
strobe_E();
}
void dsp_on(void)
{
DISPLAY_RS = 0; //Instruction mode
S_DATA_OUT = 0b00111111; //Turns display on
//DISPLAY_RS = 1; //Data Mode
delay(10);
strobe_E();
}
void clr_scr (int t)
{
int x; int y;
//line_0();
DISPLAY_RS = 0;
S_DATA_OUT = 0b11111111;
for(y=0b10111111;y>=0b10111000;y--)
{
set_y(0);
DISPLAY_RS = 0;
S_DATA_OUT = y;
strobe_E();
for(x=0; x<64; x++)
{
dsp_on();
DISPLAY_EN = 1;
DISPLAY_RS = 1;
S_DATA_OUT = t;
strobe_E();
};
};
}
void write_char(int line_select, int y_offset, int c)
{ int x; int t;
if(y_offset>63 && y_offset<122) //Check which side of the screen need to be activated
{lcd_select(1); //if the offset is bigger than 63 than the right side
t=(y_offset-64); //correction of the offset for the right side
set_y(t);
DISPLAY_RS = 0;
S_DATA_OUT = 0b10111000+line_select; //select line
strobe_E();
for(x=(c-32)*6; x<((c-32)*6)+6; x++) //Decodes the character code and make sure the data is sent by 8 bits
{
DISPLAY_RS = 1;
S_DATA_OUT = font6x8[x];
strobe_E();
}
}else if(y_offset<64 && y_offset>=0)
{
lcd_select(0); //selects the left side of the screen
t=(y_offset);
set_y(t);
DISPLAY_RS = 0;
delay(10);
S_DATA_OUT = 0b10111000+line_select;
strobe_E();
for(x=(c-32)*6; x<((c-32)*6)+6; x++) //Decodes the character code and make sure the data is sent by 8 bits
{if(t+(x-(c-32)*6)==63) //checks if the character has reached the border of the 2 sides of the screen
{lcd_select(1); //If yes selects the the right side
delay(10);
DISPLAY_RS = 0;
S_DATA_OUT = 0b10111000+line_select; // Select the relevant line
strobe_E();
set_y(0); // Resets the offset
delay(2);
DISPLAY_RS = 1;
S_DATA_OUT = font6x8[x]; //send out the data what belongs to the right side of the screen
strobe_E();
}else{ //If the Character is belong to the left side
DISPLAY_RS = 1;
S_DATA_OUT = font6x8[x]; //Sends the data to the screen
strobe_E();
}
}
}
else
{
lcd_select(2);
clr_scr(0xff);
}
}
void string_out(char* message, float variable, char line, char y_offset)
{
char test[21],i=0,j;
char a[21];
sprintf(a, "%s%f", message, variable);
while(a[i]!='\0') {test[i]=a[i]; i++;}
for(j=0;j<=i-1;j++) write_char(line,y_offset+j*6,test[j]);
}
Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Witcher topik
- Okosóra és okoskiegészítő topik
- Audi, Cupra, Seat, Skoda, Volkswagen topik
- Nintendo Switch 2
- Folyószámla, bankszámla, bankváltás, külföldi kártyahasználat
- Kerékpárosok, bringások ide!
- sziku69: Fűzzük össze a szavakat :)
- NVIDIA® driverek topikja
- Fejhallgatós találkozó
- Apple Watch
- További aktív témák...
- Garmin Epix Sapphire White Titanium (Gen2) - Bontatlan
- Gigabyte A16 CVH 15.6" FHD+ IPS i7-13620H RTX 5060 16GB 512GB NVMe IR kam gar
- Lenovo T15 G2 i7-1185G7 16Gb ram, 512Gb NVMe, 15,6", számla, 1 év garancia
- Lenovo ThinkCentre M920q i5-9500T / 16GB RAM DDR4 / 256GB SSD / Windows 11 Pro USFF mini PC Tiny PC
- Dell Latitude 5501,15.6" FHD,i5-9400H,16GB DDR4,512GB NVMe SSD,WIN11,LTE KÁRTYA,ÚJ AKKU
- Amazon Kindle 10th Generation ébresztős tok
- GYÖNYÖRŰ iPhone 14 Pro Max 256GB Space Black-1 ÉV GARANCIA - Kártyafüggetlen, MS4143
- ÚJ HP All in One 24-cr1234na PC - 24"FHD IPS - Ultra 5 125U - 16GB - 512GB SSD - Win11 - Garancia
- 230 - Lenovo Legion 5 (15IRX10) - Intel Core i7-13650HX, RTX 5060 (ELKELT)
- Dell Latitude 5490 14", HD,i5-8350U,8GB,256GB SSD,WIN11
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest


