From fb87dc7b4e465122b55c09d021334b1ed3a6f469 Mon Sep 17 00:00:00 2001 From: SSalmon2 <33885109+SSalmon2@users.noreply.github.com> Date: Wed, 29 Nov 2017 11:38:26 +0900 Subject: [PATCH 01/15] Update _config.yml --- _config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index ab3d3e4..5b520f3 100644 --- a/_config.yml +++ b/_config.yml @@ -3,7 +3,7 @@ title: Polar Bear email: description: > # this means to ignore newlines until "baseurl:" Jekyll Theme Demo -baseurl: "" # the subpath of your site, e.g. /blog/ +baseurl: / # the subpath of your site, e.g. /blog/ url: "http://username.github.io" # the base hostname & protocol for your site twitter_username: username github_username: username @@ -13,4 +13,4 @@ markdown: redcarpet markdown_ext: markdown,mkdown,mkdn,mkd,md redcarpet: - extensions: ["tables", "autolink", "strikethrough", "space_after_headers", "fenced_code_blocks"] \ No newline at end of file + extensions: ["tables", "autolink", "strikethrough", "space_after_headers", "fenced_code_blocks"] From f33c5664272f71e3ae7af3dbf4f95a6b9c7dd83f Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Wed, 29 Nov 2017 11:43:29 +0900 Subject: [PATCH 02/15] Update _config.yml --- _config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_config.yml b/_config.yml index 5b520f3..9ddfdbb 100644 --- a/_config.yml +++ b/_config.yml @@ -1,12 +1,12 @@ # Site settings title: Polar Bear -email: +email: ji9761@naver.com description: > # this means to ignore newlines until "baseurl:" Jekyll Theme Demo baseurl: / # the subpath of your site, e.g. /blog/ -url: "http://username.github.io" # the base hostname & protocol for your site +url: "http://sobadman.github.io" # the base hostname & protocol for your site twitter_username: username -github_username: username +github_username: sobadman # Build settings markdown: redcarpet From 1e057b87c4848f70487d081848010ea6818325b6 Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Wed, 29 Nov 2017 11:58:46 +0900 Subject: [PATCH 03/15] Update about.md --- about.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/about.md b/about.md index 28b5ecb..bd447ff 100644 --- a/about.md +++ b/about.md @@ -5,6 +5,6 @@ permalink: /about/ --- *Polar Bear* is a lightweight and customisable Jekyll Theme. -* Author: Camille Diez -* Github: http://github.com/diezcami -* Portfolio: http://diezcami.github.io \ No newline at end of file +* Author: sobadman +* Github: http://github.com/sobadman +* Portfolio: http://sobadman.github.io From 12a13655a567c9c7a7a679538f74d1637043965a Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Wed, 29 Nov 2017 12:00:45 +0900 Subject: [PATCH 04/15] Update 2015-05-25-hello.markdown --- _posts/2015-05-25-hello.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_posts/2015-05-25-hello.markdown b/_posts/2015-05-25-hello.markdown index 95ee506..2acf433 100644 --- a/_posts/2015-05-25-hello.markdown +++ b/_posts/2015-05-25-hello.markdown @@ -1,7 +1,7 @@ --- layout: post -title: "Hello, User!" -date: 2015-05-25 +title: "Welcome to OSS 2017 class" +date: 2017-11-29 categories: --- Hi, thanks for viewing my theme! Feel free to edit it in any way you want, just be cool and leave the necessary credits somewhere visible. If you could star the repository, that'd be pretty cool as well. @@ -11,4 +11,4 @@ Here's a list of things you should probably do after installing this theme: * Edit `_config.yml` with your actual information. Classic Jekyll. * Edit `about.md` with your actual information * Go to `css/main.scss` and edit `brand-color` to any color you want to change the header color! If you want to use an image instead, check out `_sass/_layout.scss` and edit line 6. -* Delete these icky filler posts. \ No newline at end of file +* Delete these icky filler posts. From 1dae5e332bdaf29bf22783a9ecb29a1e93ff9eb1 Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Wed, 29 Nov 2017 12:01:38 +0900 Subject: [PATCH 05/15] Update 2015-05-25-hello.markdown --- _posts/2015-05-25-hello.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2015-05-25-hello.markdown b/_posts/2015-05-25-hello.markdown index 2acf433..21f83db 100644 --- a/_posts/2015-05-25-hello.markdown +++ b/_posts/2015-05-25-hello.markdown @@ -1,6 +1,6 @@ --- layout: post -title: "Welcome to OSS 2017 class" +title: "Welcome to OSS 2017 class!" date: 2017-11-29 categories: --- From 4043e156c7e3410c92247791bf9a13394f40441a Mon Sep 17 00:00:00 2001 From: SSalmon2 <33885109+SSalmon2@users.noreply.github.com> Date: Wed, 29 Nov 2017 12:07:00 +0900 Subject: [PATCH 06/15] Update 2015-05-25-hello.markdown --- _posts/2015-05-25-hello.markdown | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/_posts/2015-05-25-hello.markdown b/_posts/2015-05-25-hello.markdown index 21f83db..cb8a4ad 100644 --- a/_posts/2015-05-25-hello.markdown +++ b/_posts/2015-05-25-hello.markdown @@ -4,11 +4,5 @@ title: "Welcome to OSS 2017 class!" date: 2017-11-29 categories: --- -Hi, thanks for viewing my theme! Feel free to edit it in any way you want, just be cool and leave the necessary credits somewhere visible. If you could star the repository, that'd be pretty cool as well. -Here's a list of things you should probably do after installing this theme: - -* Edit `_config.yml` with your actual information. Classic Jekyll. -* Edit `about.md` with your actual information -* Go to `css/main.scss` and edit `brand-color` to any color you want to change the header color! If you want to use an image instead, check out `_sass/_layout.scss` and edit line 6. -* Delete these icky filler posts. +초고속 즉시삭제! From a8a59313463f0c72d7e5f6a3f97bb0d6ec560114 Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Wed, 29 Nov 2017 12:10:00 +0900 Subject: [PATCH 07/15] Rename 2015-05-25-hello.markdown to 2017-11-29-welcome.markdown --- _posts/{2015-05-25-hello.markdown => 2017-11-29-welcome.markdown} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename _posts/{2015-05-25-hello.markdown => 2017-11-29-welcome.markdown} (100%) diff --git a/_posts/2015-05-25-hello.markdown b/_posts/2017-11-29-welcome.markdown similarity index 100% rename from _posts/2015-05-25-hello.markdown rename to _posts/2017-11-29-welcome.markdown From ea865debdd338263b06b00a0bd18ab3c636c5975 Mon Sep 17 00:00:00 2001 From: sum2nzz <33884935+sum2nzz@users.noreply.github.com> Date: Wed, 29 Nov 2017 12:11:20 +0900 Subject: [PATCH 08/15] Update 2017-11-29-welcome.markdown --- _posts/2017-11-29-welcome.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/_posts/2017-11-29-welcome.markdown b/_posts/2017-11-29-welcome.markdown index cb8a4ad..637f15c 100644 --- a/_posts/2017-11-29-welcome.markdown +++ b/_posts/2017-11-29-welcome.markdown @@ -6,3 +6,4 @@ categories: --- 초고속 즉시삭제! +수정수정수정 From da0bdbe49066c502ac09eb7926fdef5c8e7b351c Mon Sep 17 00:00:00 2001 From: KIMPIGLET <33885215+KIMPIGLET@users.noreply.github.com> Date: Wed, 29 Nov 2017 12:13:37 +0900 Subject: [PATCH 09/15] Update 2017-11-29-welcome.markdown --- _posts/2017-11-29-welcome.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/_posts/2017-11-29-welcome.markdown b/_posts/2017-11-29-welcome.markdown index 637f15c..d790142 100644 --- a/_posts/2017-11-29-welcome.markdown +++ b/_posts/2017-11-29-welcome.markdown @@ -7,3 +7,4 @@ categories: 초고속 즉시삭제! 수정수정수정 +안녕안녕하세요 From 3e62817f9c65b1033d61928b34a089089eeeca1d Mon Sep 17 00:00:00 2001 From: KIMPIGLET <33885215+KIMPIGLET@users.noreply.github.com> Date: Wed, 29 Nov 2017 12:14:06 +0900 Subject: [PATCH 10/15] Update 2017-11-29-welcome.markdown --- _posts/2017-11-29-welcome.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2017-11-29-welcome.markdown b/_posts/2017-11-29-welcome.markdown index d790142..6d1a0ff 100644 --- a/_posts/2017-11-29-welcome.markdown +++ b/_posts/2017-11-29-welcome.markdown @@ -7,4 +7,4 @@ categories: 초고속 즉시삭제! 수정수정수정 -안녕안녕하세요 +안녕안녕하세요! From a398e7951849ef3c72b0a842b49f6b7caeacf5dd Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Sun, 17 Dec 2017 09:32:21 +0900 Subject: [PATCH 11/15] Update 2017-11-29-welcome.markdown --- _posts/2017-11-29-welcome.markdown | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/_posts/2017-11-29-welcome.markdown b/_posts/2017-11-29-welcome.markdown index 6d1a0ff..f75e4bf 100644 --- a/_posts/2017-11-29-welcome.markdown +++ b/_posts/2017-11-29-welcome.markdown @@ -4,7 +4,4 @@ title: "Welcome to OSS 2017 class!" date: 2017-11-29 categories: --- - -초고속 즉시삭제! -수정수정수정 -안녕안녕하세요! +https://www.youtube.com/watch?v=JvR2igu5XlU From f80f06ebcc63d87fb152d3a5ffac814c647f9749 Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Sun, 17 Dec 2017 09:49:14 +0900 Subject: [PATCH 12/15] Update 2017-11-29-welcome.markdown --- _posts/2017-11-29-welcome.markdown | 261 +++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) diff --git a/_posts/2017-11-29-welcome.markdown b/_posts/2017-11-29-welcome.markdown index f75e4bf..6cad481 100644 --- a/_posts/2017-11-29-welcome.markdown +++ b/_posts/2017-11-29-welcome.markdown @@ -5,3 +5,264 @@ date: 2017-11-29 categories: --- https://www.youtube.com/watch?v=JvR2igu5XlU + +#!/usr/bin/python + +import smbus +import time +import vlc +import RPi.GPIO as GPIO +import os +from ftplib import FTP + +ftp = FTP('192.168.0.46','root','openmediavault') +print(2) +ftp.cwd('/asd') +n = [] +n2 = [] +print('1') +ftp.retrlines('LIST',n.append) +for a in n: + k = a.split(':')[1][3:] + n2.append(k) +print(n) +print(n2) +c = 0 +for b in n2: + fn = b + fd = open("/home/pi/New/"+fn,'wb') + ftp.retrbinary("RETR "+fn,fd.write) + c += 1 + print str(c)+" file(s) downloaded." +fd.close() +ftp.quit() +print "Download conpleted." + + + +#GPIO SETTING +GPIO.setmode(GPIO.BCM) + +GPIO.setup(17, GPIO.IN) +GPIO.setup(24, GPIO.IN) +GPIO.setup(22, GPIO.IN) +GPIO.setup(23, GPIO.IN) + +#path = "/home/pi/Desktop" + +# Define some device parameters +I2C_ADDR = 0x27 # I2C device address +LCD_WIDTH = 16 # Maximum characters per line + +# Define some device constants +LCD_CHR = 1 # Mode - Sending data +LCD_CMD = 0 # Mode - Sending command + +LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line +LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line +LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line +LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line + +LCD_BACKLIGHT = 0x08 # On +#LCD_BACKLIGHT = 0x00 # Off + +ENABLE = 0b00000100 # Enable bit + +# Timing constants +E_PULSE = 0.0005 +E_DELAY = 0.0005 + +#Open I2C interface +#bus = smbus.SMBus(0) # Rev 1 Pi uses 0 +bus = smbus.SMBus(1) # Rev 2 Pi uses 1 + +def lcd_init(): + # Initialise display + lcd_byte(0x33,LCD_CMD) # 110011 Initialise + lcd_byte(0x32,LCD_CMD) # 110010 Initialise + lcd_byte(0x06,LCD_CMD) # 000110 Cursor move direction + lcd_byte(0x0C,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off + lcd_byte(0x28,LCD_CMD) # 101000 Data length, number of lines, font size + lcd_byte(0x01,LCD_CMD) # 000001 Clear display + time.sleep(E_DELAY) + +def lcd_byte(bits, mode): + # Send byte to data pins + # bits = the data + # mode = 1 for data + # 0 for command + + bits_high = mode | (bits & 0xF0) | LCD_BACKLIGHT + bits_low = mode | ((bits<<4) & 0xF0) | LCD_BACKLIGHT + + # High bits + bus.write_byte(I2C_ADDR, bits_high) + lcd_toggle_enable(bits_high) + + # Low bits + bus.write_byte(I2C_ADDR, bits_low) + lcd_toggle_enable(bits_low) + +def lcd_toggle_enable(bits): + # Toggle enable + time.sleep(E_DELAY) + bus.write_byte(I2C_ADDR, (bits | ENABLE)) + time.sleep(E_PULSE) + bus.write_byte(I2C_ADDR,(bits & ~ENABLE)) + time.sleep(E_DELAY) + +def lcd_string(message,line): + # Send string to display + + message = message.ljust(LCD_WIDTH," ") + + lcd_byte(line, LCD_CMD) + + for i in range(LCD_WIDTH): + lcd_byte(ord(message[i]),LCD_CHR) + + + + + +class music_player: + def __init__(self,path): + self.path = path + self.play_list = os.listdir(path) + self.music_number = 0 + self.filename = self.play_list[self.music_number] + + instance = vlc.Instance() + + print(self.music_number) + + self.player=instance.media_player_new() + + def playing(self): + instance = vlc.Instance() + file1 = self.path + self.play_list[self.music_number] + media=instance.media_new(file1) + print(file1) + + self.player.set_media(media) + self.player.play() + time.sleep(0.3) + + (music,singer) = self.split(self.play_list[self.music_number]) + print(music) + print(singer) + music_script, singer_script = self.script(music), self.script(singer) + print(music_script) + print(singer_script) + music_flip_mod = self.flip(len(music_script)) + singer_flip_mod = self.flip(len(singer_script)) + print(music_flip_mod) + print(singer_flip_mod) + lcd_init() + count1,count2 = 0,0 + time1 = time.time() + + while True: + self.display(count1,music_script,1) + self.display(count2,singer_script,2) + time2 = time.time() + if time2-time1 >= 1: + if not count1 == 'NULL': + count1 = music_flip_mod[count1] + if not count2 == 'NULL': + count2 = singer_flip_mod[count2] + if count1 == 'NULL' and count2 == 'NULL': + count1, count2 = 0, 0 + time1 = time2 + if self.button(self.music_number) == 'break': + break + if self.player.get_state() == 6: + self.music_number += 1 + if self.music_number == len(self.play_list): + self.music_number = 0 + time.sleep(0.3) + self.playing() + + def button(self,music_number): + if GPIO.input(17)==0: + if self.player.get_state() == 3: + print("1") + self.player.stop() + time.sleep(0.3) + return 'break' + + if GPIO.input(24)==0: + print("2") + self.player.pause() + time.sleep(0.3) + + #Before song + if GPIO.input(22)==0: + print("3") + self.player.stop() + self.music_number -= 1 + if self.music_number < 0: + self.music_number = len(self.play_list) - 1 + print(self.music_number) + time.sleep(0.3) + self.playing() + + #After song + if GPIO.input(23)==0: + print("4") + self.player.stop() + self.music_number += 1 + if self.music_number == len(self.play_list): + self.music_number = 0 + time.sleep(0.3) + self.playing() + + def split(self,filename): + new_filename = filename.split('.')[0] + music = new_filename.split('-')[0] + singer = new_filename.split('-')[1] + return music, singer + + def script(self,text): + script_list = [] + if len(text) < 16: + length = 16-len(text) + for a in range(0,length): + k = " "*(length-a)+text+" "*a + script_list.append(k) + elif len(text) == 16: + script_list.append(text) + elif len(text) > 16: + length = len(text)-16+1 + for a in range(0,length): + k = text[a:17+a] + script_list.append(k) + return script_list + + def flip(self,number): + flip_mod = {} + for a in range(number-1): + flip_mod[a] = a+1 + flip_mod[number-1] = 'NULL' + return flip_mod + + def display(self,count,script_list,line): + if not count == 'NULL': + if line == 1: + lcd_string(script_list[count],LCD_LINE_1) + elif line == 2: + lcd_string(script_list[count],LCD_LINE_2) + + def main(self): + self.playing() + + +if __name__ == '__main__': + + try: + PLAYER = music_player("/home/pi/New/") + PLAYER.main() + except KeyboardInterrupt: + pass + finally: + lcd_byte(0x01, LCD_CMD) From b0a1551ac5049551dad975159e26b342dc7633d7 Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Sun, 17 Dec 2017 10:09:46 +0900 Subject: [PATCH 13/15] Update 2017-11-29-welcome.markdown --- _posts/2017-11-29-welcome.markdown | 348 ++++++++++++++--------------- 1 file changed, 172 insertions(+), 176 deletions(-) diff --git a/_posts/2017-11-29-welcome.markdown b/_posts/2017-11-29-welcome.markdown index 6cad481..3823a40 100644 --- a/_posts/2017-11-29-welcome.markdown +++ b/_posts/2017-11-29-welcome.markdown @@ -16,24 +16,22 @@ import os from ftplib import FTP ftp = FTP('192.168.0.46','root','openmediavault') -print(2) ftp.cwd('/asd') n = [] n2 = [] -print('1') ftp.retrlines('LIST',n.append) for a in n: - k = a.split(':')[1][3:] - n2.append(k) + k = a.split(':')[1][3:] + n2.append(k) print(n) print(n2) c = 0 for b in n2: - fn = b - fd = open("/home/pi/New/"+fn,'wb') - ftp.retrbinary("RETR "+fn,fd.write) - c += 1 - print str(c)+" file(s) downloaded." + fn = b + fd = open("/home/pi/New/"+fn,'wb') + ftp.retrbinary("RETR "+fn,fd.write) + c += 1 + print str(c)+" file(s) downloaded." fd.close() ftp.quit() print "Download conpleted." @@ -50,11 +48,11 @@ GPIO.setup(23, GPIO.IN) #path = "/home/pi/Desktop" -# Define some device parameters +#Define some device parameters I2C_ADDR = 0x27 # I2C device address LCD_WIDTH = 16 # Maximum characters per line -# Define some device constants +#Define some device constants LCD_CHR = 1 # Mode - Sending data LCD_CMD = 0 # Mode - Sending command @@ -77,192 +75,190 @@ E_DELAY = 0.0005 bus = smbus.SMBus(1) # Rev 2 Pi uses 1 def lcd_init(): - # Initialise display - lcd_byte(0x33,LCD_CMD) # 110011 Initialise - lcd_byte(0x32,LCD_CMD) # 110010 Initialise - lcd_byte(0x06,LCD_CMD) # 000110 Cursor move direction - lcd_byte(0x0C,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off - lcd_byte(0x28,LCD_CMD) # 101000 Data length, number of lines, font size - lcd_byte(0x01,LCD_CMD) # 000001 Clear display - time.sleep(E_DELAY) + # Initialise display + lcd_byte(0x33,LCD_CMD) # 110011 Initialise + lcd_byte(0x32,LCD_CMD) # 110010 Initialise + lcd_byte(0x06,LCD_CMD) # 000110 Cursor move direction + lcd_byte(0x0C,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off + lcd_byte(0x28,LCD_CMD) # 101000 Data length, number of lines, font size + lcd_byte(0x01,LCD_CMD) # 000001 Clear display + time.sleep(E_DELAY) def lcd_byte(bits, mode): - # Send byte to data pins - # bits = the data - # mode = 1 for data - # 0 for command + # Send byte to data pins + # bits = the data + # mode = 1 for data + # 0 for command + bits_high = mode | (bits & 0xF0) | LCD_BACKLIGHT + bits_low = mode | ((bits<<4) & 0xF0) | LCD_BACKLIGHT - bits_high = mode | (bits & 0xF0) | LCD_BACKLIGHT - bits_low = mode | ((bits<<4) & 0xF0) | LCD_BACKLIGHT + # High bits + bus.write_byte(I2C_ADDR, bits_high) + lcd_toggle_enable(bits_high) - # High bits - bus.write_byte(I2C_ADDR, bits_high) - lcd_toggle_enable(bits_high) - - # Low bits - bus.write_byte(I2C_ADDR, bits_low) - lcd_toggle_enable(bits_low) + # Low bits + bus.write_byte(I2C_ADDR, bits_low) + lcd_toggle_enable(bits_low) def lcd_toggle_enable(bits): - # Toggle enable - time.sleep(E_DELAY) - bus.write_byte(I2C_ADDR, (bits | ENABLE)) - time.sleep(E_PULSE) - bus.write_byte(I2C_ADDR,(bits & ~ENABLE)) - time.sleep(E_DELAY) + # Toggle enable + time.sleep(E_DELAY) + bus.write_byte(I2C_ADDR, (bits | ENABLE)) + time.sleep(E_PULSE) + bus.write_byte(I2C_ADDR,(bits & ~ENABLE)) + time.sleep(E_DELAY) def lcd_string(message,line): - # Send string to display + # Send string to display - message = message.ljust(LCD_WIDTH," ") + message = message.ljust(LCD_WIDTH," ") - lcd_byte(line, LCD_CMD) + lcd_byte(line, LCD_CMD) - for i in range(LCD_WIDTH): - lcd_byte(ord(message[i]),LCD_CHR) + for i in range(LCD_WIDTH): + lcd_byte(ord(message[i]),LCD_CHR) class music_player: - def __init__(self,path): - self.path = path - self.play_list = os.listdir(path) - self.music_number = 0 - self.filename = self.play_list[self.music_number] - - instance = vlc.Instance() - - print(self.music_number) - - self.player=instance.media_player_new() - - def playing(self): - instance = vlc.Instance() - file1 = self.path + self.play_list[self.music_number] - media=instance.media_new(file1) - print(file1) - - self.player.set_media(media) - self.player.play() - time.sleep(0.3) - - (music,singer) = self.split(self.play_list[self.music_number]) - print(music) - print(singer) - music_script, singer_script = self.script(music), self.script(singer) - print(music_script) - print(singer_script) - music_flip_mod = self.flip(len(music_script)) - singer_flip_mod = self.flip(len(singer_script)) - print(music_flip_mod) - print(singer_flip_mod) - lcd_init() - count1,count2 = 0,0 - time1 = time.time() - - while True: - self.display(count1,music_script,1) - self.display(count2,singer_script,2) - time2 = time.time() - if time2-time1 >= 1: - if not count1 == 'NULL': - count1 = music_flip_mod[count1] - if not count2 == 'NULL': - count2 = singer_flip_mod[count2] - if count1 == 'NULL' and count2 == 'NULL': - count1, count2 = 0, 0 - time1 = time2 - if self.button(self.music_number) == 'break': - break - if self.player.get_state() == 6: - self.music_number += 1 - if self.music_number == len(self.play_list): - self.music_number = 0 - time.sleep(0.3) - self.playing() - - def button(self,music_number): - if GPIO.input(17)==0: - if self.player.get_state() == 3: - print("1") - self.player.stop() - time.sleep(0.3) - return 'break' + def __init__(self,path): + self.path = path + self.play_list = os.listdir(path) + self.music_number = 0 + self.filename = self.play_list[self.music_number] + + instance = vlc.Instance() + + print(self.music_number) + + self.player=instance.media_player_new() + + def playing(self): + instance = vlc.Instance() + file1 = self.path + self.play_list[self.music_number] + media=instance.media_new(file1) + print(file1) + + self.player.set_media(media) + self.player.play() + time.sleep(0.3) + + (music,singer) = self.split(self.play_list[self.music_number]) + print(music) + print(singer) + music_script, singer_script = self.script(music), self.script(singer) + print(music_script) + print(singer_script) + music_flip_mod = self.flip(len(music_script)) + singer_flip_mod = self.flip(len(singer_script)) + print(music_flip_mod) + print(singer_flip_mod) + lcd_init() + count1,count2 = 0,0 + time1 = time.time() + + while True: + self.display(count1,music_script,1) + self.display(count2,singer_script,2) + time2 = time.time() + if time2-time1 >= 1: + if not count1 == 'NULL': + count1 = music_flip_mod[count1] + if not count2 == 'NULL': + count2 = singer_flip_mod[count2] + if count1 == 'NULL' and count2 == 'NULL': + count1, count2 = 0, 0 + time1 = time2 + if self.button(self.music_number) == 'break': + break + if self.player.get_state() == 6: + self.music_number += 1 + if self.music_number == len(self.play_list): + self.music_number = 0 + time.sleep(0.3) + self.playing() - if GPIO.input(24)==0: - print("2") - self.player.pause() - time.sleep(0.3) - - #Before song - if GPIO.input(22)==0: - print("3") - self.player.stop() - self.music_number -= 1 - if self.music_number < 0: - self.music_number = len(self.play_list) - 1 - print(self.music_number) - time.sleep(0.3) - self.playing() - - #After song - if GPIO.input(23)==0: - print("4") - self.player.stop() - self.music_number += 1 - if self.music_number == len(self.play_list): - self.music_number = 0 - time.sleep(0.3) - self.playing() - - def split(self,filename): - new_filename = filename.split('.')[0] - music = new_filename.split('-')[0] - singer = new_filename.split('-')[1] - return music, singer + def button(self,music_number): + if GPIO.input(17)==0: + if self.player.get_state() == 3: + print("1") + self.player.stop() + time.sleep(0.3) + return 'break' + + if GPIO.input(24)==0: + print("2") + self.player.pause() + time.sleep(0.3) + + if GPIO.input(22)==0: + print("3") + self.player.stop() + self.music_number -= 1 + if self.music_number < 0: + self.music_number = len(self.play_list) - 1 + print(self.music_number) + time.sleep(0.3) + self.playing() + + + if GPIO.input(23)==0: + print("4") + self.player.stop() + self.music_number += 1 + if self.music_number == len(self.play_list): + self.music_number = 0 + time.sleep(0.3) + self.playing() + + def split(self,filename): + new_filename = filename.split('.')[0] + music = new_filename.split('-')[0] + singer = new_filename.split('-')[1] + return music, singer - def script(self,text): - script_list = [] - if len(text) < 16: - length = 16-len(text) - for a in range(0,length): - k = " "*(length-a)+text+" "*a - script_list.append(k) - elif len(text) == 16: - script_list.append(text) - elif len(text) > 16: - length = len(text)-16+1 - for a in range(0,length): - k = text[a:17+a] - script_list.append(k) - return script_list - - def flip(self,number): - flip_mod = {} - for a in range(number-1): - flip_mod[a] = a+1 - flip_mod[number-1] = 'NULL' - return flip_mod - - def display(self,count,script_list,line): - if not count == 'NULL': - if line == 1: - lcd_string(script_list[count],LCD_LINE_1) - elif line == 2: - lcd_string(script_list[count],LCD_LINE_2) + def script(self,text): + script_list = [] + if len(text) < 16: + length = 16-len(text) + for a in range(0,length): + k = " "*(length-a)+text+" "*a + script_list.append(k) + elif len(text) == 16: + script_list.append(text) + elif len(text) > 16: + length = len(text)-16+1 + for a in range(0,length): + k = text[a:17+a] + script_list.append(k) + return script_list + + def flip(self,number): + flip_mod = {} + for a in range(number-1): + flip_mod[a] = a+1 + flip_mod[number-1] = 'NULL' + return flip_mod + + def display(self,count,script_list,line): + if not count == 'NULL': + if line == 1: + lcd_string(script_list[count],LCD_LINE_1) + elif line == 2: + lcd_string(script_list[count],LCD_LINE_2) - def main(self): - self.playing() + def main(self): + self.playing() if __name__ == '__main__': - try: - PLAYER = music_player("/home/pi/New/") - PLAYER.main() - except KeyboardInterrupt: - pass - finally: - lcd_byte(0x01, LCD_CMD) + try: + PLAYER = music_player("/home/pi/New/") + PLAYER.main() + except KeyboardInterrupt: + pass + finally: + lcd_byte(0x01, LCD_CMD) From 4a6623b49e7ae94930c6efb36983d0ee161e8184 Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Sun, 17 Dec 2017 10:16:21 +0900 Subject: [PATCH 14/15] Update 2017-11-29-welcome.markdown --- _posts/2017-11-29-welcome.markdown | 492 ++++++++++++++--------------- 1 file changed, 243 insertions(+), 249 deletions(-) diff --git a/_posts/2017-11-29-welcome.markdown b/_posts/2017-11-29-welcome.markdown index 3823a40..9b92581 100644 --- a/_posts/2017-11-29-welcome.markdown +++ b/_posts/2017-11-29-welcome.markdown @@ -6,259 +6,253 @@ categories: --- https://www.youtube.com/watch?v=JvR2igu5XlU -#!/usr/bin/python - -import smbus -import time -import vlc -import RPi.GPIO as GPIO -import os -from ftplib import FTP - -ftp = FTP('192.168.0.46','root','openmediavault') -ftp.cwd('/asd') -n = [] -n2 = [] -ftp.retrlines('LIST',n.append) -for a in n: - k = a.split(':')[1][3:] - n2.append(k) -print(n) -print(n2) -c = 0 -for b in n2: - fn = b - fd = open("/home/pi/New/"+fn,'wb') - ftp.retrbinary("RETR "+fn,fd.write) - c += 1 - print str(c)+" file(s) downloaded." -fd.close() -ftp.quit() -print "Download conpleted." + #!/usr/bin/python + + import smbus + import time + import vlc + import RPi.GPIO as GPIO + import os + from ftplib import FTP + + ftp = FTP('192.168.0.46','root','openmediavault') + ftp.cwd('/asd') + n = [] + n2 = [] + ftp.retrlines('LIST',n.append) + for a in n: + k = a.split(':')[1][3:] + n2.append(k)print(n) + print(n2) + c = 0 + for b in n2: + fn = b + fd = open("/home/pi/New/"+fn,'wb') + ftp.retrbinary("RETR "+fn,fd.write) + c += 1 + print str(c)+" file(s) downloaded." + fd.close() + ftp.quit() + print "Download conpleted." + + #GPIO SETTING + GPIO.setmode(GPIO.BCM) + + GPIO.setup(17, GPIO.IN) + GPIO.setup(24, GPIO.IN) + GPIO.setup(22, GPIO.IN) + GPIO.setup(23, GPIO.IN) + + #path = "/home/pi/Desktop" + + #Define some device parameters + I2C_ADDR = 0x27 # I2C device address + LCD_WIDTH = 16 # Maximum characters per line + + #Define some device constants + LCD_CHR = 1 # Mode - Sending data + LCD_CMD = 0 # Mode - Sending command + + LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line + LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line + LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line + LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line + + LCD_BACKLIGHT = 0x08 # On + #LCD_BACKLIGHT = 0x00 # Off + + ENABLE = 0b00000100 # Enable bit + + # Timing constants + E_PULSE = 0.0005 + E_DELAY = 0.0005 + + #Open I2C interface + #bus = smbus.SMBus(0) # Rev 1 Pi uses 0 + bus = smbus.SMBus(1) # Rev 2 Pi uses 1 + + def lcd_init(): + # Initialise display + lcd_byte(0x33,LCD_CMD) # 110011 Initialise + lcd_byte(0x32,LCD_CMD) # 110010 Initialise + lcd_byte(0x06,LCD_CMD) # 000110 Cursor move direction + lcd_byte(0x0C,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off + lcd_byte(0x28,LCD_CMD) # 101000 Data length, number of lines, font size + lcd_byte(0x01,LCD_CMD) # 000001 Clear display + time.sleep(E_DELAY) + + def lcd_byte(bits, mode): + # Send byte to data pins + # bits = the data + # mode = 1 for data + # 0 for command + bits_high = mode | (bits & 0xF0) | LCD_BACKLIGHT + bits_low = mode | ((bits<<4) & 0xF0) | LCD_BACKLIGHT + + # High bits + bus.write_byte(I2C_ADDR, bits_high) + lcd_toggle_enable(bits_high) + + # Low bits + bus.write_byte(I2C_ADDR, bits_low) + lcd_toggle_enable(bits_low) + + def lcd_toggle_enable(bits): + # Toggle enable + time.sleep(E_DELAY) + bus.write_byte(I2C_ADDR, (bits | ENABLE)) + time.sleep(E_PULSE) + bus.write_byte(I2C_ADDR,(bits & ~ENABLE)) + time.sleep(E_DELAY) + + def lcd_string(message,line): + #Send string to display + + message = message.ljust(LCD_WIDTH," ") + + lcd_byte(line, LCD_CMD) + + for i in range(LCD_WIDTH): + lcd_byte(ord(message[i]),LCD_CHR) + + class music_player: + + def __init__(self,path): + self.path = path + self.play_list = os.listdir(path) + self.music_number = 0 + self.filename = self.play_list[self.music_number] + + instance = vlc.Instance() - - -#GPIO SETTING -GPIO.setmode(GPIO.BCM) - -GPIO.setup(17, GPIO.IN) -GPIO.setup(24, GPIO.IN) -GPIO.setup(22, GPIO.IN) -GPIO.setup(23, GPIO.IN) - -#path = "/home/pi/Desktop" - -#Define some device parameters -I2C_ADDR = 0x27 # I2C device address -LCD_WIDTH = 16 # Maximum characters per line - -#Define some device constants -LCD_CHR = 1 # Mode - Sending data -LCD_CMD = 0 # Mode - Sending command - -LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line -LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line -LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line -LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line - -LCD_BACKLIGHT = 0x08 # On -#LCD_BACKLIGHT = 0x00 # Off - -ENABLE = 0b00000100 # Enable bit - -# Timing constants -E_PULSE = 0.0005 -E_DELAY = 0.0005 - -#Open I2C interface -#bus = smbus.SMBus(0) # Rev 1 Pi uses 0 -bus = smbus.SMBus(1) # Rev 2 Pi uses 1 - -def lcd_init(): - # Initialise display - lcd_byte(0x33,LCD_CMD) # 110011 Initialise - lcd_byte(0x32,LCD_CMD) # 110010 Initialise - lcd_byte(0x06,LCD_CMD) # 000110 Cursor move direction - lcd_byte(0x0C,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off - lcd_byte(0x28,LCD_CMD) # 101000 Data length, number of lines, font size - lcd_byte(0x01,LCD_CMD) # 000001 Clear display - time.sleep(E_DELAY) - -def lcd_byte(bits, mode): - # Send byte to data pins - # bits = the data - # mode = 1 for data - # 0 for command - bits_high = mode | (bits & 0xF0) | LCD_BACKLIGHT - bits_low = mode | ((bits<<4) & 0xF0) | LCD_BACKLIGHT - - # High bits - bus.write_byte(I2C_ADDR, bits_high) - lcd_toggle_enable(bits_high) - - # Low bits - bus.write_byte(I2C_ADDR, bits_low) - lcd_toggle_enable(bits_low) - -def lcd_toggle_enable(bits): - # Toggle enable - time.sleep(E_DELAY) - bus.write_byte(I2C_ADDR, (bits | ENABLE)) - time.sleep(E_PULSE) - bus.write_byte(I2C_ADDR,(bits & ~ENABLE)) - time.sleep(E_DELAY) - -def lcd_string(message,line): - # Send string to display - - message = message.ljust(LCD_WIDTH," ") - - lcd_byte(line, LCD_CMD) - - for i in range(LCD_WIDTH): - lcd_byte(ord(message[i]),LCD_CHR) - - - - - -class music_player: - def __init__(self,path): - self.path = path - self.play_list = os.listdir(path) - self.music_number = 0 - self.filename = self.play_list[self.music_number] - - instance = vlc.Instance() - - print(self.music_number) - - self.player=instance.media_player_new() - - def playing(self): - instance = vlc.Instance() - file1 = self.path + self.play_list[self.music_number] - media=instance.media_new(file1) - print(file1) - - self.player.set_media(media) - self.player.play() - time.sleep(0.3) - - (music,singer) = self.split(self.play_list[self.music_number]) - print(music) - print(singer) - music_script, singer_script = self.script(music), self.script(singer) - print(music_script) - print(singer_script) - music_flip_mod = self.flip(len(music_script)) - singer_flip_mod = self.flip(len(singer_script)) - print(music_flip_mod) - print(singer_flip_mod) - lcd_init() - count1,count2 = 0,0 - time1 = time.time() - - while True: - self.display(count1,music_script,1) - self.display(count2,singer_script,2) - time2 = time.time() - if time2-time1 >= 1: - if not count1 == 'NULL': - count1 = music_flip_mod[count1] - if not count2 == 'NULL': - count2 = singer_flip_mod[count2] - if count1 == 'NULL' and count2 == 'NULL': - count1, count2 = 0, 0 - time1 = time2 - if self.button(self.music_number) == 'break': - break - if self.player.get_state() == 6: - self.music_number += 1 - if self.music_number == len(self.play_list): - self.music_number = 0 - time.sleep(0.3) - self.playing() - - def button(self,music_number): - if GPIO.input(17)==0: - if self.player.get_state() == 3: - print("1") - self.player.stop() - time.sleep(0.3) - return 'break' - - if GPIO.input(24)==0: - print("2") - self.player.pause() - time.sleep(0.3) - - if GPIO.input(22)==0: - print("3") - self.player.stop() - self.music_number -= 1 - if self.music_number < 0: - self.music_number = len(self.play_list) - 1 print(self.music_number) - time.sleep(0.3) - self.playing() + self.player=instance.media_player_new() - if GPIO.input(23)==0: - print("4") - self.player.stop() - self.music_number += 1 - if self.music_number == len(self.play_list): - self.music_number = 0 + def playing(self): + instance = vlc.Instance() + file1 = self.path + self.play_list[self.music_number] + media=instance.media_new(file1) + print(file1) + + self.player.set_media(media) + self.player.play() time.sleep(0.3) + + (music,singer) = self.split(self.play_list[self.music_number]) + print(music) + print(singer) + music_script, singer_script = self.script(music), self.script(singer) + print(music_script) + print(singer_script) + music_flip_mod = self.flip(len(music_script)) + singer_flip_mod = self.flip(len(singer_script)) + print(music_flip_mod) + print(singer_flip_mod) + lcd_init() + count1,count2 = 0,0 + time1 = time.time() + + while True: + self.display(count1,music_script,1) + self.display(count2,singer_script,2) + time2 = time.time() + if time2-time1 >= 1: + if not count1 == 'NULL': + count1 = music_flip_mod[count1] + if not count2 == 'NULL': + count2 = singer_flip_mod[count2] + if count1 == 'NULL' and count2 == 'NULL': + count1, count2 = 0, 0 + time1 = time2 + if self.button(self.music_number) == 'break': + break + if self.player.get_state() == 6: + self.music_number += 1 + if self.music_number == len(self.play_list): + self.music_number = 0 + time.sleep(0.3) + self.playing() + + def button(self,music_number): + if GPIO.input(17)==0: + if self.player.get_state() == 3: + print("1") + self.player.stop() + time.sleep(0.3) + return 'break' + + if GPIO.input(24)==0: + print("2") + self.player.pause() + time.sleep(0.3) + + if GPIO.input(22)==0: + print("3") + self.player.stop() + self.music_number -= 1 + if self.music_number < 0: + self.music_number = len(self.play_list) - 1 + print(self.music_number) + time.sleep(0.3) + self.playing() + + + if GPIO.input(23)==0: + print("4") + self.player.stop() + self.music_number += 1 + if self.music_number == len(self.play_list): + self.music_number = 0 + time.sleep(0.3) + self.playing() + + def split(self,filename): + new_filename = filename.split('.')[0] + music = new_filename.split('-')[0] + singer = new_filename.split('-')[1] + return music, singer + + def script(self,text): + script_list = [] + if len(text) < 16: + length = 16-len(text) + for a in range(0,length): + k = " "*(length-a)+text+" "*a + script_list.append(k) + elif len(text) == 16: + script_list.append(text) + elif len(text) > 16: + length = len(text)-16+1 + for a in range(0,length): + k = text[a:17+a] + script_list.append(k) + return script_list + + def flip(self,number): + flip_mod = {} + for a in range(number-1): + flip_mod[a] = a+1 + flip_mod[number-1] = 'NULL' + return flip_mod + + def display(self,count,script_list,line): + if not count == 'NULL': + if line == 1: + lcd_string(script_list[count],LCD_LINE_1) + elif line == 2: + lcd_string(script_list[count],LCD_LINE_2) + + def main(self): self.playing() - def split(self,filename): - new_filename = filename.split('.')[0] - music = new_filename.split('-')[0] - singer = new_filename.split('-')[1] - return music, singer - - def script(self,text): - script_list = [] - if len(text) < 16: - length = 16-len(text) - for a in range(0,length): - k = " "*(length-a)+text+" "*a - script_list.append(k) - elif len(text) == 16: - script_list.append(text) - elif len(text) > 16: - length = len(text)-16+1 - for a in range(0,length): - k = text[a:17+a] - script_list.append(k) - return script_list - - def flip(self,number): - flip_mod = {} - for a in range(number-1): - flip_mod[a] = a+1 - flip_mod[number-1] = 'NULL' - return flip_mod - - def display(self,count,script_list,line): - if not count == 'NULL': - if line == 1: - lcd_string(script_list[count],LCD_LINE_1) - elif line == 2: - lcd_string(script_list[count],LCD_LINE_2) - - def main(self): - self.playing() - - -if __name__ == '__main__': - - try: - PLAYER = music_player("/home/pi/New/") - PLAYER.main() - except KeyboardInterrupt: - pass - finally: - lcd_byte(0x01, LCD_CMD) + + if __name__ == '__main__': + + try: + PLAYER = music_player("/home/pi/New/") + PLAYER.main() + except KeyboardInterrupt: + pass + finally: + lcd_byte(0x01, LCD_CMD) From 4763eef0bbc18346359b467e7e88511ea50b46fb Mon Sep 17 00:00:00 2001 From: sobadman <33043156+sobadman@users.noreply.github.com> Date: Sun, 17 Dec 2017 10:18:14 +0900 Subject: [PATCH 15/15] Update and rename 2017-11-29-welcome.markdown to 2017-12-17-welcome.markdown --- ...017-11-29-welcome.markdown => 2017-12-17-welcome.markdown} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename _posts/{2017-11-29-welcome.markdown => 2017-12-17-welcome.markdown} (99%) diff --git a/_posts/2017-11-29-welcome.markdown b/_posts/2017-12-17-welcome.markdown similarity index 99% rename from _posts/2017-11-29-welcome.markdown rename to _posts/2017-12-17-welcome.markdown index 9b92581..f2109e8 100644 --- a/_posts/2017-11-29-welcome.markdown +++ b/_posts/2017-12-17-welcome.markdown @@ -1,7 +1,7 @@ --- layout: post -title: "Welcome to OSS 2017 class!" -date: 2017-11-29 +title: "2017 OSS final video and code" +date: 2017-12-17 categories: --- https://www.youtube.com/watch?v=JvR2igu5XlU