(self, enable=False, mapSize="(800,1500,0,0,0,0)",
                   mapPath=".", iconPath = "./", roomOutline=True,
                   enableMapWithText=True,
                   fillColor="lawngreen", 
                   outlineColor=(64,64,64,255),
                   outlineWidth=1,
                   home_icon_file="home.png",
                   roomba_icon_file="roomba.png",
                   roomba_error_file="roombaerror.png",
                   roomba_cancelled_file="roombacancelled.png",
                   roomba_battery_file="roomba-charge.png",
                   bin_full_file="binfull.png",
                   tank_low_file="tanklow.png",
                   floorplan = None,
                   roomba_size=(50,50), draw_edges = 30, auto_rotate=False)
return False
Enable live map drawing. mapSize is x,y size, x,y offset of docking
        station ((0,0) is the center of the image) final value is map rotation
        (in case map is not straight up/down). These values depend on the
        size/shape of the area Roomba covers. Offset depends on where you place
        the docking station. This will need some experimentation to get right.
        You can supply 32x32 icons for dock and roomba etc. If the files don't
        exist, crude representations are made. If you specify home_icon_file as
        None, then no dock is drawn. Draw edges attempts to draw straight lines
        around the final (not live) map, and Auto_rotate (on/off) attempts to
        line the map up vertically. These only work if you have openCV
        installed. otherwise a PIL version is used, which is not as good (but
        less CPU intensive). roomOutline enables the previous largest saved
        outline to be overlayed on the map (so you can see where cleaning was
        missed). This is on by default, but the alignment doesn't work so well,
        so you can turn it off.
        Returns map enabled True/False
Enable live map drawing. mapSize is x,y size, x,y offset of docking
        station ((0,0) is the center of the image) final value is map rotation
        (in case map is not straight up/down). These values depend on the
        size/shape of the area Roomba covers. Offset depends on where you place
        the docking station. This will need some experimentation to get right.
        You can supply 32x32 icons for dock and roomba etc. If the files don't
        exist, crude representations are made. If you specify home_icon_file as
        None, then no dock is drawn. Draw edges attempts to draw straight lines
        around the final (not live) map, and Auto_rotate (on/off) attempts to
        line the map up vertically. These only work if you have openCV
        installed. otherwise a PIL version is used, which is not as good (but
        less CPU intensive). roomOutline enables the previous largest saved
        outline to be overlayed on the map (so you can see where cleaning was
        missed). This is on by default, but the alignment doesn't work so well,
        so you can turn it off.
        Returns map enabled True/False
