Pop

The code to import the whole of Pop Library :

from pop import *



Class Camera

Camera

Initialization

Camera(width=224, height=224, auto_load=True) : Camera object
  Params
   width : camera width. default 224
   height : camera height. default 224
   auto_load : set auto load

Methods

show() : display camera image

stop() : stop display camera image

Example

simple example
from pop import Camera
import time 

cam = Camera()
cam.show()
time.sleep(5)
cam.stop()



Class Out

Output device is controlled by GPIO.

Initialization

Out(n) : Out Object
  Params
   n : GPIO number connected to the Output Device

Methods

allOn() : Set all GPIO connected to Output Device to HIGH

allOff() : Set all GPIO connected to Output Device to LOW

Example

simple example
from pop import Leds
import time 

leds = Leds()
leds.allOn()
time.sleep(1)
leds.allOff()  



Class Led

LEDs are controlled by GPIO.
This class is used in AIoT Home, AIoT Server Plus.

Initialization

Led(n) : Led Object inheriting from Out Class
  Params
   n : GPIO number connected to the LED

Methods

 Refer to Out Class for inherited and used methods.

Example

simple example 1
from pop import Led
import time 

led = Led(1)
led.on()
time.sleep(1)
led.off()    
simple example 2
from pop import Led
import time 

leds = [Led(23), Led(24), Led(25), Led(27)]    

for i in range(20):
    for led in leds:
    led.on()
    time.sleep(0.1)

    for led in leds:
    led.off()
    time.sleep(0.1)  



Class Leds

LEDs are controlled by GPIO.
This class is used in PyCBasic.

Initialization

Leds(n) : Leds object inheriting from Led Class
  Params
   n : List number defined in board and connected to the LED

Methods

show() : display camera image

stop() : stop display camera image

Example

simple example
from pop import Leds
import time 

leds = Leds()
leds.allOn()
time.sleep(1)
leds.allOff()



Class Fan

Fan is controlled by GPIO.
This class is used in AIoT Home.

Initialization

Fan(n) : Fan object inheriting from Out Class
  Params
   n : GPIO number connected to the Fan

Methods

 Refer to Out Class for inherited and used methods.

Example

simple example
from pop import Fan
import time 

dcfan = Fan(17)
dcfan.on()
time.sleep(2)
dcfan.off()



Class Input

Read the Input Device through GPIO.

Initialization

Input(n,activeHigh=True) : Input Object
  Params
   n : GPIO number connected to the Input Device.
   activeHigh : Used to check if the Input Device is HIGH when pressed, Default True.

Definitions

FALLING : Detect Falling Edge.
RISING : Detect Rising Edge.
BOTH : Detect Both Side.

Methods

read() : Read the Input Device status.

setCallback(func,param=None,type=BOTH) : Set Callback function when detecting Edge.
  Params
   func : Function to use when calling Callback.
   param : Parameters passed to the Callback function, Default None.
   type : Call condition of Callback function, Default BOTH.

Example

simple example
from pop import Input

input = Input(22)
data = input.read()
print(ret)



Class Flame

Flame sensor status reading.
This class is used in AIoT Server Plus, SensorPack option.

Initialization

Flame(n) : Flame object inheriting from Input Class
  Params
   n : Connected pin number.

Methods

read() : Returns Flame status. If flame is detected, value is False. And if flame is not detected, value is True.

setCallback(func,param=None,type=BOTH) : Callback function setting called Edge is detected.
  Params
   func : Callback function
   param : Parameters passed to Callback function
   type : Edge type

Example

simple example 1
from pop import Flame
import time

flame1 = Flame(17)
flame2 = Flame(27)

while True:
    print("flame1 : %d , flame2 : %d"%(flame1.read(),flame2.read()))
    time.sleep(0.05)
simple example 2
from pop import Flame
import time

flame1 = Flame(17)
count = 0

def onFlame(unuse):
    globla count
    caount += 1
    print("flame = %d"%(count))
    time.sleep(1)

flame.setCallback(onFlame, None, Flame.FALLING)
input("Press <Enter> Key...\n")



Class Switch

Read the switch status through GPIO.
This class is used in AIoT Server Plus.

Initialization

Switch(n) : Switch object inheriting from Input Class
  Params
   n : GPIO number connected to the switch.

Methods

 Refer to Input Class for inherited and used methods.

Example

simple example
from pop import Switch

sw = Switch(22)
data = sw.read()
print(data)



Class Switches

Read the switch status through GPIO.
This class is used in PyCBasic.

