def OptionSelBox(Canvas, PrevOption, CurOption, CurIndex, PrevIndex): draw = ImageDraw.Draw(Canvas) #draw rectangle over Current option draw.rectangle((CSM.Location[0], CSM.Location[1] + CurIndex * 10 + 10, CSM.Location[0] + CSM.Size[0], CSM.Location[1] + (CurIndex * 10) + 20), fill = "purple") draw.text((CSM.Location[0], CSM.Location[1] + CurIndex * 10 + 10),Array[CurIndex][0], fill = "orange") if(len(Array) != 1): #Erase rectangle over last option and repaste text draw.rectangle((CSM.Location[0], CSM.Location[1] + PrevIndex * 10 + 10, CSM.Location[0] + CSM.Size[0], CSM.Location[1] + (PrevIndex * 10) + 20), fill = "white") draw.text((CSM.Location[0], CSM.Location[1] + PrevIndex * 10 + 10), Array[PrevIndex][0], fill = "black") device.display(Canvas)
def CloseContextMenu(): print("Closed CSM") global ButtonSel global OpContext OpContext = () ButtonSel = False DrawScreen(CSM.Canvas, CSM.Screen, CSM.Arr, len(CSM.Arr)) DrawDevBar(Canvas) CheckBatt(Canvas) DisableClick() device.display(Canvas)
def Draw(Self): #Draw Rectangle at Location draw = ImageDraw.Draw(Self.Canvas) draw.rectangle((Self.Location, Self.Location[0] + Self.Size[0], Self.Location[1] + Self.Size[1]), fill = Self.BackgroundColor) OptionInteger = 10 draw.text((Self.Location[0], Self.Location[1]), Self.Title, fill = "black") for Option in Self.Options: draw.text((Self.Location[0], Self.Location[1] + OptionInteger), Option[0], fill = "black") OptionInteger += 10 del draw device.display(Self.Canvas)
def Setup(): DrawScreen(Canvas, CameraApp) device.display(Canvas) global Trackball GPIO.add_event_detect(Trackball[0],GPIO.FALLING) GPIO.add_event_detect(Trackball[1],GPIO.FALLING) GPIO.add_event_detect(Trackball[2],GPIO.FALLING) GPIO.add_event_detect(Trackball[3],GPIO.FALLING) GPIO.add_event_detect(SW,GPIO.RISING) GPIO.add_event_callback(SW, clickCallback) GPIO.add_event_callback(Trackball[0], upCallback) GPIO.add_event_callback(Trackball[2], downCallback)
def Setup(): checkScreen(Context) DrawDevBar(Canvas) CheckBatt(Canvas) device.display(Canvas) global Trackball GPIO.add_event_detect(Trackball[0], GPIO.FALLING) GPIO.add_event_detect(Trackball[1], GPIO.FALLING) GPIO.add_event_detect(Trackball[2], GPIO.FALLING) GPIO.add_event_detect(Trackball[3], GPIO.FALLING) GPIO.add_event_detect(SW, GPIO.RISING) GPIO.add_event_callback(SW, clickCallback) GPIO.add_event_callback(Trackball[0], upCallback) GPIO.add_event_callback(Trackball[2], downCallback)
def takePic(Canvas): stream = io.BytesIO() with picamera.PiCamera() as camera: time.sleep(2) camera.capture(stream, format='jpeg') stream.seek(0) img = Image.open(stream) #Create Image Destination destination = "FramesPics/" + datetime.today().isoformat() img.save(destination, "JPEG") img = img.resize(PicWindowSize) img = img.convert("RGBA") Canvas.paste(img, (0,0), img) device.display(Canvas)
def SelectionBox(Canvas, PrevImage, CurImage): draw = ImageDraw.Draw(Canvas) #Erase the Selection Box around the old image draw.rectangle(PrevImage[3], fill="white") #Repaste the old image tmpPrev = Image.open(PrevImage[0]) tmpPrev = tmpPrev.resize(PrevImage[1]) tmpPrev = tmpPrev.convert("RGBA") tmpPrev.putalpha(255) Canvas.paste(tmpPrev, PrevImage[2], tmpPrev) #Draw Box Around New Image draw.rectangle(CurImage[3], fill="purple") #Paste new Image on top of selection box tmpCur = Image.open(CurImage[0]) tmpCur = tmpCur.resize(CurImage[1]) tmpCur = tmpCur.convert("RGBA") tmpCur.putalpha(255) Canvas.paste(tmpCur, CurImage[2], tmpCur) device.display(Canvas)
def DrawScreen(Canvas, Screen): global TOPINDEX global Array Array = CameraAppSel TOPINDEX = len(CameraAppSel) draw = ImageDraw.Draw(Canvas) #Draw Image 'Canvas' for imageObject in Screen: #create temp image and open the file tmpimg = Image.open(imageObject[0]) #resize image tmpimg = tmpimg.resize(imageObject[1]) #convert image to RGBA if it wasnt already tmpimg = tmpimg.convert("RGBA") #paste the image on the splash with mask of the image Canvas.paste(tmpimg, imageObject[2], tmpimg) draw.rectangle(ToolBarLine, fill = "black") x = 1 device.display(Canvas)
def DrawScreen(Canvas, Screen, Arr, TOPindex): draw = ImageDraw.Draw(Canvas) draw.rectangle((0, 23, 128, 128), fill="white") del draw global Array global TOPINDEX global ScreenContext ScreenContext = Screen ScreenSelectContext = Arr TOPINDEX = TOPindex Array = Arr #Draw Image 'Canvas' for imageObject in Screen: #create temp image and open the file tmpimg = Image.open(imageObject[0]) #resize image tmpimg = tmpimg.resize(imageObject[1]) #convert image to RGBA if it wasnt already tmpimg = tmpimg.convert("RGBA") #paste the image on the splash with mask of the image Canvas.paste(tmpimg, imageObject[2], tmpimg) device.display(Canvas) print(Context)
def Run(): DrawSplashScreen(Canvas) DrawDevBar(Canvas) CheckBatt(Canvas) device.display(Canvas)