Enable live map drawing . mapSize is x y size x y offset of docking station (( 0 0 ) is the center of the image ) final value is map rotation ( in case map is not straight up / down ) . These values depend on the size / shape of the area Roomba covers . Offset depends on where you place the docking station . This will need some experimentation to get right . You can supply 32x32 icons for dock and roomba etc . If the files don t exist crude representations are made . If you specify home_icon_file as None then no dock is drawn . Draw edges attempts to draw straight lines around the final ( not live ) map and Auto_rotate ( on / off ) attempts to line the map up vertically . These only work if you have openCV installed . otherwise a PIL version is used which is not as good ( but less CPU intensive ) . roomOutline enables the previous largest saved outline to be overlayed on the map ( so you can see where cleaning was missed ) . This is on by default but the alignment doesn t work so well so you can turn it off . Returns map enabled True / False
def _enable_map(self, enable=False, mapSize="(800,1500,0,0,0,0)",
                   mapPath=".", iconPath = "./", roomOutline=True,
                   enableMapWithText=True,
                   fillColor="lawngreen", 
                   outlineColor=(64,64,64,255),
                   outlineWidth=1,
                   home_icon_file="home.png",
                   roomba_icon_file="roomba.png",
                   roomba_error_file="roombaerror.png",
                   roomba_cancelled_file="roombacancelled.png",
                   roomba_battery_file="roomba-charge.png",
                   bin_full_file="binfull.png",
                   tank_low_file="tanklow.png",
                   floorplan = None,
                   roomba_size=(50,50), draw_edges = 30, auto_rotate=False):
        '''
        Enable live map drawing. mapSize is x,y size, x,y offset of docking
        station ((0,0) is the center of the image) final value is map rotation
        (in case map is not straight up/down). These values depend on the
        size/shape of the area Roomba covers. Offset depends on where you place
        the docking station. This will need some experimentation to get right.
        You can supply 32x32 icons for dock and roomba etc. If the files don't
        exist, crude representations are made. If you specify home_icon_file as
        None, then no dock is drawn. Draw edges attempts to draw straight lines
        around the final (not live) map, and Auto_rotate (on/off) attempts to
        line the map up vertically. These only work if you have openCV
        installed. otherwise a PIL version is used, which is not as good (but
        less CPU intensive). roomOutline enables the previous largest saved
        outline to be overlayed on the map (so you can see where cleaning was
        missed). This is on by default, but the alignment doesn't work so well,
        so you can turn it off.
        Returns map enabled True/False
        '''
        if not HAVE_PIL: #can't draw a map without PIL!
            return False

        if Image.__version__ < "4.1.1":
            print("WARNING: PIL version is %s, this is not the latest! you "
                  "can get bad memory leaks with old versions of PIL"
                  % Image.__version__)
            print("run: 'pip install --upgrade pillow' to fix this")
        
        if enable:
            self.log.info("MAP: Maps Enabled")
            if isinstance(mapSize, str):
                mapSize = literal_eval(mapSize)
            self.mapSize = mapSize
            if len(self.mapSize) < 6:
                self.log.error("mapSize is required, and is of the form "
                               "(800,1500,0,0,0,0) - (x,y size, x,y dock loc,"
                               "theta1, theta2), map,roomba roatation")
                self.drawmap = False
                return False
            if self.roombas_config.get(self.address):
                self.roombas_config[self.address]['mapsize'] = self.mapSize
            self.angle = self.mapSize[4]
            self.roomba_angle = self.mapSize[5]
            if len(self.mapSize) >=7:
                self.invert_x = self.mapSize[6]
            if len(self.mapSize) >=8:
                self.invert_y = self.mapSize[7]
            self.mapPath = mapPath
            # get a font
            if self.fnt is None:
                try:
                    self.fnt = ImageFont.truetype('FreeMono.ttf', 40)
                except IOError as e:
                    self.log.warning("error loading font: %s, loading default font".format(e))
                    self.fnt = ImageFont.load_default()
            #load icons
            self.icons.set_font(self.fnt)
            self.icons.set_angle(self.angle)

            self.icons.load_icon_file('roomba', os.path.join(iconPath, roomba_icon_file), roomba_size)
            self.icons.load_icon_file('stuck', os.path.join(iconPath, roomba_error_file), roomba_size)
            self.icons.load_icon_file('cancelled', os.path.join(iconPath, roomba_cancelled_file), roomba_size)
            self.icons.load_icon_file('battery', os.path.join(iconPath, roomba_battery_file), roomba_size)
            self.icons.load_icon_file('bin full', os.path.join(iconPath, bin_full_file), roomba_size)
            self.icons.load_icon_file('tank low', os.path.join(iconPath, tank_low_file), roomba_size)
            if home_icon_file is not None:
                self.icons.load_icon_file('home', os.path.join(iconPath, home_icon_file), (32,32))  #make home base size adjustable?
            self.draw_edges = draw_edges // 10000
            self.auto_rotate = auto_rotate
            if not roomOutline:
                self.log.info("MAP: Not drawing Room Outline")
            self.roomOutline = roomOutline

            self.enableMapWithText = enableMapWithText
            self.fillColor = self.get_colour(fillColor, default=(124, 252, 0, 255))
            self.outlineColor = self.get_colour(outlineColor)
            self.outlineWidth = outlineWidth
            self.initialise_map(roomba_size)
            if floorplan:
                if isinstance(floorplan, str):
                    floorplan = literal_eval(floorplan)
                if floorplan and len(floorplan) != 6:
                    self.log.error('floorplan is of the form '
                                   '("res/first_floor.jpg",0,0,1.0,0) - (filename, x, y, scale, roatation, transparency)')
                else:
                    self.floorplan_size = floorplan
                    self.load_floorplan(floorplan[0], new_center=(floorplan[1], floorplan[2]), scale=floorplan[3], angle=floorplan[4], transparency=floorplan[5])
            self.drawmap = enable
            return True
        return False
