Esempio n. 1
0
    def __init__(self, *args, **kwargs):

        i2c_bus = 1
        adress = os.popen("i2cdetect -y -r 1 0x48 0x48 | egrep '48' | awk '{print $2}'").read()
        adress8 = os.popen("i2cdetect -y -r 8 0x48 0x48 | egrep '48' | awk '{print $2}'").read()
        if(adress=='48\n'):
            self.ads = ads1115.ADS1115()
        elif (adress8 =='48\n'):
            self.ads = ads1115.ADS1115(i2c_bus=8)
            i2c_bus = 8
        else:
            self.ads = None


        adress = os.popen("i2cdetect -y -r 1 0x41 0x41 | egrep '41' | awk '{print $2}'").read()
        adress8 = os.popen("i2cdetect -y -r 8 0x41 0x41 | egrep '41' | awk '{print $2}'").read()
        if(adress=='41\n'):
            self.ina219 = ina219.INA219(addr=0x41)
        if(adress8=='41\n'):
            self.ina219 = ina219.INA219(addr=0x41, i2c_bus=8)
            i2c_bus = 8
        else:
            self.ina219 = None
            
        adress = os.popen("i2cdetect -y -r 1 0x42 0x42 | egrep '42' | awk '{print $2}'").read()
        adress8 = os.popen("i2cdetect -y -r 8 0x42 0x42 | egrep '42' | awk '{print $2}'").read()
        if(adress=='42\n'):
            self.ina = ina219.INA219(addr=0x42)
        if(adress8=='42\n'):
            self.ina = ina219.INA219(addr=0x42, i2c_bus=8)
            i2c_bus = 8
        else:
            self.ina = None
        
        print("I2C-BUS:", i2c_bus)
            
        self.display = Adafruit_SSD1306.SSD1306_128_32(rst=None, i2c_bus=i2c_bus, gpio=1) 
        self.display.begin()
        self.display.clear()
        self.display.display()
        self.font = PIL.ImageFont.load_default()
        self.image = PIL.Image.new('1', (self.display.width, self.display.height))
        self.draw = PIL.ImageDraw.Draw(self.image)
        self.draw.rectangle((0, 0, self.image.width, self.image.height), outline=0, fill=0)
        self.stats_enabled = False
        self.stats_thread = None
        self.stats_interval = 1.0
        self.enable_stats()
Esempio n. 2
0
if platform_is_nano():
    i2c_bus = 1
else:
    i2c_bus = 8  # NX?

adress = os.popen("i2cdetect -y -r " + str(i2c_bus) +
                  " 0x48 0x48 | egrep '48' | awk '{print $2}'").read()
if (adress == '48\n'):
    ads = ads1115.ADS1115(i2c_bus=i2c_bus)
else:
    ads = None

adress = os.popen("i2cdetect -y -r " + str(i2c_bus) +
                  " 0x41 0x41 | egrep '41' | awk '{print $2}'").read()
if (adress == '41\n'):
    ina = ina219.INA219(addr=0x41, i2c_bus=i2c_bus)
else:
    ina = None

# 128x32 display with hardware I2C:
disp = Adafruit_SSD1306.SSD1306_128_32(
    rst=None, i2c_bus=i2c_bus,
    gpio=1)  # setting gpio to 1 is hack to avoid platform detection

# Initialize library.
disp.begin()

# Clear display.
disp.clear()
disp.display()
Esempio n. 3
0
from jetcard import ads1115
from jetcard import ina219
import os
import subprocess

adress = os.popen(
    "i2cdetect -y -r 1 0x48 0x48 | egrep '48' | awk '{print $2}'").read()
if (adress == '48\n'):
    ads = ads1115.ADS1115()
else:
    ads = None

adress = os.popen(
    "i2cdetect -y -r 1 0x41 0x41 | egrep '41' | awk '{print $2}'").read()
if (adress == '41\n'):
    ina = ina219.INA219(addr=0x41)
else:
    ina = None

# 128x32 display with hardware I2C:
disp = Adafruit_SSD1306.SSD1306_128_32(
    rst=None, i2c_bus=1,
    gpio=1)  # setting gpio to 1 is hack to avoid platform detection

# Initialize library.
disp.begin()

# Clear display.
disp.clear()
disp.display()