Initialization

Switches(n) : Switch object inheriting from Input Class
  Params
   n : List number defined in the board and connected to the Switch.

Methods

 Refer to Input Class or Switch Class for inherited and used methods.

Example

simple example
from pop import Switches
switch = Switches()

data = switch[0].read()

print(data)



Class Bme680

Read the gas, temperature, humidity and pressure status.
This class is used in SensorPack option.

Initialization

Bme680(n) : Bme680 object
  Params
   n : I2C Address of Bme680. Default 0x77.

Methods

init() : Bme680 chip initialization, called when creating a class.

softReset() : Bme680 chip software reset.

getSensorData() : Data collection of temperature/humidity sensor, return in list format (temperature, pressure, humidity, gas_resistance).

getTemperature() : Returns temperature data(°C).

getHumidity() : Returns humidity data(%).

getPressure() : Returns atmospheric pressure data(hpa).

getGas() : Returns gas data(ohm).

Example

simple example
from pop import Bme680
import time

b = Bme680(0x77)

while True:
    sensor = b.getSensorData()
    temp = b.getTemperature()
    humi = b.getHumidity()
    pressure = b.getPressure()
    gas = b.getGas()
    print("sensor data = %d, %d, %d, %d"%(sensor[0],sensor[1],sensor[2] ,sensor[3]))
    print("temp : %d [C], humi : %d [%%] , pressure : %d [hpa], gas : %d [ohm]"%(temp,humi,pressure,gas))
    time.sleep(0.5)



Class Light

Light status reading.
This class is used in SensorPack option.

Initialization

Light(n) : Light object
  Params
   n : I2C Address of Light chip. Default 0x23.

Methods

init() : Light chip initialization, Called when creating class.

getLight() : Returns Light data(lx).

Example

simple example
from pop import Light
import time

l = Light(0x23)

while True:
    print("light : %d [lx]"%l.getLight())
    time.sleep(0.5)



Class CO2

Read status of CO2 Sensor.
This class is used in SensorPack option.

Initialization

CO2() : CO2 Producer. It takes 1 second to initialize

Methods

read() : Return CO2 ppm value of CO2 Sensor. It takes 5 seconds to return.

Example

simple example
from pop import CO2
import time

c = CO2()

while True:
    print(c.read())



Class Thermopile

Thermopile sensor status reading.
This class is used in SensorPack option.

Initialization

Thermopile(n) : Thermopile object inheriting from PopThread
  Params
   n : Connected SEC pin number.

Methods

read() : Returns measured temperature(°C).

setChipSelect(cs) : Sets SEC pin.
  Params
   cs : Connected pin number

setInterval(n) : Sets Laser Turn on cycle(sec).
  Params
   n : Laser Turn on cycle (sec)

laserOn() : Manual command for Laser Turn on.

setLaserAutomode(Automode) : Laser Automode setting. Sets to Default True when creating a class.
  Params
   Automode : If True, sets Automode. Release if False.

Example

simple example
from pop import Thermopile
import time

d = Thermopile(7)

while True:
    print(d.read())
    time.sleep(1)



Class MicroWave

Reading the speed of obstacles ahead of Micro Wave Sensor.
This class is used in SensorPack option.

Initialization

MicroWave(n) : MicroWave object
  Params
   n : Connected pin information.

Methods

read() : Returns the speed of the obstacle ahead (km/h). If not, returns 0.

Example

simple example
from pop import MicroWave
import time

m = MicroWave(16)

while True:
    result = m.read()

    if result!=0:
        print("%5.5f [km/h]\r\n"%(result))
    else:
        print(".\n")

    time.sleep(0.5)

Class Pir

Responds to the movement of infrared wavelengths emitted or reflected from an object.
This class is used in AIoT Server Plus, SensorPack option.

Initialization

Pir(n) : Pir object inheriting from Input Class
  Params
   n : GPIO number connected to the Pir.

Methods

 Refer to Input Class for inherited and used methods.

Example

simple example 1
from pop import Pir
pir = Pir(22)

data = pir.read()

print(data)
simple example 2
from pop import Pir
import time

pir = Pir(22)

def onPir(param):
    ret = pir.read()
    if ret == True:
        print("detect...")
        time.sleep(2)
    else:
        time.sleep(0.1)

pir.setCallback(onPir)
input("Press <Enter> Key...\n")



Class SpiAdc

adc chip control through spi interface.

Initialization