def _enable_map ( self , enable = False , mapSize = "(800,1500,0,0,0,0)" , mapPath = "." , iconPath = "./" , roomOutline = True , enableMapWithText = True , fillColor = "lawngreen" , outlineColor = ( 64 , 64 , 64 , 255 ) , outlineWidth = 1 , home_icon_file = "home.png" , roomba_icon_file = "roomba.png" , roomba_error_file = "roombaerror.png" , roomba_cancelled_file = "roombacancelled.png" , roomba_battery_file = "roomba-charge.png" , bin_full_file = "binfull.png" , tank_low_file = "tanklow.png" , floorplan = None , roomba_size = ( 50 , 50 ) , draw_edges = 30 , auto_rotate = False ) : if not HAVE_PIL : #can't draw a map without PIL! return False if Image . __version__ < "4.1.1" : print ( "WARNING: PIL version is %s, this is not the latest! you " "can get bad memory leaks with old versions of PIL" % Image . __version__ ) print ( "run: 'pip install --upgrade pillow' to fix this" ) if enable : self . log . info ( "MAP: Maps Enabled" ) if isinstance ( mapSize , str ) : mapSize = literal_eval ( mapSize ) self . mapSize = mapSize if len ( self . mapSize ) < 6 : self . log . error ( "mapSize is required, and is of the form " "(800,1500,0,0,0,0) - (x,y size, x,y dock loc," "theta1, theta2), map,roomba roatation" ) self . drawmap = False return False if self . roombas_config . get ( self . address ) : self . roombas_config [ self . address ] [ 'mapsize' ] = self . mapSize self . angle = self . mapSize [ 4 ] self . roomba_angle = self . mapSize [ 5 ] if len ( self . mapSize ) >= 7 : self . invert_x = self . mapSize [ 6 ] if len ( self . mapSize ) >= 8 : self . invert_y = self . mapSize [ 7 ] self . mapPath = mapPath # get a font if self . fnt is None : try : self . fnt = ImageFont . truetype ( 'FreeMono.ttf' , 40 ) except IOError as e : self . log . warning ( "error loading font: %s, loading default font" . format ( e ) ) self . fnt = ImageFont . load_default ( ) #load icons self . icons . set_font ( self . fnt ) self . icons . set_angle ( self . angle ) self . icons . load_icon_file ( 'roomba' , os . path . join ( iconPath , roomba_icon_file ) , roomba_size ) self . icons . load_icon_file ( 'stuck' , os . path . join ( iconPath , roomba_error_file ) , roomba_size ) self . icons . load_icon_file ( 'cancelled' , os . path . join ( iconPath , roomba_cancelled_file ) , roomba_size ) self . icons . load_icon_file ( 'battery' , os . path . join ( iconPath , roomba_battery_file ) , roomba_size ) self . icons . load_icon_file ( 'bin full' , os . path . join ( iconPath , bin_full_file ) , roomba_size ) self . icons . load_icon_file ( 'tank low' , os . path . join ( iconPath , tank_low_file ) , roomba_size ) if home_icon_file is not None : self . icons . load_icon_file ( 'home' , os . path . join ( iconPath , home_icon_file ) , ( 32 , 32 ) ) #make home base size adjustable? self . draw_edges = draw_edges // 10000 self . auto_rotate = auto_rotate if not roomOutline : self . log . info ( "MAP: Not drawing Room Outline" ) self . roomOutline = roomOutline self . enableMapWithText = enableMapWithText self . fillColor = self . get_colour ( fillColor , default = ( 124 , 252 , 0 , 255 ) ) self . outlineColor = self . get_colour ( outlineColor ) self . outlineWidth = outlineWidth self . initialise_map ( roomba_size ) if floorplan : if isinstance ( floorplan , str ) : floorplan = literal_eval ( floorplan ) if floorplan and len ( floorplan ) != 6 : self . log . error ( 'floorplan is of the form ' '("res/first_floor.jpg",0,0,1.0,0) - (filename, x, y, scale, roatation, transparency)' ) else : self . floorplan_size = floorplan self . load_floorplan ( floorplan [ 0 ] , new_center = ( floorplan [ 1 ] , floorplan [ 2 ] ) , scale = floorplan [ 3 ] , angle = floorplan [ 4 ] , transparency = floorplan [ 5 ] ) self . drawmap = enable return True return False