Example #1
0
 def test_adc_max_res(self):
   adc_max_res = m.adcRawBits()
   print("Platform ADC max. resolution is: " + str(adc_max_res) + " bits")
   self.assertEqual(adc_max_res, PLATFORM_MAX_ADC_RES_BITS, "Wrong ADC max. resolution")
Example #2
0
import mraa

mraa.init()
print(mraa.getPinCount())
print(mraa.getVersion())
print("Raw adc bits: " + str(mraa.adcRawBits()))
print("Support adc bits: " + str(mraa.adcSupportedBits()))
count = 0
while (count < 100):
    try:
        #There is no adcs on this dragonboard. wtf!! even from 0 to 100
        print("Reading I2c" + str(count))
        port = mraa.I2c(count)
        print("Trying to read I2c" + str(count))
        port.dir(mraa.DIR_IN)
        a = port.read(count)

        if (a / 255 * 100 > 90):
            pass  #BOTTLE IF FULL
        elif (a / 255 * 100 < 50):
            pass  #BOTTLE IS HALF FULL
        elif (a / 255 * 100 < 25):
            pass  #YOU MIGHT WANNA CONSIDER REFILL THE MEDICINE
        elif (a / 255 * 100 < 10):
            pass  #TIME TO GO GET MEDICATION
        print("Got a I2c" + str(count) + " of " + str(a))
    except:
        print("Are you sure you have an I2c" + str(count))
    count = count + 1
Example #3
0
 def test_adc_max_res(self):
     adc_max_res = m.adcRawBits()
     print("Platform ADC max. resolution is: " + str(adc_max_res) + " bits")
     self.assertEqual(adc_max_res, PLATFORM_MAX_ADC_RES_BITS,
                      "Wrong ADC max. resolution")
Example #4
0
 def test_mraa_check_platform_ADC_max_resolution(self):
     self.p_ADC_mres = m.adcRawBits()
     print("Platform ADC max. resolution is: " + str(self.p_ADC_mres) +
           " bits")
     self.assertEqual(self.p_ADC_mres, 12,
                      "Wrong ADC max. resolution. Check platform ...")
Example #5
0
 def test_mraa_check_platform_ADC_max_resolution(self):
     self.p_ADC_mres = m.adcRawBits()
     print("Platform ADC max. resolution is: " + str(self.p_ADC_mres) + " bits")
     self.assertEqual(self.p_ADC_mres, 12, "Wrong ADC max. resolution. Check platform ...")