SpiAdc(channel, device=0, ce=0, speed=1000000) : SpiAdc object
  Params
   channel : ADC Channel.
   device : SPI Interface Channel, Default 0 (in Raspberry Pi).
   ce : The SPI_CE(or CS) number to which the slave is connected. Default 0.
   speed : SPI Interface Clock Speed, Default 1000000(1MHz).

Definitions

TYPE_AVERAGE : Average data based on sampling count.
TYPE_NORMAL : Unaveraged raw data.
MODE_FULL : Call Callback function always.
MODE_INCLUSIVE : If data is in a range (max, min), call Callback function.
MODE_EXCLUSIVE : If data is over a range, call Callback function.

Methods

getSample() : Get Sampling Count.

read() : Read Data from Device (Raw Type).

readAverage() : Read Average Data from Device.

run() : Read data and call Callback function according to mode.

setSample(sample) : Set Sampling Count.
  Params
   sample : Sampling count.

readVolt(ref=3.3,max=3020.0) : Read Data from Device. (Voltage Type)
  Params
   ref : Reference Voltage.
   max : Maximum value of raw data.

readVoltAverage(ref=3.3,max=3020.0) : Read Data from Device. (Voltage Type)
  Params
   ref : Reference Voltage.
   max : Maximum value of raw data.

setCallback(func,param=None,type=TYPE_AVERAGE,mode=MODE_FULL,min=0,max=ADC_MAX) : Set up callback function for automatic data read.
  Params
   func : Function to use when calling Callback.
   param : Arguments passed to the Callback function. Default None.
   type : Data Read Type. Default TYPE_AVERAGE.
   mode : Select Mod. Default MODE_FULL.
   min : analog data minimum. Default 0.
   max : analog data maximum. Default 4095. (MCP3208 12bit ADC Chip)



Class Psd

Distance measurement using PSD sensor.
This class is used in AIoT Server Plus, PyCBasic.

Initialization

Psd(channel=-1, device=0, ce=0, speed=1000000) : PSD object inheriting from SpiAdc Class
  Params
   channel : ADC Channel.
   device : SPI Interface Channel. Default 0. (in Raspberry Pi)
   ce : The SPI_CE(or CS) number to which the slave is connected. Default 0.
   speed : SPI Interface Clock Speed. Default 1000000(1MHz).

Methods

calcDist(val,calibration=1.1) : Calculate distance value from raw data.
  Params
   val : ADC Raw Data.
   calibration : Calibration Value. Default 1.1.



Class CDS

Light measurement using CDS sensor.
This class is used in AIoT AutoCAR, AIoT AutoCAR Prime, AIoT AutoCAR Prime X, AIoT Home, AIoT SerBot, AIoT SerBot Prime X, AIoT Server Plus, PyCBasic.

Initialization

Cds(channel=-1, device=0, ce=0, speed=1000000) : Cds object inheriting from SpiAdc Class
  Params
   channel : ADC Channel
   device : SPI Interface Channel. Default 0. (in Raspberry Pi)
   ce : The SPI_CE(or CS) number to which the slave is connected. Default 0.
   speed : SPI Interface Clock Speed. Default 1000000(1MHz).

Methods

readAverage() : Read lux data from device and calibration function.
setCalibrationPseudoLx(func) : Set calibration function.
  Params
   func : Calibration function.



Class Gas

Gas amount measurement using Gas sensor.
This class is used in AIoT Home, AIoT Server Plus.

Initialization

Gas(channel=-1, device=0, ce=0, speed=1000000) : Gas object inheriting from SpiAdc Class
  Params
   channel : ADC Channel
   device : SPI Interface Channel. Default 0. (in Raspberry Pi)
   ce : The SPI_CE(or CS) number to which the slave is connected. Default 0.
   speed : SPI Interface Clock Speed. Default 1000000(1MHz).

Methods

read() : Measured gas volume read as voltage value.

readAverage() : Read the average gas volume as an RMS-based voltage value.

calcPropan(val) : Convert gas volume into propane amounts in PPM units.
  Params
   val : Value read through method 'readAverage'.

calcMethan(val) : Convert gas volume into methane amounts in PPM units.
  Params
   val : Value read through method 'readAverage'.

calcEthanol(val) : Convert gas volume into ethanol amounts in PPM units.
  Params
   val : Value read through method 'readAverage'.



Class Temperature

Temperature measurement using LM32 sensor.
This class is used in AIoT Server Plus.

Initialization

