From 0350a2e433638755b36aaac66ea63dabee51f96e Mon Sep 17 00:00:00 2001 From: Nathan Matsuda Date: Fri, 23 Dec 2016 16:52:24 +0000 Subject: [PATCH] inital commit --- gpio.py | 36 ++++++++++++++++ key.py | 45 +++++++++++++++++++ key_001.py | 103 ++++++++++++++++++++++++++++++++++++++++++++ key_002.py | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ key_003.py | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ rtl_fm_python | 1 + splash.sh | 2 + test_001.png | Bin 0 -> 3838 bytes 8 files changed, 421 insertions(+) create mode 100644 gpio.py create mode 100644 key.py create mode 100644 key_001.py create mode 100644 key_002.py create mode 100755 key_003.py create mode 160000 rtl_fm_python create mode 100755 splash.sh create mode 100644 test_001.png diff --git a/gpio.py b/gpio.py new file mode 100644 index 0000000..8e274a1 --- /dev/null +++ b/gpio.py @@ -0,0 +1,36 @@ +import pygame +import os +from time import sleep +import RPi.GPIO as GPIO + +#Note #21 changed to #27 for rev2 Pi +button_map = {23:(255,0,0), 22:(0,255,0), 27:(0,0,255), 17:(0,0,0)} + +#Setup the GPIOs as inputs with Pull Ups since the buttons are connected to GND +GPIO.setmode(GPIO.BCM) +for k in button_map.keys(): + GPIO.setup(k, GPIO.IN, pull_up_down=GPIO.PUD_UP) + +#Colours +WHITE = (255,255,255) + +os.putenv('SDL_FBDEV', '/dev/fb1') +pygame.init() +pygame.mouse.set_visible(False) +lcd = pygame.display.set_mode((320, 240)) +lcd.fill((0,0,0)) +pygame.display.update() + +font_big = pygame.font.Font(None, 100) + + +while True: + # Scan the buttons + for (k,v) in button_map.items(): + if GPIO.input(k) == False: + lcd.fill(v) + text_surface = font_big.render('%d'%k, True, WHITE) + rect = text_surface.get_rect(center=(160,120)) + lcd.blit(text_surface, rect) + pygame.display.update() + sleep(0.1) diff --git a/key.py b/key.py new file mode 100644 index 0000000..c908650 --- /dev/null +++ b/key.py @@ -0,0 +1,45 @@ +import pygame +import os +from time import sleep +import RPi.GPIO as GPIO + +#Note #21 changed to #27 for rev2 Pi +button_map = {23:(255,0,0), 22:(0,255,0), 27:(0,0,255), 17:(0,0,0)} + +#Setup the GPIOs as inputs with Pull Ups since the buttons are connected to GND +GPIO.setmode(GPIO.BCM) +for k in button_map.keys(): + GPIO.setup(k, GPIO.IN, pull_up_down=GPIO.PUD_UP) + +#Colours +WHITE = (255,255,255) + +os.putenv('SDL_FBDEV', '/dev/fb1') +pygame.init() +pygame.mouse.set_visible(False) +lcd = pygame.display.set_mode((320, 240)) +lcd.fill((0,0,0)) +pygame.display.update() + +font_big = pygame.font.Font(None, 100) + + +while True: + + for event in pygame.event.get(): + if event.type == pygame.KEYDOWN: + lcd.fill((0,0,0)) + text_surface = font_big.render(event.unicode, True, WHITE) + rect = text_surface.get_rect(center=(160,120)) + lcd.blit(text_surface, rect) + pygame.display.update() + + # Scan the buttons +# for (k,v) in button_map.items(): +# if GPIO.input(k) == False: +# lcd.fill(v) +# text_surface = font_big.render('%d'%k, True, WHITE) +# rect = text_surface.get_rect(center=(160,120)) +# lcd.blit(text_surface, rect) +# pygame.display.update() +# sleep(0.1) diff --git a/key_001.py b/key_001.py new file mode 100644 index 0000000..8fb3426 --- /dev/null +++ b/key_001.py @@ -0,0 +1,103 @@ +import pygame +import os +from time import sleep +import RPi.GPIO as GPIO + +#Note #21 changed to #27 for rev2 Pi +button_map = {23:(255,0,0), 22:(0,255,0), 27:(0,0,255), 17:(0,0,0)} + +#Setup the GPIOs as inputs with Pull Ups since the buttons are connected to GND +GPIO.setmode(GPIO.BCM) +for k in button_map.keys(): + GPIO.setup(k, GPIO.IN, pull_up_down=GPIO.PUD_UP) + +#Colours +WHITE = (255,255,255) + +os.putenv('SDL_FBDEV', '/dev/fb1') +pygame.init() +pygame.mouse.set_visible(False) +lcd = pygame.display.set_mode((320, 240)) +lcd.fill((0,0,0)) +pygame.display.update() + +font_big = pygame.font.Font(None, 100) + +dial = 0 + +dialColor = (255,255,255) + +sql = 0 + +sql_str = list("0x"); + +while True: + + for event in pygame.event.get(): + if event.type == pygame.KEYDOWN: + + print pygame.key.name(event.key) + + if event.key == pygame.K_x: + dial += 1 + elif event.key == pygame.K_z: + dial -= 1 + elif event.key == pygame.K_m: + dialColor = (127,255,255) + elif event.key == pygame.K_n: + dialColor = (255,255,255) + elif event.key == pygame.K_0: + sql_str.append('0') + elif event.key == pygame.K_1: + sql_str.append('1') + elif event.key == pygame.K_2: + sql_str.append('2') + elif event.key == pygame.K_3: + sql_str.append('3') + elif event.key == pygame.K_4: + sql_str.append('4') + elif event.key == pygame.K_5: + sql_str.append('5') + elif event.key == pygame.K_6: + sql_str.append('6') + elif event.key == pygame.K_7: + sql_str.append('7') + elif event.key == pygame.K_8: + sql_str.append('8') + elif event.key == pygame.K_9: + sql_str.append('9') + elif event.key == pygame.K_a: + sql_str.append('a') + elif event.key == pygame.K_b: + sql_str.append('b') + elif event.key == pygame.K_c: + sql_str.append('c') + elif event.key == pygame.K_d: + sql_str.append('d') + elif event.key == pygame.K_e: + sql_str.append('e') + elif event.key == pygame.K_f: + sql_str.append('f') + elif event.key == pygame.K_RETURN: + sql = int("".join(sql_str), 0) + sql_str = list("0x") + + lcd.fill((0,0,0)) + text_surface = font_big.render('%d'%dial, True, dialColor) + rect = text_surface.get_rect(center=(160,100)) + lcd.blit(text_surface, rect) + sql_surface = font_big.render('%d'%sql, True, WHITE) + rect = text_surface.get_rect(center=(160,140)) + lcd.blit(sql_surface, rect) + pygame.display.update() + + # Scan the buttons +# for (k,v) in button_map.items(): +# if GPIO.input(k) == False: +# lcd.fill(v) +# text_surface = font_big.render('%d'%k, True, WHITE) +# rect = text_surface.get_rect(center=(160,120)) +# lcd.blit(text_surface, rect) +# pygame.display.update() +# sleep(0.1) + diff --git a/key_002.py b/key_002.py new file mode 100644 index 0000000..509f24c --- /dev/null +++ b/key_002.py @@ -0,0 +1,117 @@ +import pygame +import os +from time import sleep +import RPi.GPIO as GPIO + +#Note #21 changed to #27 for rev2 Pi +button_map = {23:(255,0,0), 22:(0,255,0), 27:(0,0,255), 17:(0,0,0)} + +#Setup the GPIOs as inputs with Pull Ups since the buttons are connected to GND +GPIO.setmode(GPIO.BCM) +for k in button_map.keys(): + GPIO.setup(k, GPIO.IN, pull_up_down=GPIO.PUD_UP) + +#Colours +WHITE = (255,255,255) + +os.putenv('SDL_FBDEV', '/dev/fb1') +pygame.init() +pygame.mouse.set_visible(False) +lcd = pygame.display.set_mode((320, 240)) +lcd.fill((0,0,0)) +pygame.display.update() + +font_big = pygame.font.Font(None, 100) + +dial = 0 + +dialColor = (255,255,255) + +sql = 0 + +sql_str = list("0x") + +freq = [4,4,2,2,7,5] + +freq_idx = 0; + +wasdown = 0; + +while True: + + for event in pygame.event.get(): + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_x: + freq[freq_idx] = (freq[freq_idx] + 1) % 10 + elif event.key == pygame.K_z: + freq[freq_idx] = (freq[freq_idx] - 1) % 10 + elif event.key == pygame.K_m: + wasdown = 1; + elif event.key == pygame.K_n: + if(wasdown == 1): + wasdown = 0 + freq_idx = (freq_idx + 1) % 6 + elif event.key == pygame.K_0: + sql_str.append('0') + elif event.key == pygame.K_1: + sql_str.append('1') + elif event.key == pygame.K_2: + sql_str.append('2') + elif event.key == pygame.K_3: + sql_str.append('3') + elif event.key == pygame.K_4: + sql_str.append('4') + elif event.key == pygame.K_5: + sql_str.append('5') + elif event.key == pygame.K_6: + sql_str.append('6') + elif event.key == pygame.K_7: + sql_str.append('7') + elif event.key == pygame.K_8: + sql_str.append('8') + elif event.key == pygame.K_9: + sql_str.append('9') + elif event.key == pygame.K_a: + sql_str.append('a') + elif event.key == pygame.K_b: + sql_str.append('b') + elif event.key == pygame.K_c: + sql_str.append('c') + elif event.key == pygame.K_d: + sql_str.append('d') + elif event.key == pygame.K_e: + sql_str.append('e') + elif event.key == pygame.K_f: + sql_str.append('f') + elif event.key == pygame.K_RETURN: + sql = int("".join(sql_str), 0) + sql_str = list("0x") + + lcd.fill((0,0,0)) + #text_surface = font_big.render('%d'%dial, True, dialColor) + #rect = text_surface.get_rect(center=(160,100)) + #lcd.blit(text_surface, rect) + + for x in range(0,6): + text_surface = font_big.render('%d'%freq[x], True, WHITE) + rect = text_surface.get_rect(center=((x + .5) * 320 / 6, 80)) + lcd.blit(text_surface, rect) + + pygame.draw.rect(lcd, WHITE, (freq_idx * 320 / 6, 50, 320 / 6, 70), 1) + + pygame.draw.rect(lcd, (255, 200, 10), (10,10,20, 220 * sql / 1024), 0) + #sql_surface = font_big.render('%d'%sql, True, WHITE) + #rect = text_surface.get_rect(center=(160,140)) + #lcd.blit(sql_surface, rect) + pygame.display.update() + + # Scan the buttons +# for (k,v) in button_map.items(): +# if GPIO.input(k) == False: +# lcd.fill(v) +# text_surface = font_big.render('%d'%k, True, WHITE) +# rect = text_surface.get_rect(center=(160,120)) +# lcd.blit(text_surface, rect) +# pygame.display.update() +# sleep(0.1) + diff --git a/key_003.py b/key_003.py new file mode 100755 index 0000000..509f24c --- /dev/null +++ b/key_003.py @@ -0,0 +1,117 @@ +import pygame +import os +from time import sleep +import RPi.GPIO as GPIO + +#Note #21 changed to #27 for rev2 Pi +button_map = {23:(255,0,0), 22:(0,255,0), 27:(0,0,255), 17:(0,0,0)} + +#Setup the GPIOs as inputs with Pull Ups since the buttons are connected to GND +GPIO.setmode(GPIO.BCM) +for k in button_map.keys(): + GPIO.setup(k, GPIO.IN, pull_up_down=GPIO.PUD_UP) + +#Colours +WHITE = (255,255,255) + +os.putenv('SDL_FBDEV', '/dev/fb1') +pygame.init() +pygame.mouse.set_visible(False) +lcd = pygame.display.set_mode((320, 240)) +lcd.fill((0,0,0)) +pygame.display.update() + +font_big = pygame.font.Font(None, 100) + +dial = 0 + +dialColor = (255,255,255) + +sql = 0 + +sql_str = list("0x") + +freq = [4,4,2,2,7,5] + +freq_idx = 0; + +wasdown = 0; + +while True: + + for event in pygame.event.get(): + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_x: + freq[freq_idx] = (freq[freq_idx] + 1) % 10 + elif event.key == pygame.K_z: + freq[freq_idx] = (freq[freq_idx] - 1) % 10 + elif event.key == pygame.K_m: + wasdown = 1; + elif event.key == pygame.K_n: + if(wasdown == 1): + wasdown = 0 + freq_idx = (freq_idx + 1) % 6 + elif event.key == pygame.K_0: + sql_str.append('0') + elif event.key == pygame.K_1: + sql_str.append('1') + elif event.key == pygame.K_2: + sql_str.append('2') + elif event.key == pygame.K_3: + sql_str.append('3') + elif event.key == pygame.K_4: + sql_str.append('4') + elif event.key == pygame.K_5: + sql_str.append('5') + elif event.key == pygame.K_6: + sql_str.append('6') + elif event.key == pygame.K_7: + sql_str.append('7') + elif event.key == pygame.K_8: + sql_str.append('8') + elif event.key == pygame.K_9: + sql_str.append('9') + elif event.key == pygame.K_a: + sql_str.append('a') + elif event.key == pygame.K_b: + sql_str.append('b') + elif event.key == pygame.K_c: + sql_str.append('c') + elif event.key == pygame.K_d: + sql_str.append('d') + elif event.key == pygame.K_e: + sql_str.append('e') + elif event.key == pygame.K_f: + sql_str.append('f') + elif event.key == pygame.K_RETURN: + sql = int("".join(sql_str), 0) + sql_str = list("0x") + + lcd.fill((0,0,0)) + #text_surface = font_big.render('%d'%dial, True, dialColor) + #rect = text_surface.get_rect(center=(160,100)) + #lcd.blit(text_surface, rect) + + for x in range(0,6): + text_surface = font_big.render('%d'%freq[x], True, WHITE) + rect = text_surface.get_rect(center=((x + .5) * 320 / 6, 80)) + lcd.blit(text_surface, rect) + + pygame.draw.rect(lcd, WHITE, (freq_idx * 320 / 6, 50, 320 / 6, 70), 1) + + pygame.draw.rect(lcd, (255, 200, 10), (10,10,20, 220 * sql / 1024), 0) + #sql_surface = font_big.render('%d'%sql, True, WHITE) + #rect = text_surface.get_rect(center=(160,140)) + #lcd.blit(sql_surface, rect) + pygame.display.update() + + # Scan the buttons +# for (k,v) in button_map.items(): +# if GPIO.input(k) == False: +# lcd.fill(v) +# text_surface = font_big.render('%d'%k, True, WHITE) +# rect = text_surface.get_rect(center=(160,120)) +# lcd.blit(text_surface, rect) +# pygame.display.update() +# sleep(0.1) + diff --git a/rtl_fm_python b/rtl_fm_python new file mode 160000 index 0000000..e8d1734 --- /dev/null +++ b/rtl_fm_python @@ -0,0 +1 @@ +Subproject commit e8d173491ff21a58cbebd0185bfb2322bba6ca4d diff --git a/splash.sh b/splash.sh new file mode 100755 index 0000000..9068167 --- /dev/null +++ b/splash.sh @@ -0,0 +1,2 @@ +#!/bin/sh +/usr/bin/fbi -T 2 -d /dev/fb1 -noverbose -a /home/nmatsuda/test_001.png diff --git a/test_001.png b/test_001.png new file mode 100644 index 0000000000000000000000000000000000000000..73e9762fdf0f0771ccfc8643167d56c1ea628b3f GIT binary patch literal 3838 zcmeHKX;c$g7OpA_CkdcI1wjy^2reuE6&pdJR5Yk8f;JHY35XHd5*AU}E8V!#ij2r6 zf-Q4W?4UP<9M^K%(e!jt!-G{m1zW!{gLpV2dKld0lf*TxgAc7hZ8gL+-8sQht zW^-5}T)&{mP?m*-rTP9~Hs?Tw>yEj=r}m6b2j9bNXtjmqI;!Prs^vP0rG<@^mCah~ zzHx6;U_+j<*%J`LhAb>>{`go9)*Amhv(RsA3itgsX!(nq=28Hv&wyJ17VZoE`*lb; z^Z^X0&J67KV{_Qhw`boH?=%3rY?yzakF<92weD>{Q zjoA|KEyW~Jm^G?$?Px8|R1=y|j$g6X!;!rPDsx*a>x^G!7x_kx+F})+E+zT$!uv`` z*`d$Vzr_ir&J|iTonZ6m<-p39Mvx!NuI0R=9@IGP*ls; zR<3$>V|n0-DLc#Wg)0;uvxajGgml-M(fP_KW!<~+YWTaT>DX|~Ro(cc|K3d$7oV@v zi58=z;f}{$q+e)|d{zyoqQB(JRCL>67=d#{}%U{2`N##xc_R6;2 zA2a<|T{I|f^yvRBzA=0E$I7vSwp)B^a(g3xF_k4KbBW^cm;~SXuT_tTRCtt@5 zl0sddjG_c56AE-=G5@Rv<<9cqRYFdQD_te_B_WmA|?doO3ZkA4Y0b38Eg_ zp;;&)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