/*
* main.c
*
* Copyright 2023 <kim@kim>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
#include <stdio.h>
// 컴파일하고 빌드 옵션설정 = 지니 IDE 제작옵션 설
// 컴파일 옵션 : gcc -Wall -c "%f" -lwiringPi -lwiringPiDev -I/usr/local/lib
// 빌드 옵션 : gcc -Wall -o "%e" "%f" -lwiringPi -lwiringPiDev -I/usr/local/lib
// 실행옵션 : sudo "./%e"
// 원래는 /usr/include 폴더안에 있었야 하는데 최신버전 C라이브러리는
// 누락되어 있음 = 다른 폴더에 있음 = lcd.c, lcd.h, lcd.o 파일이 필요함
// lcd.c, lcd.h, lcd.o 파일은 wiringPi\DEVLib 폴더 안에 있음
#include <stdio.h>
#include <time.h>
#include <wiringPi.h>
#include <lcd.h>
#include "my_rpi_lib_v2_1.h"
//#define LCD_IF_8Bit 1
#define LCD_IF_4Bit 2
#include "My_R_pi_LCD_Lib_V1_0.h"
timer_t timer;
char buf_date[26];
char buf_time[26];
struct tm* tm_info;
int main(int argc, char **argv)
{
if(wiringPiSetupGpio() == -1) //BCM Mode 사용
{
return 1;
}
lcd_4bit_init();
lcdPosition(lcd, 0, 0);
lcdPuts(lcd, "Song Myoung Gyu");
lcdPosition(lcd, 3, 1);
lcdPuts(lcd, "LCD_Test");
lcdPosition(lcd, 10,2);
lcdPutchar(lcd, 'K');
lcdPosition(lcd, 15,3);
lcdPrintf(lcd, "OK");
//sleep(2); //2sec
//delay(2000); // ms
//lcdClear(lcd);
// lcdCursor(lcd, 2);
// lcdCursorBlink(lcd, 1);
custom_Write(2, love1);
custom_Write(5, temp);
custom_read(10, 3, 2);
custom_read(7, 2, 5);
while(1)
{
/*
time(&timer);
tm_info = localtime(&timer);
strftime(buf_date, 26, "Date: %m:%d:%Y", tm_ingo);
strftime(buf_time, 26, "Time: %H :%M:%S", tm_ingo);
lcdPosition(lcd, 2,0);
lcdPuts(lcd, buf_date);
lcdPosition(lcd, 2,1);
lcdPuts(lcd, buf_time);
*/
/*
*
lcdPosition(lcd, 15,3);
lcdPrintf(lcd, "OK");
sleep(2);
lcdClear(lcd);
sleep(2);
*/
}
return 0;
//============================================
// My LCD LIB
// 2023, 09, 05
// hp: 010-2402-4398
// e-main : mgsong@hanamil.net
// 송 명 규
// 2023, 09, 05 ==>> v1.0 최초로 작성
#ifndef __My_R_pi_LCD_LIB__
#define __My_R_pi_LCD_LIB__
#include <wiringPi.h>
#include <lcd.h>
enum LCD_PIN_MAP{
LCD_RS = 2,
LCD_EN = 3,
LCD_D0 = 17,
LCD_D1 = 27,
LCD_D2 = 22,
LCD_D3 = 10,
LCD_D4 = 9,
LCD_D5 = 11,
LCD_D6 = 5,
LCD_D7 = 6
}lcd_pin;
int lcd;
// LCD if Pin Mapping
#if LCD_IF_8Bit
void lcd_8bit_init()
{
lcd = lcdInit(4, 20, 8, LCD_RS, LCD_EN, LCD_D0, LCD_D1, LCD_D2,LCD_D3,LCD_D4,LCD_D5,LCD_D6,LCD_D7);
}
#elif LCD_IF_4Bit
void lcd_4bit_init()
{
lcd = lcdInit(4, 20, 4, LCD_RS, LCD_EN, LCD_D4,LCD_D5,LCD_D6,LCD_D7,0,0,0,0);
}
#endif
unsigned char love1[8] = {
0b00000,
0b01010,
0b10101,
0b10001,
0b10001,
0b01010,
0b00100,
0b00000
};
unsigned char temp[8] = {
0b00100,
0b01010,
0b01010,
0b01110,
0b01110,
0b11111,
0b11111,
0b01110};
void custom_Write(char mem_index, unsigned char *user_font)
{
lcdCharDef(lcd, mem_index, user_font);
}
void custom_read(char x, char y, char mem_index)
{
lcdPosition(lcd, x, y);
lcdPutchar(lcd, mem_index);
}
#endif