Temperature(channel, device=0, ce=0, speed=1000000) : Temperature object inheriting from SpiAdc Class
  Params
   channel : ADC Channel.
   device : SPI Interface Channel. Default 0. (in Raspberry Pi)
   ce : The SPI_CE(or CS) number to which the slave is connected. Default 0.
   speed : SPI Interface Clock Speed. Default 1000000(1MHz).

Methods

calcTempC(val) : Convert the value read to Celsius temperature.
  Params
   val : Value read through method 'readAverage'.



Class Sound

Ambient sound measurement using Sound sensor.
This class is used in AIoT Server Plus, PyCBasic.

Initialization

Sound(channel=-1, device=0, ce=0, speed=1000000) : Sound object inheriting from SpiAdc Class
  Params
   channel : ADC Channel.
   device : SPI Interface Channel. Default 0. (in Raspberry Pi)
   ce : The SPI_CE(or CS) number to which the slave is connected. Default 0.
   speed : SPI Interface Clock Speed. Default 1000000(1MHz).



Class Potentiometer

Voltage measurement with variable resistor.
This class is used in AIoT Server Plus, PyCBasic.

Initialization

Potentiometer(channel=-1, device=0, ce=0, speed=1000000) : Potentiometer object inheriting from SpiAdc Class
  Params
   channel : ADC Channel.
   device : SPI Interface Channel. Default 0. (in Raspberry Pi)
   ce : The SPI_CE(or CS) number to which the slave is connected. Default 0.
   speed : SPI Interface Clock Speed. Default 1000000(1MHz).

Methods

readAverage() : return level from range table.
getRangeTable() : return range table.
setRangeTable(table) : Set potentiometer range table.
  Params
   table : Table with 10 elements.
    ex) [48, 300, 700, 1090, 1540, 1945, 2320, 2715, 2980, 3040]


Class PiezoBuzzer

PiezoBuzzer is controlled by Software PWM.
This class is used in AIoT Home, PyCBasic, SensorPack option.

Initialization

PiezoBuzzer(n) : PiezoBuzzer object inheriting from PopThread
  Params
   n : A GPIO number connected to the PiezoBuzzer defined in board, or it can be manually set.

Methods

isPlay() : Return play status.
getTempo() : Get tempo value.
setTempo(n) : Set tempo value.
  Params
   n : Value to be set to tempo.

tone(scale,pitch,duration) : Play a note on piezo buzzer during duration value.
  Params
   scale : Scale value to play on piezo buzzer (int type).
   pitch : Pitch value to play on piezo buzzer. 'Do' is 1, 'Do♯' is 2, 'Re' is 3 and 'Si' is 12.
   duration : Tone is playing during duration value.

rest(duration) : Stop to play piezo buzzer.
  Params
   duration : The duration of the stopping.

play(sheet) : Play music by sheet.
  Params
   sheet : list [[scale],[pitch],[duration]].

Example

simple example 1
from pop import PiezoBuzzer
p = PiezoBuzzer(12)

p.tone(4, 8, 4)
simple example 2
from pop import PiezoBuzzer
p = PiezoBuzzer(12)

p.setTempo(120)

butterfly_scale = [4,4,4, 4,4,4, 4,4,4,4, 4,4,4,  4,4,4,4, 4,4,4, 4,4,4,4, 4,4,4]
butterfly_pitch = [8,5,5, 6,3,3, 1,3,5,6, 8,8,8,  8,5,5,5, 6,3,3, 1,5,8,8, 5,5,5]
butterfly_duration = [8,8,4, 8,8,4, 8,8,8,8, 8,8,4,  8,8,8,8, 8,8,4, 8,8,8,8, 8,8,4]
sheet_butterfly = [butterfly_scale, butterfly_pitch, butterfly_duration]

p.play(sheet_butterfly)



Class PixelDisplay

Pixel Display is controlled by Hardware PWM.
This class is used in PyCBasic, SensorPack option.

Initialization

PixelDisplay(width=8, height=8, gpio=-1, type=GRB, dma=10, automode=True, debug=False) : PixelDisplay object
  Params
   width : Number of pixel width.
   height : Number of pixel height.
   automode : Automode setting. True or False.

Methods

display() : Send command from buffer when Automode is False, this is not executed and the command is automaically sent when Automode is True.
getRGBType(): Get the RGB Type.
RGBtoHEX(color_arr) : Convert the RGB list data to HEX.
clear() : Clear Pixel Display.
rainbow() : Display rainbow color on Pixel Display.
fill(color_arr) : Fill Pixel Display with one color.
  Params
   color_arr : A color to be filled. Type is list of [R, G, B].

