Ejemplo n.º 1
0
 def test_adc_std_res(self):
   adc_std_res = m.adcSupportedBits()
   print("Platform ADC standard resolution is: " + str(adc_std_res) + " bits")
   self.assertEqual(adc_std_res, PLATFORM_STD_ADC_RES_BITS, "Wrong ADC standard resolution")
Ejemplo n.º 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
Ejemplo n.º 3
0
 def test_adc_std_res(self):
     adc_std_res = m.adcSupportedBits()
     print("Platform ADC standard resolution is: " + str(adc_std_res) +
           " bits")
     self.assertEqual(adc_std_res, PLATFORM_STD_ADC_RES_BITS,
                      "Wrong ADC standard resolution")
Ejemplo n.º 4
0
 def test_mraa_check_platform_ADC_resolution(self):
     self.p_ADC_res = m.adcSupportedBits()
     print("Platform ADC resolution is: " + str(self.p_ADC_res) + " bits")
     self.assertEqual(self.p_ADC_res, 10,
                      "Wrong ADC supported resolution. Check platform ...")
Ejemplo n.º 5
0
 def test_mraa_check_platform_ADC_resolution(self):
     self.p_ADC_res = m.adcSupportedBits()
     print("Platform ADC resolution is: " + str(self.p_ADC_res) + " bits")
     self.assertEqual(self.p_ADC_res, 10, "Wrong ADC suported resolution. Check platform ...")