-
20140421 (LCD 제어 화면 출력, Single Linked List)부산IT학원/스마트컨트롤러 2014. 4. 21. 10:27
46일차
-------------------------
ATMega128 LCD 제어
-------------------------
- Clear Display
화면 지우기
- Excution time
명령 실행까지 걸리는 시간
이 시간이 흐르기 전에 명령을 보내면 실행이 불가능하다.
- Return Home
커서를 맨 앞으로 옴김. DB0 자리에 - 는 아무 값이나 상관 없다는 뜻.
- Entry Mode
I/D (Increase/Decrease) 커서가 움직이는 방향 설정
(A_ 글자 오른쪽으로 움직. 1, H, Increase)
(_A 글자 왼쪽으로 움직. 0, L, Decrease)
S 화면이 움직이는 모드
1 set
0 no set (기본값으로 할 것)
LCD 글자 찍기 실습 화면
소스
- C
--------------------
Single Linked List
--------------------
Single Linked List 는 항상 이런 구조를 갖고 있다.
이 안에서 구조 변경, 접근, 삭제등을 생각하는 것이 좋다.
다시 처음부터 Linked List 구조를 짜보자
- LinkedList.h
#ifndef _LinkedList_h_
#define _LinkedList_h_
#include <stdio.h>
#include <stdlib.h>
typedef struct _node
{
char data;
struct _node * next;
}Node;
Node * Node_Insert(Node *, char);
void Node_Print(Node *);
void Node_Free(Node *);
#endif // _LinkedList_h_- LinkedList.c
#include "LinkedList.h"
Node * Node_Insert(Node * Head, char cData)
{
Node * stpNew;
Node * stpFront;
Node * stpRear;
stpFront = Head;
stpRear = Head;
stpNew = malloc(sizeof(Node));
stpNew->data = cData;
stpNew->next = NULL;
while(0 != stpRear) // 삽입 위치 검색
{
if(stpNew->data < stpRear->data) // 삽입 위치 판단
{
break;
}
stpFront = stpRear;
stpRear = stpRear->next;
}
stpNew->next = stpRear;
stpFront->next = stpNew;
return Head;
}
void Node_Print(Node * Head)
{
while(0 != Head)
{
printf("%c -> ", Head->data);
Head = Head->next;
}
printf("NULL \n");
}
void Node_Free(Node * Head)
{
Node * temp;
for(temp = Head; 0 != temp; temp = Head)
{
Head = Head->next;
free(temp);
}
}- main.c
#include "LinkedList.h"
int main()
{
Node * Head = 0;
Head = malloc(sizeof(Node));
Head->data = 'b';
Head->next = malloc(sizeof(Node));
Head->next->data = 'd';
Head->next->next = NULL;
Node_Print(Head);
Head = Node_Insert(Head, 'c');
Head = Node_Insert(Head, 'e');
Node_Print(Head);
Node_Free(Head);
return 0;
}오늘은 리스트에 중간에, 끝부분에 검색하여 추가하는 것 까지 했고
내일은 앞부분에 추가하는 작업을 하고 삭제하는 것 까지 할 예정.
'부산IT학원 > 스마트컨트롤러' 카테고리의 다른 글
20140423 (LCD 속도 최적화, 직렬 병렬 통신, USART Reg, 열거형, 파일입출력, read, write) (0) 2014.04.23 20140422 (LCD 코드 최적화, 문자열, 숫자 출력, DDRAM, Cursor or Display option, 링크드리스트 삽입삭제) (0) 2014.04.22 20140417 (LCD specification, 연결리스트 치환, 삽입) (0) 2014.04.17 20140416 (LED 실습, #if #ifdef #ifndef #endif #else, 분할 컴파일) (0) 2014.04.16 20140415 (define, 연결리스트 링크드리스트) (0) 2014.04.15