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)
# == SET SAMPLE RATE == print("SETTING SAMPLE RATE TO 62.5") ADC.set_sample_rate(62.5) crate = ADC.get_sample_rate() print(crate) print("") # == CHAN 0 RAW == print("READING LRADC CHAN0 RAW") raw0 = ADC.get_chan0_raw() print(raw0) print("") # == CHAN 1 RAW == print("READING LRADC CHAN1 RAW") raw1 = ADC.get_chan1_raw() print(raw1) print("") # == CHAN 0 == print("READING LRADC CHAN0 WITH SCALE APPLIED") full0 = ADC.get_chan0() print(full0) print("") # == CHAN 1 == print("READING LRADC CHAN1 WITH SCALE APPLIED") full1 = ADC.get_chan1() print(full1) print("")