Exemple #1
0
 def api_lradc_data(self, mode, dat, req_method, req_args):
     resp = copy.deepcopy(self.CHIP_INFO)
     resp["connected"] = True
     resp["mode"] = mode
     # Get Sample Rate
     if mode == "sample_rate" and dat == None and req_method == 'GET':
         resp["message"] = LRADC.get_sample_rate()
     # Set Sample Rate
     elif mode == "sample_rate" and dat != None and req_method in [
             'GET', 'PUT', 'POST'
     ]:
         dat = float(dat)
         if dat in [32.25, 62.5, 125, 250]:
             resp["message"] = "Setting LRADC Sample Rate to " + str(dat)
             LRADC.set_sample_rate(dat)
     # Scale Factor
     elif mode == "scale_factor" and req_method == 'GET':
         resp["message"] = LRADC.get_scale_factor()
     # Get Data
     elif (mode == "full" or mode == "raw") and req_method == 'GET':
         dat = int(dat)
         if dat not in [0, 1]:
             resp["message"] = "Invalid ADC Channel Specified"
         elif dat == 0:
             if mode == "full":
                 resp["message"] = LRADC.get_chan0()
             elif mode == "raw":
                 resp["message"] = LRADC.get_chan0_raw()
         elif dat == 1:
             if mode == "full":
                 resp["message"] = LRADC.get_chan1()
             elif mode == "raw":
                 resp["message"] = LRADC.get_chan1_raw()
     else:
         resp["message"] = "invalid command"
     return jsonify(resp)
Exemple #2
0
 def test_sample_rate_values(self):
     assert LRADC.get_allowable_sample_rates() == (32.25, 62.5, 125, 250)
Exemple #3
0
 def test_scale_factor(self):
     assert LRADC.get_scale_factor() == 31.25
Exemple #4
0
 def test_set_sample_rate(self):
     LRADC.set_sample_rate(32.25)
     assert LRADC.get_sample_rate() == 32.25
Exemple #5
0
import CHIP_IO.LRADC as LRADC
while True:
	print LRADC.get_chan0()

Exemple #6
0
import CHIP_IO.LRADC as ADC

# == ENABLE DEBUG ==
print("ENABLING LRADC DEBUG OUTPUT")
ADC.toggle_debug()

# == SETUP ==
print("LRADC SETUP WITH SAMPLE RATE OF 125")
ADC.setup(125)

# == SCALE FACTOR ==
print("GETTING SCALE FACTOR")
scalefactor = ADC.get_scale_factor()
print(scalefactor)
print("")

# == ALLOWABLE SAMPLING RATES ==
print("GETTING ALLOWABLE SAMPLE RATES")
rates = ADC.get_allowable_sample_rates()
print(rates)
print("IS 32.25 IN RATE TUPLE")
print(ADC.SAMPLE_RATE_32P25 in rates)
print("")

# == CURRENT SAMPLE RATE ==
print("CURRENT SAMPLING RATE")
crate = ADC.get_sample_rate()
print(crate)
print("")

# == SET SAMPLE RATE ==
Exemple #7
0
 def test_sample_rate_values(self):
     assert LRADC.get_allowable_sample_rates() == (32.25, 62.5, 125, 250)
Exemple #8
0
 def test_scale_factor(self):
     assert LRADC.get_scale_factor() == 31.25
Exemple #9
0
 def test_set_sample_rate(self):
     LRADC.set_sample_rate(32.25)
     assert LRADC.get_sample_rate() == 32.25