setColor(x, y, color_arr) : Set Pixel Display color_arr on x,y.
  Params
   x : x-axis.
   y : y-axis.
   color_arr : A color to be set. Type is list of [R, G, B] or HEX (0xRRGGBB).

getColor(x, y) : Return color on x,y as INT type.
  Params
   x : x-axis.
   y : y-axis.

setAutomode(automode) : Set automode. Default True. If False set, display() should be used.
  Params
   automode : True or False.

setBrightness(brightness) : Set Brightness.
  Params
   brightness : Brightness (0~255).

setColorInvert(invert) : Invert the color. Default False.
  Params
   invert
    True : input (255,0,0) -> (0,255,255).
    False : input (255,0,0) -> (255,0,0).

Example

simple example
from pop import PixelDisplay
import time 

display = PixelDisplay()

display.setColor(0, 0, [5, 0, 0])
time.sleep(1)
display.fill([5, 0, 0])
time.sleep(1)



Class Dust

dust measurement using Dust sensor.
This class is used in AIoT Home, AIoT Server Plus, SensorPack option.

Initialization

Dust(addr) : Dust object
  Params
   addr : I2c slave address. default 0x28.

Methods

reset() : Software reset for Dust Sensor.

read() : Read all sensor data that can be read by the dust sensor.

Variables
pm_1p0_grimm : Fine dust data read pm1.0 by grimm.
pm_2p5_grimm : Fine dust data read pm2.5 by grimm.
pm_10_grimm : Fine dust data read pm10 by grimm.
pm_1p0_tsi : Fine dust data read pm1.0 by tsi.
pm_2p5_tsi : Fine dust data read pm2.5 by tsi.
pm_10_tsi : Fine dust data read pm10 by tsi.

Example

simple example
from pop import Dust
import time 

dust = Dust()
while True:
    dust.read()
    print("PM 1.0 GRIM  : %u ㎍/㎥"%dust.pm_1p0_grimm)
    print("PM 2.5 GRIM  : %u ㎍/㎥"%dust.pm_2p5_grimm)
    print("PM 10  GRIM  : %u ㎍/㎥"%dust.pm_10_grimm)
    time.sleep(0.5)



Class PwmController

I2C communication allows PWM signals to be generated by issuing control commands to the PWM control module, specifying the desired frequency and desired duty cycle for each outputable channel.
This class is used in AIoT Home, AI Mavin, SensorPack option.

Initialization

PwmController(addr) : PwmController object
  Params
   addr : I2c slave address. default 0x5e.

Methods

init() : initialize PwmController.

setChannel(channel) : Set the PWM Channel for control.
  Params
   channel : channel value. (0 ~ 15)

setDuty(percent) : Specifies the duty cycle of pwm.
  Params
   percent : Specifies the duty ratio as a percentage. (0 ~ 100)

setFreq(freq) : Specifies the pwm frequency.
  Params
   freq : Frequency. ex) 50 -> 50Hz

setInvertPulse() : Invert the output PWM signal.

Example

simple example
from pop import PwmController
import time

pwm = PwmController()
pwm.init()
pwm.setChannel(0)
pwm.setFreq(50)
for i in range(10):
    pwm.setDuty(i*10)
    time.sleep(0.5)



Class Audio

Initialization

Audio(blocking=True, cont=False) : Audio object
  Params
   blocking : If True, working in blocking mode. Else non-blocking mode. Default is True.
   cont : If True, repeat playing file. Else play one time. This is working in only non-blocking mode. Default is False.

Methods

stop() : Stop playing if in non-blocking mode. This method is used in subclass like 'AudioPlay'.
close() : Clear audio resources explicitly. This method is used in subclass like 'AudioPlay'.



Class AudioPlay

Initialization

AudioPlay(file, blocking=True, cont=False) : AudioPlay object
  Params
   file : Name of WAV file to play.
   blocking : If True, working in blocking mode. Else non-blocking mode. Default is True.
   cont : If True, repeat playing file. Else play one time. This is working in only non-blocking mode. Default is False.

Methods

run() : Start playing the file.
isPlay() : Return playing status. True means playing now, False means stopped.

Example

simple example
from pop import AudioPlay
import time 

with AudioPlay("/usr/share/sounds/alsa/Side_Left.wav", False, True) as play:   
    play.run()
    print("Start Play...")
    for _ in range(12):  
        time.sleep(1)

    play.stop()
    print("Stop play...")



Class AudioPlayList

Initialization

