embeded/raspberry pi2020. 3. 12. 17:51

헐.. wiringpi 프로젝트 종료? 아무튼 그럼 이걸 쓰면 안되려나..?

일단은 소스를 찾아야 하니 mirror 된 git을 발견 해당 저장소의 소스를 사용하고 복사해서 수정한다.

$ git clone https://github.com/WiringPi/WiringPi.git

$ cd WiringPi/example

$ cp lcd.c lcd2.c

$ vi lcd2.c

$ gcc lcd2.c -o lcd2 -lwiringPi -lwiringPiDev

[링크 : http://wiringpi.com/wiringpi-deprecated/]

  [링크 : https://github.com/WiringPi/WiringPi]

 

별로 도움이 안될 배선 사진. jpg

 

넣을 위치가 마땅찮아 대충 끼워넣는 동영상.avi

 

링크 블로그의 내용 그대로 사용한다.

LCD  1번핀(VSS) --- RPI3  6번핀(ground), 가변저항의 왼쪽 다리

LCD  2번핀(VDD) --- RPI3  2번핀(+5V), 가변저항의 오른쪽 다리

LCD  3번핀(VE, VO) --- 가변저항의 가운데 다리

LCD  4번핀(RS) --- RPI3 26번핀(GPIO 7)

LCD  5번핀(RW) --- RPI3 14번핀(ground)

LCD  6번핀(EN,E) --- RPI3 24번핀(GPIO 8)

 

LCD 11번핀(D4) --- RPI3 11번핀(GPIO 17)

LCD 12번핀(D5) --- RPI3 12번핀(GPIO 18)

LCD 13번핀(D6) --- RPI3 13번핀(GPIO 27)

LCD 14번핀(D7) --- RPI3 15번핀(GPIO 22)

LCD 15번핀(LED+) --- RPI3   4번핀(+5V)

LCD 16번핀(LED-)  --- RPI3 34번핀(ground)


약간(!) 수정한 소스는 아래와 같다.

크게 바뀌는 건 별로 없고, 배선상의 문제로 아래의 코드로 4,5,6,7 에서 0,1,2,3 으로 변경해야 한다.

  if (bits == 4)
    lcdHandle = lcdInit (rows, cols, 4, 11,10, 0,1,2,3,0,0,0,0) ;
//  lcdHandle = lcdInit (rows, cols, 4, 11,10, 4,5,6,7,0,0,0,0) ;

 

전체 소소는 아래와 같다.

$ cat lcd2.c
/*
 * lcd.c:
 *      Text-based LCD driver.
 *      This is designed to drive the parallel interface LCD drivers
 *      based in the Hitachi HD44780U controller and compatables.
 *
 *      This test program assumes the following:
 *
 *      8-bit displays:
 *              GPIO 0-7 is connected to display data pins 0-7.
 *              GPIO 11 is the RS pin.
 *              GPIO 10 is the Strobe/E pin.
 *
 *      For 4-bit interface:
 *              GPIO 4-7 is connected to display data pins 4-7.
 *              GPIO 11 is the RS pin.
 *              GPIO 10 is the Strobe/E pin.
 *
 * Copyright (c) 2012-2013 Gordon Henderson.
 ***********************************************************************
 * This file is part of wiringPi:
 *      https://projects.drogon.net/raspberry-pi/wiringpi/
 *
 *    wiringPi is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    wiringPi 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 Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public License
 *    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
 ***********************************************************************
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#include <unistd.h>
#include <string.h>
#include <time.h>

#include <wiringPi.h>
#include <lcd.h>

#ifndef TRUE
#  define       TRUE    (1==1)
#  define       FALSE   (1==2)
#endif

static unsigned char newChar [8] =
{
  0b11111,
  0b10001,
  0b10001,
  0b10101,
  0b11111,
  0b10001,
  0b10001,
  0b11111,
} ;


// Global lcd handle:

static int lcdHandle ;

/*
 * usage:
 *********************************************************************************
 */

int usage (const char *progName)
{
  fprintf (stderr, "Usage: %s bits cols rows\n", progName) ;
  return EXIT_FAILURE ;
}


/*
 * scrollMessage:
 *********************************************************************************
 */

static const char *message =
  "                    "
  "Wiring Pi by Gordon Henderson. HTTP://WIRINGPI.COM/"
  "                    " ;

void scrollMessage (int line, int width)
{
  char buf [32] ;
  static int position = 0 ;
  static int timer = 0 ;

  if (millis () < timer)
    return ;

  timer = millis () + 200 ;

  strncpy (buf, &message [position], width) ;
  buf [width] = 0 ;
  lcdPosition (lcdHandle, 0, line) ;
  lcdPuts     (lcdHandle, buf) ;

  if (++position == (strlen (message) - width))
    position = 0 ;
}


/*
 * pingPong:
 *      Bounce a character - only on 4-line displays
 *********************************************************************************
 */

static void pingPong (int lcd, int cols)
{
  static int position = 0 ;
  static int dir      = 0 ;

  if (dir == 0)         // Setup
  {
    dir = 1 ;
    lcdPosition (lcdHandle, 0, 3) ;
    lcdPutchar  (lcdHandle, '*') ;
    return ;
  }

  lcdPosition (lcdHandle, position, 3) ;
  lcdPutchar (lcdHandle, ' ') ;
  position += dir ;

  if (position == cols)
  {
    dir = -1 ;
    --position ;
  }

  if (position < 0)
  {
    dir = 1 ;
    ++position ;
  }

  lcdPosition (lcdHandle, position, 3) ;
  lcdPutchar  (lcdHandle, '#') ;
}


/*
 * waitForEnter:
 *********************************************************************************
 */

static void waitForEnter (void)
{
  printf ("Press ENTER to continue: ") ;
  (void)fgetc (stdin) ;
}


/*
 * The works
 *********************************************************************************
 */

int main (int argc, char *argv[])
{
  int i ;
  int lcd ;
  int bits, rows, cols ;

  struct tm *t ;
  time_t tim ;

  char buf [32] ;

  if (argc != 4)
    return usage (argv [0]) ;

  printf ("Raspberry Pi LCD test\n") ;
  printf ("=====================\n") ;

  bits = atoi (argv [1]) ;
  cols = atoi (argv [2]) ;
  rows = atoi (argv [3]) ;

  if (!((rows == 1) || (rows == 2) || (rows == 4)))
  {
    fprintf (stderr, "%s: rows must be 1, 2 or 4\n", argv [0]) ;
    return EXIT_FAILURE ;
  }

  if (!((cols == 16) || (cols == 20)))
  {
    fprintf (stderr, "%s: cols must be 16 or 20\n", argv [0]) ;
    return EXIT_FAILURE ;
  }

  wiringPiSetup () ;

  if (bits == 4)
    lcdHandle = lcdInit (rows, cols, 4, 11,10, 0,1,2,3,0,0,0,0) ;
//  lcdHandle = lcdInit (rows, cols, 4, 11,10, 4,5,6,7,0,0,0,0) ;
  else
    lcdHandle = lcdInit (rows, cols, 8, 11,10, 0,1,2,3,4,5,6,7) ;

  if (lcdHandle < 0)
  {
    fprintf (stderr, "%s: lcdInit failed\n", argv [0]) ;
    return -1 ;
  }

  lcdPosition (lcdHandle, 0, 0) ; lcdPuts (lcdHandle, "Gordon Henderson") ;
  lcdPosition (lcdHandle, 0, 1) ; lcdPuts (lcdHandle, "  wiringpi.com  ") ;

  waitForEnter () ;

  if (rows > 1)
  {
    lcdPosition (lcdHandle, 0, 1) ; lcdPuts (lcdHandle, "  wiringpi.com  ") ;

    if (rows == 4)
    {
      lcdPosition (lcdHandle, 0, 2) ;
      for (i = 0 ; i < ((cols - 1) / 2) ; ++i)
        lcdPuts (lcdHandle, "=-") ;
      lcdPuts (lcdHandle, "=3") ;

      lcdPosition (lcdHandle, 0, 3) ;
      for (i = 0 ; i < ((cols - 1) / 2) ; ++i)
        lcdPuts (lcdHandle, "-=") ;
      lcdPuts (lcdHandle, "-4") ;
    }
  }

  waitForEnter () ;

  lcdCharDef  (lcdHandle, 2, newChar) ;

  lcdClear    (lcdHandle) ;
  lcdPosition (lcdHandle, 0, 0) ;
  lcdPuts     (lcdHandle, "User Char: ") ;
  lcdPutchar  (lcdHandle, 2) ;

  lcdCursor      (lcdHandle, TRUE) ;
  lcdCursorBlink (lcdHandle, TRUE) ;

  waitForEnter () ;

  lcdCursor      (lcdHandle, FALSE) ;
  lcdCursorBlink (lcdHandle, FALSE) ;
  lcdClear       (lcdHandle) ;

  for (;;)
  {
    scrollMessage (0, cols) ;

    if (rows == 1)
      continue ;

    tim = time (NULL) ;
    t = localtime (&tim) ;

    sprintf (buf, "%02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec) ;

    lcdPosition (lcdHandle, (cols - 8) / 2, 1) ;
    lcdPuts     (lcdHandle, buf) ;

    if (rows == 2)
      continue ;

    sprintf (buf, "%02d/%02d/%04d", t->tm_mday, t->tm_mon + 1, t->tm_year+1900) ;

    lcdPosition (lcdHandle, (cols - 10) / 2, 2) ;
    lcdPuts     (lcdHandle, buf) ;

    pingPong (lcd, cols) ;
  }

  return 0 ;
}

[링크 : https://webnautes.tistory.com/1111]

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 파이 카메라 케이블이 이상해  (0) 2020.03.15
라즈베리 프로젝트?  (0) 2020.03.14
미세먼지(웹 크롤링) 표시용 장치  (0) 2020.03.11
라즈베리 node.js gpio  (0) 2020.03.10
라즈베리 python gpio  (0) 2020.03.10
Posted by 구차니
embeded/raspberry pi2020. 3. 11. 21:14

음.. 일단 구상은 했는데 구체화를 못해서 어떻게 만들어야 할지 감이 안와서 끄적끄적

 

1. 라즈베리 파이 사용(아두이노 ethernet 실드에 파싱하려니 무리일 느낌)

2. CLCD로 현재 온도 / 습도 / PM2.5 / PM10 의 정보 출력

아침에는(AM 6~9시 정도?) 오늘 비올 확율 출력

저녁에는(PM 9~12시 정도?) 새벽 온도 출력(보일러를 고민하기 위해?)

3. 웹 파싱 혹은 API 부분

기상청 정보, 공공 API 혹은 포탈 정보중 어떤걸 쓸지 고민

3. 데이터베이스

데이터베이스 공부할겸 축적해놓고 마지막 정보를 끌어오는 정도로 하려면

sqlight가 무난하려나? postgresql을 써볼까 고민중(WAS 구성해서)

4. LED

미세먼지 수치에 따라서 Green / Yellow / Red 를 출력

25ug 씩 끊어서 2/2/4개를 할까 고민중

레벨 미터 식으로 출력하자니 미세먼지가 안 좋을수록 녹색이 더 많이 불이 들어와서 고민중

a. 귀찮으니 레벨 미터 방식으로 25ug씩 출력

b. on/off 식으로 녹색 -> 노랑 -> 빨강으로 색이 옮겨가는 식으로 나쁠수록 숫자를 줄여나가기(가독성이..)

c. 걍 7 segment 사용해서 출력(CLCD에도 출력은 하지만)

5. 미세먼지 농도에 따른 릴레이 및 사용시간 적산

2개의 relay를 이용해서 필터 2개를 미세먼지 상황에 따라 자동으로 on/off

2개니까 심하지 않을 경우 하나씩 번갈아 가면서 쓰도록 하여 모터 및 필터 수명 연장을 하도록 함

 

이정도면 되려나..

미세먼지 단계에 따른 정책이 가장 귀찮네... LED를 빼버릴까..

 

+

일단 국내 기준은 아래와 같다.

보통이 31~80 으로 50정도로 꽤 넓은 편이라 보통인 경우가 많았구만..

[링크 : https://bluesky.seoul.go.kr/finedust/common-sense/page/10?article=745]

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 프로젝트?  (0) 2020.03.14
rpi clcd / wiringpi deprecated  (0) 2020.03.12
라즈베리 node.js gpio  (0) 2020.03.10
라즈베리 python gpio  (0) 2020.03.10
waveshare rpi lcd (a)와 (c)  (0) 2020.03.09
Posted by 구차니
embeded/raspberry pi2020. 3. 10. 21:26

'embeded > raspberry pi' 카테고리의 다른 글

rpi clcd / wiringpi deprecated  (0) 2020.03.12
미세먼지(웹 크롤링) 표시용 장치  (0) 2020.03.11
라즈베리 python gpio  (0) 2020.03.10
waveshare rpi lcd (a)와 (c)  (0) 2020.03.09
라즈베리 2B + waveshare 35c + MAME  (0) 2020.03.08
Posted by 구차니
embeded/raspberry pi2020. 3. 10. 21:22

아래 방법은 기본적으로 되는 듯 한데(2020년 배포 버전, 기본 패키지 상태)

import RPi.GPIO as GPIO

 

다른 방법은 안된다. (별도로 설치가 필요한듯)

일단은 위의 방법이 되면 되니 파이썬 공부할겸 한번 해봐야겠다.

(일단 파이썬이라면 인터넷 접속이랑 파싱이 편할테니..)

 

[링크 : http://www.hardcopyworld.com/gnuboard5/bbs/board.php?bo_table=lecture_rpi&wr_id=4]

'embeded > raspberry pi' 카테고리의 다른 글

미세먼지(웹 크롤링) 표시용 장치  (0) 2020.03.11
라즈베리 node.js gpio  (0) 2020.03.10
waveshare rpi lcd (a)와 (c)  (0) 2020.03.09
라즈베리 2B + waveshare 35c + MAME  (0) 2020.03.08
rpi retro / GPIO  (0) 2020.03.08
Posted by 구차니
embeded/raspberry pi2020. 3. 9. 17:16

회로가 엄청나게 변경되었는지 밑면은 먼가 많이 바뀌었다.

 

라즈베리 기준 좌측에서 찍으면 시야각이 하늘로 날아가고..

 

라즈베리 기준 우측, LCD 연결선 기준 하단에서 봐야지 전반적인 색감이 살아난다.

라즈베리 기준 상하 방향으로는 색감이 바뀌지 않아서 사진은 찍지 않았음.

 

전면에서 찍으면 정상으로 보이지만

눈으로 보면 그정도 화각에서도 색감이 정상으로 보이지 않는 영역이 보인다.

게임기로 쓰려면 세로로 세워서 써야지 가로로는 화각 문제가 좀 심각해 보인다.

 

결론 : 휴대용 게임기 만들려는 나의 계획은 취소에 가까운 보류중..

1. 3.5파이 오디오 잭을 통해 그리고 외부 전원을 통해 스피커를 만들어 주어야 하고

>> 걍 이어폰 쓰게 하면 해결 되긴 하지만

>> LCD 실드가 공간을 먹어버려서 전원 끌어 오는 등의 작업이 쉽지 않음

2. 터치가 되면 좀 낫긴 하지만 mame 코인 버튼 등을 만들어 주어야 한다.

>> mame 에서 바로 되는지 찾아봐야 함

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 node.js gpio  (0) 2020.03.10
라즈베리 python gpio  (0) 2020.03.10
라즈베리 2B + waveshare 35c + MAME  (0) 2020.03.08
rpi retro / GPIO  (0) 2020.03.08
rpi 3 / sd host overclock  (0) 2020.03.07
Posted by 구차니
embeded/raspberry pi2020. 3. 8. 08:52

이전에 라즈베리 2B 에 3.5 인치 저속 SPI 모니터를 달았었는데

프레임이 너무 낮아서 게임은 무리겠다 싶었는데

[링크 : https://minimonk.net/7989]

 

정작 고속으로 달았지만 rpi2로는 mame 에뮬레이션 성능이 안나와서 무리인가? 라는 생각이 든다.

아무튼 위의 링크랑 비교하면 확실히 빨라지긴 했다는걸 느낄수 있다.

 

속 터져서 rpi 3 투입

xwindow에서 화면 갱신은 티가 나진 않는다.

 

 

------

mame 롬은 구글로 검색해서 다운로드 받아서 테스트 함 (비교 위치는 23초 / 35초)

rpi 2  대충 23초

 

rpi 3 대충 35초

 

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 python gpio  (0) 2020.03.10
waveshare rpi lcd (a)와 (c)  (0) 2020.03.09
rpi retro / GPIO  (0) 2020.03.08
rpi 3 / sd host overclock  (0) 2020.03.07
rpi LCD(C) (SPI high speed)  (0) 2020.03.07
Posted by 구차니
embeded/raspberry pi2020. 3. 8. 08:31

'embeded > raspberry pi' 카테고리의 다른 글

waveshare rpi lcd (a)와 (c)  (0) 2020.03.09
라즈베리 2B + waveshare 35c + MAME  (0) 2020.03.08
rpi 3 / sd host overclock  (0) 2020.03.07
rpi LCD(C) (SPI high speed)  (0) 2020.03.07
rpi thin client  (0) 2019.11.18
Posted by 구차니
embeded/raspberry pi2020. 3. 7. 22:33

dtoverlay를 통해 sdhost를 오버클럭이 가능하다고 하는데

그러면 20% 정도의 성능 향상이 있다고 한다(4k read시)

 

hdparam 을 통한 벤치를 보면 20MB 대에서 30MB 대로 rpi 4와 동일한 성능이 나오게 되는데

반대로 말하자면.. rpi 쪽은 UHS-1을 지원하지 않는다가 될지도 모르겠다

(다만 rpi 4 부터는 공식적으로 지원하는 것 같다.)

 

sudo bash -c 'printf "dtoverlay=sdhost,overclock_50=100\n" >> /boot/config.txt'

[링크 : https://www.jeffgeerling.com/blog/2016/how-overclock-microsd-card-reader-on-raspberry-pi-3]

  [링크 : https://www.raspberrypi.org/forums/viewtopic.php?t=149983]

  [링크 : http://www.pidramble.com/wiki/benchmarks/microsd-cards]

[링크 : https://www.sdcard.org/developers/overview/index.html]

[링크 : https://www.sdcard.org/developers/overview/low_voltage_signaling/index.html]

 

 

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 2B + waveshare 35c + MAME  (0) 2020.03.08
rpi retro / GPIO  (0) 2020.03.08
rpi LCD(C) (SPI high speed)  (0) 2020.03.07
rpi thin client  (0) 2019.11.18
sd formatter 바뀌었네?  (0) 2019.07.23
Posted by 구차니
embeded/raspberry pi2020. 3. 7. 22:25

원래 계획했던 대로 한번 게임기 만들어 봐야지

 

$ git clone https://github.com/waveshare/LCD-show.git

$ cd LCD-show

$ sudo ./LCD35C-show

[링크 : https://github.com/waveshare/LCD-show]

  [링크 : https://github.com/waveshare/LCD-show]

[링크 : https://www.waveshare.com/wiki/3.5inch_RPi_LCD_(C)]

  [링크 : http://eleparts.co.kr/goods/view?no=7048556]

 

게임기 설정에 따라 라즈베리 버전은 GPIO 번호에 따라 연동이 되나보네?

[링크 : http://www.retrobuiltgames.com/porta-pi-arcade-help/porta-pi-software-os-download/arcade-gpio-mapping/]

'embeded > raspberry pi' 카테고리의 다른 글

rpi retro / GPIO  (0) 2020.03.08
rpi 3 / sd host overclock  (0) 2020.03.07
rpi thin client  (0) 2019.11.18
sd formatter 바뀌었네?  (0) 2019.07.23
라즈베리 파이 2 lakka 설정  (1) 2019.07.23
Posted by 구차니
embeded/raspberry pi2019. 11. 18. 14:09

라즈베리로 무언가의 틴 클라이언트로 만드는 건가?

대충 봐서는 freeRDP 등으로 윈도우 서버에 붙이는 thin client를 라즈베리로 한 듯?

 

[링크 : http://rpitc.blogspot.com/]

'embeded > raspberry pi' 카테고리의 다른 글

rpi 3 / sd host overclock  (0) 2020.03.07
rpi LCD(C) (SPI high speed)  (0) 2020.03.07
sd formatter 바뀌었네?  (0) 2019.07.23
라즈베리 파이 2 lakka 설정  (1) 2019.07.23
rpi as bt device  (0) 2019.05.30
Posted by 구차니