Esempio n. 1
0
    def __init__(self, config) :

        pin_a = Pin(BUTTON_A_PIN, mode=Pin.IN, pull=None)
        pin_b = Pin(BUTTON_B_PIN, mode=Pin.IN, pull=None)
        pin_c = Pin(BUTTON_C_PIN, mode=Pin.IN, pull=None)
        
        self.buttonA = Button(pin=pin_a)
        self.buttonB = Button(pin=pin_b)
        self.buttonC = Button(pin=pin_c)
        self.buttonA.press_func(self.button_A_callback, (pin_a,))  # Note how function and args are passed
        self.buttonB.press_func(self.button_B_callback, (pin_b,))  # Note how function and args are passed
        self.buttonC.press_func(self.button_C_callback, (pin_c,))  # Note how function and args are passed
 
        # display
        self.display = None
        self.screen_power = None
        self.header_font = None
        self.large_label_font = None
        self.small_label_font = None

        self.setup_screen()

        # screen saver
        # 0 - disable
        # x - screen saver activation in second
        self.screensaver = 0
        self.currentcount  = 0
        if "screensaver" in config:
            self.screensaver = int(config["screensaver"])
            self.currentcount = int(config["screensaver"])
        
        self.screen_timeout_lock = Lock()
        
        # wifi
        super().__init__(config)
Esempio n. 2
0
 def set_pin_callback(self, button, cb):
     '''
     call this to override the PIN callback function
     '''
     if button == BUTTON_A_PIN:
         self.buttonA = Button(pin=Pin(BUTTON_A_PIN, mode=Pin.IN,
                                       pull=None),
                               callback=cb,
                               trigger=Pin.IRQ_FALLING)
Esempio n. 3
0
    def __init__(self, config):

        # TTGO hardware specific
        '''
        self.buttonA = Button(pin=Pin(BUTTON_A_PIN, mode=Pin.IN, pull=None),  
            callback=self.button_A_callback, trigger=Pin.IRQ_FALLING)
        self.buttonB = Button(pin=Pin(BUTTON_B_PIN, mode=Pin.IN, pull=None),  
            callback=self.button_C_callback, trigger=Pin.IRQ_FALLING)
        self.buttonC = Button(pin=Pin(BUTTON_C_PIN, mode=Pin.IN, pull=None),  
            callback=self.button_C_callback, trigger=Pin.IRQ_FALLING)
        '''
        pin_a = Pin(BUTTON_A_PIN, mode=Pin.IN, pull=None)
        pin_b = Pin(BUTTON_B_PIN, mode=Pin.IN, pull=None)
        pin_c = Pin(BUTTON_C_PIN, mode=Pin.IN, pull=None)

        self.buttonA = Button(pin=pin_a)
        self.buttonB = Button(pin=pin_b)
        self.buttonC = Button(pin=pin_c)
        self.buttonA.press_func(
            self.button_A_callback,
            (pin_a, ))  # Note how function and args are passed
        self.buttonB.press_func(
            self.button_B_callback,
            (pin_b, ))  # Note how function and args are passed
        self.buttonC.press_func(
            self.button_C_callback,
            (pin_c, ))  # Note how function and args are passed

        self.led = Pin(LED, mode=Pin.OUT)

        #configure the battery reading
        self.vbat = ADC(Pin(BATT_PIN))
        self.vbat.atten(ADC.ATTN_0DB)
        self.vbat.width(ADC.WIDTH_12BIT)

        self.tranport_handler = None
        super().__init__(config)
Esempio n. 4
0
    def __init__(self, config):

        # MH-ET Live ESP32  hardware specific
        pin_a = Pin(BUTTON_A_PIN, mode=Pin.IN, pull=None)

        self.buttonA = Button(pin=pin_a)
        self.buttonA.press_func(
            self.button_A_callback,
            (pin_a, ))  # Note how function and args are passed

        self.led = Pin(LED, mode=Pin.OUT)

        #configure the battery reading
        #self.vbat = ADC(Pin(BATT_PIN))
        #self.vbat.atten(ADC.ATTN_0DB)
        #self.vbat.width(ADC.WIDTH_12BIT)

        self.tranport_handler = None
        super().__init__(config)
Esempio n. 5
0
    def __init__(self, config) :
        self.config = config
        # TTGO hardware specific
        self.tft = st7789.ST7789(
            SPI(2, baudrate=30000000, polarity=1, phase=1, sck=Pin(18), mosi=Pin(19)),
            135,
            240,
            reset=Pin(23, Pin.OUT),
            cs=Pin(5, Pin.OUT),
            dc=Pin(16, Pin.OUT),
            backlight=Pin(4, Pin.OUT),
            rotation=3)        
        
        self.tft.init()
        self.tft.rotation(1)
        self.tft.fill(0)
        
        pin_a = Pin(BUTTON_A_PIN, mode=Pin.IN, pull=None)
        #pin_b = Pin(BUTTON_B_PIN, mode=Pin.IN, pull=None)
        
        self.buttonA = Button(pin=pin_a)
        
        self.buttonA.press_func(self.button_A_callback, (pin_a,))  # Note how function and args are passed
        
        
        #configure the battery reading
        self.vbat = ADC(Pin(BATT_PIN))
        self.vbat.atten(ADC.ATTN_0DB)
        self.vbat.width(ADC.WIDTH_12BIT)

        self.tranport_handler = None
        
        # Turn off backlit
        self.screen_power = Pin(4, Pin.OUT)
        
        super().__init__(config)
Esempio n. 6
0
 def set_callback(self, button, cb):
     if button == BUTTON_A_PIN:
         self.buttonA = Button(pin=Pin(BUTTON_A_PIN, mode=Pin.IN, pull=None),  
             callback=cb, trigger=Pin.IRQ_FALLING)