Exemplo n.º 1
0
    def __init__(self):
        #Set up second I2C bus
        i2cConfig()
        self.lcd = SH1106LCD()

        #Import startup image from disk.
        self.image_path = os.chdir("Hardware")

        self.lcd.addImage("FirstGear", "shift_1_sized.bmp")
        self.lcd.addImage("SecondGear", "shift_2_sized.bmp")
        self.lcd.addImage("ThirdGear", "shift_3_sized.bmp")
        self.lcd.addImage("FourthGear", "shift_4_sized.bmp")
        self.lcd.addImage("FifthGear", "shift_5_sized.bmp")
        self.lcd.addImage("Reverse", "shift_R_sized.bmp")
        self.lcd.addImage("Neutral", "shift_N_sized.bmp")
        self.lcd.addImage("SubaruLogo", "subie_logo.bmp")
        self.lcd.addImage("WrxLogo", "wrx_logo.bmp")
        self.lcd.displayBufferedImage("SubaruLogo", 0, 0)
        time.sleep(2)
        self.lcd.displayBufferedImage("WrxLogo", 0, 0)
        time.sleep(2)
        self.lcd.clearScreen()
Exemplo n.º 2
0
def main():
    global m_indx
    global h_ip
    global w_ip
    global h_name
    global scr_num
    global alsa_vol
    global alsa_hvol
    global alsa_cvol
    global f_indx
    global fil_sp
    global hp_fil
    global de_emp
    global ph_comp
    global non_os
    global hv_en
    global ok_flag
    global card_num
    global de_ctrl
    global hp_ctrl
    global hv_ctrl
    global non_ctrl
    global ma_ctrl
    global dig_ctrl
    global ph_ctrl
    global mixerCtrl
    global status_M
    global update_M
    global filter_cur
    global filter_mod
    global mute
    global sec_flag
    global bs1
    global bs2
    global bs3
    global bs4
    global bs5
    global irm
    global irok
    global ir1
    global ir3
    global ir4
    global ir5
    global led_off_counter
    LED_FLAG = 0
    led_off_counter = 1
    i2cConfig()
    lcd = SH1106LCD()
    h_ip = network1('eth0')
    w_ip = network1('wlan0')
    lcd.displayStringNumber(h_ip, 0, 0)
    lcd.displayStringNumber(w_ip, 6, 0)
    h_name = "HOST:%s" % socket.gethostname()
    lcd.displayString(h_name, 2, 0)
    lcd.displayString(a_card1, 4, 0)
    time.sleep(5)
    lcd.clearScreen()
    card_num1 = getCardNumber()
    if card_num1 == None:
        print("no card detected")
        lcd.displayString("NO BOSS2", 4, 5)
        lcd.displayStringNumber(h_ip, 0, 0)
        lcd.displayStringNumber(w_ip, 6, 0)
        exit(0)

    time.sleep(0.04)
    init_gpio()
    scr0_ref_count = 0
    card_num = getCardNumber()
    ir = IRModule.IRRemote(callback='DECODE')
    GPIO.add_event_detect(irPin, GPIO.BOTH, callback=ir.pWidth)
    ir.set_callback(remote_callback)
    timer1 = time.time()
    timerButton1 = time.time()
    #    try :
    screenVol()
    getMuteStatus(ma_ctrl)
    mute = status_M
    getMuteStatus(hp_ctrl)
    hp_fil = status_M
    getMuteStatus(hv_ctrl)
    hv_en = status_M
    getMuteStatus(non_ctrl)
    non_os = status_M
    getMuteStatus(ph_ctrl)
    ph_comp = status_M
    getMuteStatus(de_ctrl)
    de_emp = status_M
    getFilterStatus()
    fil_sp = filter_cur
    while 1:
        if led_off_counter == 950:
            LED_FLAG = 1
        elif led_off_counter == 1:
            LED_FLAG = 0
        if led_off_counter > 950:
            led_off_counter = 951
        if LED_FLAG == 1:
            lcd.powerDown()
            LED_FLAG = 2
        elif LED_FLAG == 0:
            lcd.powerUp()
            LED_FLAG = 2
        if scr0_ref_count < 10:
            scr0_ref_count += 1
            time.sleep(0.02)
        else:
            sec_flag = 1
            scr0_ref_count = 0
        if (GPIO.input(sw1) == GPIO.HIGH):
            time.sleep(0.04)
        else:
            time.sleep(0.04)
            bs1 = 1
            led_off_counter = 0
        if (GPIO.input(sw2) == GPIO.HIGH):
            time.sleep(0.04)
        else:
            time.sleep(0.04)
            bs2 = 1
            led_off_counter = 0
        if (GPIO.input(sw3) == GPIO.HIGH):
            time.sleep(0.04)
        else:
            time.sleep(0.04)
            bs3 = 1
            led_off_counter = 0
        if (GPIO.input(sw4) == GPIO.HIGH):
            time.sleep(0.04)
        else:
            time.sleep(0.04)
            bs4 = 1
            led_off_counter = 0
        if (GPIO.input(sw5) == GPIO.HIGH):
            time.sleep(0.04)
        else:
            time.sleep(0.04)
            bs5 = 1
            led_off_counter = 0
        if bs1 == 1 or ir1 == 1:
            time.sleep(0.1)
            bs1 = 0
            ir1 = 0
            if scr_num == 0:
                lcd.clearScreen()
                menuScr()
            elif scr_num == 1:
                screenVol()
            elif scr_num == 2:
                menuScr()
            elif scr_num == 3:
                menuScr()
            elif scr_num == 4:
                if hv_en == 0:
                    hv_en = 1
                    hvScr4()
            elif scr_num == 5:
                if fil_sp == 0:
                    fil_sp = 1
                    spScr5()
            elif scr_num == 6:
                if hp_fil == 0:
                    hp_fil = 1
                    hpScr6()
            elif scr_num == 7:
                if de_emp == 0:
                    de_emp = 1
                    deScr7()
            elif scr_num == 8:
                if non_os == 0:
                    non_os = 1
                    nonScr8()
            elif scr_num == 9:
                if ph_comp == 0:
                    ph_comp = 1
                    phScr9()
            else:
                print(scr_num)

        if irm == 1:
            time.sleep(0.1)
            sec_flag = 1
            irm = 0
            getMuteStatus(ma_ctrl)
            mute = status_M
            if mute == 0:
                update_M = 1
                setMuteStatus(ma_ctrl)
                setMuteStatus(dig_ctrl)
            else:
                update_M = 0
                setMuteStatus(ma_ctrl)
                setMuteStatus(dig_ctrl)

        if bs2 == 1 or irok == 1:
            time.sleep(0.1)
            bs2 = 0
            irm_nflag = 0
            if irok == 1:
                irm_nflag = 1
                irok = 0
            if scr_num == 0 and irm_nflag == 0:
                sec_flag = 1
                getMuteStatus(ma_ctrl)
                mute = status_M
                if mute == 0:
                    update_M = 1
                    setMuteStatus(ma_ctrl)
                    setMuteStatus(dig_ctrl)
                else:
                    update_M = 0
                    setMuteStatus(ma_ctrl)
                    setMuteStatus(dig_ctrl)
            elif scr_num == 1:
                if m_indx == 1:
                    bootScr()
                elif m_indx == 2:
                    hvScr4()
                elif m_indx == 3:
                    filtScr()
                elif m_indx == 4:
                    spScr5()
            elif scr_num == 2:
                menuScr()
            elif scr_num == 3:
                if f_indx == 1:
                    phScr9()
                elif f_indx == 2:
                    hpScr6()
                elif f_indx == 3:
                    deScr7()
                elif f_indx == 4:
                    nonScr8()

            elif scr_num == 4:
                ok_flag = 0
                getMuteStatus(hv_ctrl)
                if status_M != hv_en:
                    update_M = hv_en
                    setMuteStatus(hv_ctrl)
                menuScr()
            elif scr_num == 5:
                ok_flag = 0
                getFilterStatus()
                if filter_cur != fil_sp:
                    filter_mod = fil_sp
                    setFilterStatus()
                menuScr()
            elif scr_num == 6:
                ok_flag = 0
                getMuteStatus(hp_ctrl)
                if status_M != hp_fil:
                    update_M = hp_fil
                    setMuteStatus(hp_ctrl)
                filtScr()
            elif scr_num == 7:
                ok_flag = 0
                getMuteStatus(de_ctrl)
                if status_M != de_emp:
                    update_M = de_emp
                    setMuteStatus(de_ctrl)
                filtScr()
            elif scr_num == 8:
                ok_flag = 0
                getMuteStatus(non_ctrl)
                if status_M != non_os:
                    update_M = non_os
                    setMuteStatus(non_ctrl)
                filtScr()
            elif scr_num == 9:
                ok_flag = 0
                getMuteStatus(ph_ctrl)
                if status_M != ph_comp:
                    update_M = ph_comp
                    setMuteStatus(ph_ctrl)
                filtScr()

        if bs3 == 1 or ir3 == 1:
            time.sleep(0.1)
            bs3 = 0
            ir3 = 0
            if scr_num == 0:
                getVol()
                alsa_hvol = alsa_cvol
                if alsa_hvol < 255 and alsa_hvol >= 240:
                    alsa_hvol += 1
                if alsa_hvol < 240 and alsa_hvol >= 210:
                    alsa_hvol += 3
                if alsa_hvol < 210 and alsa_hvol >= 120:
                    alsa_hvol += 10
                if alsa_hvol < 120 and alsa_hvol >= 0:
                    alsa_hvol += 30
                setVol()
                screenVol()
            elif scr_num == 1:
                if m_indx > 1:
                    m_indx -= 1
                menuScr()
            elif scr_num == 3:
                if f_indx > 1:
                    f_indx -= 1
                filtScr()

        if bs4 == 1 or ir4 == 1:
            time.sleep(0.1)
            bs4 = 0
            ir4 = 0
            if scr_num == 0:
                getVol()
                alsa_hvol = alsa_cvol
                if alsa_hvol <= 255 and alsa_hvol > 240:
                    alsa_hvol -= 1
                if alsa_hvol <= 240 and alsa_hvol > 210:
                    alsa_hvol -= 3
                if alsa_hvol <= 210 and alsa_hvol > 120:
                    alsa_hvol -= 10
                if alsa_hvol <= 120 and alsa_hvol > 0:
                    alsa_hvol -= 30
                setVol()
                screenVol()

            elif scr_num == 1:
                m_indx += 1
                if m_indx > 4:
                    m_indx = 1
                menuScr()
            elif scr_num == 3:
                f_indx += 1
                if f_indx > 4:
                    f_indx = 1
                filtScr()
            elif scr_num == 4:
                if ok_flag == 0:
                    ok_flag = 1
                hvScr4()
            elif scr_num == 5:
                if ok_flag == 0:
                    ok_flag = 1
                spScr5()
            elif scr_num == 6:
                if ok_flag == 0:
                    ok_flag = 1
                hpScr6()

            elif scr_num == 7:
                if ok_flag == 0:
                    ok_flag = 1
                deScr7()
            elif scr_num == 8:
                if ok_flag == 0:
                    ok_flag = 1
                nonScr8()
            elif scr_num == 9:
                if ok_flag == 0:
                    ok_flag = 1
                phScr9()

        if bs5 == 1 or ir5 == 1:
            time.sleep(0.1)
            bs5 = 0
            ir5 = 0
            if scr_num == 0:
                lcd.clearScreen()
                menuScr()
            elif scr_num == 1:
                screenVol()
            elif scr_num == 2:
                menuScr()
            elif scr_num == 3:
                menuScr()
            elif scr_num == 4:
                if hv_en == 1:
                    hv_en = 0
                hvScr4()
            elif scr_num == 5:
                if fil_sp == 1:
                    fil_sp = 0
                spScr5()
            elif scr_num == 6:
                if hp_fil == 1:
                    hp_fil = 0
                hpScr6()
            elif scr_num == 7:
                if de_emp == 1:
                    de_emp = 0
                deScr7()
            elif scr_num == 8:
                if non_os == 1:
                    non_os = 0
                nonScr8()
            elif scr_num == 9:
                if ph_comp == 1:
                    ph_comp = 0
                phScr9()

        if sec_flag == 1:
            if scr_num == 0:
                screenVol()
                sec_flag = 0
        led_off_counter += 1


#    except:
    ir.remove_callback()
    print("exit")
    GPIO.cleanup(irPin)
    GPIO.cleanup(sw1)
    GPIO.cleanup(sw2)
    GPIO.cleanup(sw3)
    GPIO.cleanup(sw3)
    GPIO.cleanup(sw4)
    GPIO.cleanup(sw5)
Exemplo n.º 3
0
filter_mod = 0
bs1 = 0
bs2 = 0
bs3 = 0
bs4 = 0
bs5 = 0
irp = 0
irm = 0
ir1 = 0
irok = 0
ir3 = 0
ir4 = 0
ir5 = 0
led_off_counter = 0

lcd = SH1106LCD()


def remote_callback(code):

    global irp
    global irm
    global ir1
    global irok
    global ir3
    global ir4
    global ir5
    global led_off_counter
    if code == 0xC77807F:
        irp = 1
        led_off_counter = 0