Пример #1
0
 def display(self,msg,menu1,menu2,menu3):
     if self.busy: return False
     self.busy=True
     with self.canvas as draw:
         draw.rectangle((0, 0, self.device.width-1, self.device.height-1), outline=0, fill=0)
         if UI.USE_ALSA_MIXER:
             s1 = "%s | Vol: %d%%" % (UI.Mode(), UI.SoundVolume())
         else:
             s1 = "Mode: %s" % (gv.sample_mode)
         s2=msg
         if s2 == '':
             if UI.Voice()>1: s2=str(UI.Voice())+":"
             if UI.Presetlist()!=[]: s2 += UI.Presetlist()[UI.getindex(UI.Preset(),UI.Presetlist())][1]
         #s3 = "Scale:%s" % (UI.Scalename()[UI.Scale()])
         s3 = "Scale:%s | Chord:%s" % (UI.Scalename()[UI.Scale()], UI.Chordname()[UI.Chord()])
         # Change menu lines if necessary
         if menu1 != '':
             self.s4=menu1
             self.s5=menu2
             self.s6=menu3
         s6=self.s6 if self.s6!='' else UI.IP()
         draw.text((self.x, self.top), s1, font=self.font, fill=255)
         draw.rectangle((self.x, self.top+11,self.device.width, 21), outline=255, fill=255)
         draw.text((self.x+2, self.top+12), s2, font=self.font,fill=0)
         draw.text((self.x, self.top+24), s3, font=self.font, fill=255)
         draw.text((self.x, self.top+32), self.s4, font=self.font, fill=255)
         draw.text((self.x, self.top+40), self.s5, font=self.font, fill=255)
         draw.text((self.x, self.top+48), s6, font=self.font, fill=255)
     self.busy=False
     return True
Пример #2
0
def display(msg='', menu1='', menu2='', menu3='', *z):
    global busy, prevs
    if busy: return False
    busy = True
    # ---   default behaviour for first two lines
    s = [''] * 4
    vol = " %d%%" % UI.SoundVolume() if UI.USE_ALSA_MIXER else ""
    s[0] = "%s%s %s%s" % (UI.Scalename()[UI.Scale()],
                          UI.Chordname()[UI.Chord()], UI.Mode(), vol)
    if UI.Voice() > 1: s[1] = str(UI.Voice()) + ":"
    if UI.Presetlist() != []:
        s[1] += UI.Presetlist()[UI.getindex(UI.Preset(), UI.Presetlist())][1]

    # ---   menu control, fit the 3 menu lines into two/four display lines
    if I2C_DISPLAY_LCD_LINES == 2:
        if menu1 != '':
            if menu3 == '':
                s[0] = menu1
                s[1] = menu2
            else:
                s[0] = menu1 + ":" + menu2
                if len(
                        s[0]
                ) > I2C_DISPLAY_LCD_WIDTH:  # make sure the most significant part is displayed
                    s[0] = menu1[:I2C_DISPLAY_LCD_WIDTH - 1 -
                                 len(menu2)] + ":" + menu2
                s[1] = menu3
            if msg != '':
                s[1] = msg  # a message is important, so override s[1]
    else:
        if menu1 != '':
            if menu3 == '':
                s[2] = menu1
                s[3] = menu2
            else:
                s[1] = menu1
                s[2] = menu2
                s[3] = menu3
        else:
            s[2] = prevs[2]
            s[3] = prevs[3]

    # ---   display the result
    for i in xrange(I2C_DISPLAY_LCD_LINES):
        if not s[i] == prevs[i]:
            lcd_string(i, s[i])
            prevs[i] = s[i]
    busy = False
    return True
Пример #3
0
 def display(self, msg='', menu1='', menu2='', menu3='', *z):
     if self.busy: return False
     self.busy = True
     # ---   default behaviour
     s1 = ""
     s2 = msg
     if msg == '':
         if UI.Voice() > 1: s2 = str(UI.Voice()) + ":"
         if UI.Presetlist() != []:
             s2 += UI.Presetlist()[UI.getindex(UI.Preset(),
                                               UI.Presetlist())][1]
     if menu1 == '':  # The menu will also override s2
         vol = " %d%%" % UI.SoundVolume() if UI.USE_ALSA_MIXER else ""
         s1 = "%s%s %s%s" % (UI.Scalename()[UI.Scale()],
                             UI.Chordname()[UI.Chord()], UI.Mode(), vol)
     # ---   menu control, fit the 3 menu lines into two display lines
     else:
         if menu3 == '':
             s1 = menu1
             s2 = menu2
         else:
             s1 = menu1 + ":" + menu2
             if len(
                     s1
             ) > 16:  # make sure the most significant part is displayed
                 s1 = menu1[:15 - len(menu2)] + ":" + menu2
             s2 = menu3
     if not (s1 == self.prevs1 and s2 == self.prevs2):
         self.prevs1 = s1
         self.prevs2 = s2
         self.cmd(0x02)  # go home first
         self.displayline(s1)
         self.cmd(0xC0)  # next line
         self.displayline(s2)
     self.busy = False
     return True