google-sheet2Html

/*! * * Google Sheets To HTML v0.9a * * To use, simply replace the "tq?key=" value in the * URL below with your own unique Google document ID * * The Google document's sharing must be set to public * */ google.load('visualization', '1', { packages: ['table'] }); var visualization; function drawVisualization() { var query = new google.visualization.Query('https://spreadsheets.google.com/tq?key=https://docs.google.com/spreadsheets/d/1-vUEZ9tae5C_OXzSi0dQPWwUrO3H5S-gImB5afFgqDg/edit?usp=sharing'); query.setQuery('SELECT A, B, C, D label A "Duration", B "Song", C "Requested By", D "URL"'); query.send(handleQueryResponse); } function handleQueryResponse(response) { if (response.isError()) { alert('There was a problem with your query: ' + response.getMessage() + ' ' + response.getDetailedMessage()); return; } var data = response.getDataTable(); visualization = new google.visualization.Table(document.getElementById('table')); visualization.draw(data, { legend: 'bottom' }); } google.setOnLoadCallback(drawVisualization);

Thursday, February 2, 2017

ซิมเพล็กซ์ รีพีทเตอร์ simplex repeater

โปรแกรม simplex repeater ทำเองก็ได้

บทความนี้ แสดงวิธีการ สร้างสถานนีทวนสัญญาณ เพื่อศึกษา การเขียนโปรแกรมเท่านั้น โปรดขอคำแนะนำกับ ศูนย์ควบคุมข่าย ประจำจังหวัด ก่อน ทดสอบ ครับ

โปรแกรม ซิเพล็ก รีพีทเตอร์ ในบทความนี้ใช้ ภาษาไพทอน ร่วมกัน sound meter  ถ้าอ่านแล้วไม่เข้าใจ ขอให้ย้อน ไปดู โพสท์ เก่าๆ ก่อน  โปรแกรมนี้ จะเป็นการเรียกใช้ สคริป ให้ทำงานเมื่อมีระดับเสียงดังในระดับที่กำหนด โดยจะทำการ บันทึกเสียง 10 วินาที จากนั้น จะส่ง สัญญาณ จาก Pyserial ควบคุม ปุ่ม PTT ของวิทยุสื่อสาร ออกอากาศ ด้วยเสียงที่บันทึกไว้โดย สคริป ที่ควบคุม ชื่อ repeater.sh มีรายละเอียดังในภาพ


 เมื่อ soundMeter ได้รับสัญญาณ เสียงจาก ไมโครโฟน ดังกว่าระดับที่ตั้งไว้ จะทำการบันทึกเสียงในไฟล์ชื่อ simplex.wav 
โดยทำการบันทึกเสียง แชนแนลเดียว ด้วย คำสั่ง rec -c 1 โดยกำหนดความยาวเป็นเวลา 10 วินาที่ ด้วย พารามิเตอร์ trim 0 10
คำสั่ง sleep 0.5 ให้ หยุด 0.5 วินาที เพื่อ ให้ pyserial ทำงาน แล้วจึง ส่งเสียงออกมาด้วย คำสั่ง play simplex.wav
 
ในการใช้งาน window  กับ linux การเรียกใช้ Pyserial ต่างกันเล็กน้อย ไปดูโพสท์ เก่าๆ แล้วแก้ไข การควบคุมที่ บรรทัด #insert PTT on กับ #insert PTT off

ดูวีดีโอตัวอย่างใช้งาน https://youtu.be/z5jsPE5CeDg





ในส่วน GUI ด้วย Tkinter Python 2 มีรายละเอียดดังนี้
#!/usr/bin/python
# coding: utf-8

#program radio+computer  by HS1ZFK
#last modify 2/02/2560 ConchRepeater#  version 2.0 Sox

import os
from Tkinter import *





def SetSerial():
    print "set usb serial converter"



def RepeaterOn():
    #repeater Start
    print "start repeater"
    #print ( tiggerValue.get())
    tig = str(tiggerValue.get())
    command = "soundmeter --trigger +" + tig +" 1 --action exec-stop --exec repeater.sh"
    print command
    os.system(command)

def About():
    Message(Mwin, text="Simplex Repeater by HSZFK"
            "set Mic noise Levea ""and time then click start", bg="royalblue", fg="ivory",relief=GROOVE).pack(padx=10, pady=10)

Mwin = Tk()  #Main Window

#set Menu bar
menubar = Menu(Mwin)


#create pulldown menu
ModeMenu = Menu(menubar,tearoff=0)
ModeMenu.add_command(label="Exit ", command=Mwin.quit)
menubar.add_command(label="Set up serial port", command=SetSerial)

menubar.add_command(label="Quit!", command=Mwin.quit)
menubar.add_command(label="About", command=About)


#display menu
Mwin.config(menu=menubar, bg="light cyan")

Mwin.geometry("450x350+300+300")        #set size and position of window
Mwin.title('Simplex_Sox v2.0 by HS1ZFK')




tiggerValue = Scale(Mwin, from_=300, to=500, length=600,label="trigger",bg="light cyan", troughcolor="blue", tickinterval=25, orient=HORIZONTAL)
tiggerValue.set(370)
tiggerValue.pack()

# set button
Btn1 = Button(Mwin,text=" Start Repeater ", bg="pale green",command=RepeaterOn)
Btn1.pack()

Mwin.mainloop()     #start the event loop