Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Create LED lightened Wapuu (LEDパネルで光るわぷーを)

2,022 views

Published on

Show wapuu images on an LED matrix panel. Choose image by WP REST API.

Published in: Technology
  • Be the first to comment

Create LED lightened Wapuu (LEDパネルで光るわぷーを)

  1. 1. /. kmd n -NB PB /. IFDEPB BA M
  2. 2. n Yilf L E DB PEB F DB
  3. 3. : NLII M
  4. 4. a bc k t oW EBNB FO 8F F LNAF N EL B W
  5. 5. a bc k t oW EBNB FO 8F F LNAF N EL B W a LAA F N EL B
  6. 6. /. c k L HB /. OFD DB
  7. 7. 2 NAS NB
  8. 8. /. PNFT 8 BI
  9. 9. OM BNN 8F 
 
 

  10. 10. 1 PNFT 2
  11. 11. n -L B P I AO MB M BIO RBNPF II
  12. 12. w BF CLN B I H P MB 

  13. 13. v su yb k 0FT L LLH OP AO D BP
  14. 14. :LCPS NB 
 

  15. 15. OM F
  16. 16. 7: OBP M git libgraphicsmagick++-dev libwebp-dev
  17. 17. 8F 1 /. PNFT
  18. 18. 1BP F ! HB $ git clone https://github.com/ hzeller/rpi-rgb-led-matrix $ cd rpi-rgb-led-matrix $ make -C examples-api-use $ cd utils $ make led-image-viewer
  19. 19. .B L $ cd example-api-use $ sudo ./demo 
 --led-gpio-mapping=adafruit-hat --led-no-hardware-pulse --led-chain=4 -L 
 -D 0
  20. 20. md :ELS S M
  21. 21. md n -LIIB P S M F DBO
  22. 22. b ek NN DB PEB
  23. 23. : NLII .B L $ sudo ./demo 
 --led-gpio-mapping=adafruit-hat --led-no-hardware-pulse --led-chain=4 -L 
 -D 1 ../../images/wapuu.ppm
  24. 24. :BIB P 8
  25. 25. 8 8
  26. 26. 8 8 -NB PB 8
  27. 27. - OPL / A 8LF P /wp-json/wapuu/v1/set/nnn /wp-json/wapuu/v1/get
  28. 28. p y o x AA B A MLF P add_action( 'rest_api_init', function () { register_rest_route( 'wapuu/v1', '/set/(?P<id>d+)', array( 'methods' => 'POST', 'callback' => 'set_wapuu_image', 'args' => array( 'id' => array( 'validate_callback' => function($param, $request, $key) { return is_numeric( $param ); } ), ), ) ); register_rest_route( 'wapuu/v1', '/get', array( 'methods' => 'GET', 'callback' => 'get_wapuu_image', ) ); } );
  29. 29. n :BP 1BP DB BN function set_wapuu_image( $data ) { $id = $data['id']; update_post_meta( 60, 'wapuu-image', $id ); $data = array( 'id' => $id ); return new WP_REST_Response( $data, 200 ); } function get_wapuu_image() { $id = get_post_meta( 60, 'wapuu-image'); $data = array( 'id' => $id ); return new WP_REST_Response( $data, 200 ); }
  30. 30. 8 BOML OB http://example.net/wp-json/ wapuu/v1/get {"id":"001"}
  31. 31. 8 PEL LAB L O8F
  32. 32. 8 hj 1BP F DB BN CNL 8 api="http://example.net/wp-json/wapuu/v1/get" def img_number(): try: html = urllib.urlopen( api ).read() except: return None data = json.loads(html) return data['id']
  33. 33. n BPNFBRB F DB CNL BN image_dir = "~/wapuu/" viewer = "~/rpi-rgb-led-matrix/utils/led-image-viewer" opt = " --led-daemon --led-gpio-mapping=adafruit-hat" + " --led-no-hardware-pulse --led-chain=4 -L" prev = None while True: time.sleep(2) number = img_number() if number is None: continue files = glob.glob(image_dir+number+"-*.png") if len(files) < 1: continue if files[0] == prev: continue if prev is not None: kill_img() commands.getstatusoutput("sudo "+viewer+opt+files[0]) prev = files[0]
  34. 34. j Y c n /N OB MNBRFL O F DB pattern = r"^ *(d+) .*/led-image-viewer" def kill_img (): id = [] ps_list = commands.getoutput('ps awx') for process in ps_list.split("n"): match = re.match(pattern, process) if not match: continue id.append(match.group(1)) commands.getoutput("sudo kill "+" ".join(id))
  35. 35. r :BIB PLN 8 DB <form method="post" action="/wp-json/wapuu/v1/set/001"> <div>[caption id="attachment_40" align="alignleft" width="150"] <img src="/wp-content/uploads/ 2017/09/001-original-150x150.png" alt="001" width="150" height="150" class="size-thumbnail wp-image-40" /> Original (WordCamp 2011 Fukuoka)<br> <button type="submit" value="001">
 Submit</button> [/caption]</div></form>
  36. 36. 7.7 
 

  37. 37. LNA0BO g .FOMI P LNA0BO F DL & &
  38. 38. http://www.yuriko.net/ @lilyfanjp EPPMO SSS OIFABOE NB BP IFI C IBA PNFT S M EPPMO DFPE L IFI C GM S M IBA

×