AudioPlayList(files, blocking=True, cont=False) : AudioPlayList object
  Params
   files : Names of WAV file to play. (list type)
   blocking : If True, working in blocking mode. Else non-blocking mode. Default is True.
   cont : If True, repeat playing file. Else play one time. This is working in only non-blocking mode. Default is False.

Methods

isPlay() : Return playing status. True means playing now, False means stopped.
run(pos=0) : Start playing the file.
  Params
   pos : Index of WAV file in playing list. Default is 0.

Example

simple example
from pop import AudioPlayList
import time 

playlist = ["/usr/share/sounds/alsa/Front_Center.wav", "/usr/share/sounds/alsa/Side_Left.wav", "/usr/share/sounds/alsa/Side_Right.wav"]

with AudioPlayList(playlist) as play:
    print("Start PlayList...") 
    play.run()



Class AudioRecord

Initialization

AudioRecord(file, sFormat=8, sChannel=1, sRate=48000, sFramePerBuffer=1024) : AudioRecord object. Only non-blocking mode is supported.

  Params
   file : Name of WAV file to save.
   sFormat : Sampling type. 8 is paInt16, 2 is paInt32, 1 is pa Float32. Default is 8. (int type)
   sChannel : Number of channel. Default is 1.
   sRate : Sampling rate(Hz). Default is 48000.
   sFramePerBuffer : Frame per buffer. Default 1024.

Methods

run() : Start recording.

Example

simple example
from pop import AudioRecord
import time 

with AudioRecord("my_record.wav") as record:
    record.run()
    print("Start Recording...") 

    for _ in range(5):
        time.sleep(1)

    record.stop()
    print("Stop Recording...") 



Class Tone

Initialization

Tone(tempo=100, volume=.5, rate=48000, channels=1) : Tone object
  Params
   tempo : Tempo of melody. Default is 100.
   volume : Volume of meldy. Default is 0.5. (0 ~ 1)
   rate : Sampling rate(Hz). Default is 48000.
   channels : Number of channels. Default is 1.

Methods

close() : Clear audio resources explicitly.
setTempo(tempo) : Set the tempo of melody.
  Params
   tempo : Value of tempo.
rest(duration) : Intervals of silence.
  Params
   duration : Duration of silence. (4, 2, 1, 1/2, 1/4, ...)
play(octave, pitch, duration) : Play the melody.
  Params
   octave : Octave of melody. (1 ~ 8)
   pitch : Pitch of melody. ("DO", "DO#", "RE", "RE#", "MI", "FA", "SOL", "SOL#", "RA", "RA#", "SI")
   duration : Duration of melody.

Example

simple example1
from pop import Tone
import time 

with Tone() as tone:
    for n in [1, 3, 5, 7, 8, 10, 12]:
        tone.play(3, n, 4)
simple example2
from pop import Tone

schoolBell1 = ((4, "SOL", 1/4), (4, "SOL", 1/4), (4, "RA", 1/4), (4, "RA", 1/4), (4, "SOL", 1/4), (4, "SOL", 1/4), (4, "MI", 1/2), (4, "SOL", 1/4), (4, "SOL", 1/4), (4, "MI", 1/4), (4, "MI", 1/4), (4, "RE", 1/2 + 1/4))
schoolBell2 = (*schoolBell1[:7], (4, "SOL", 1/4), (4, "MI", 1/4), (4, "RE", 1/4), (4, "MI", 1/4), (4, "DO", 1/2 + 1/4))

with Tone() as tone:
    tone.setTempo(200)

    for n in schoolBell1:
        tone.play(*n)
    tone.rest(1/4)

    for n in schoolBell2:
        tone.play(*n)
    tone.rest(1/4)



Class SoundMeter

Initialization

SoundMeter(sampleFormat=pyaudio.paInt16, channelNums=1, framesPerBuffer=1024, sampleRate=48000) : SoundMeter object
  Params
   sampleFormat : Sampling type. Default is pyaudio.paInt16.
   channelNums : Number of channel. Default is 1.
   framesPerBuffer : Frame per buffer. Default 1024.
   sampleRate : Sampling rate(Hz). Default is 48000.

Methods

stop() : Stop measurement and clear audio resources explicitly.
setCallback(func, args) : Set user callback method and start measurement.
  
Params*
   func : User callback method.
   *args : Argument to be conveyed to user callback method. (skippable)

Example

simple example
import time
from pop import SoundMeter

sm = SoundMeter()

def onSoundMeter(rms, inData):
    if(rms>600):
        print(rms)

sm.setCallback(onSoundMeter)

input("input something")

sm.stop()