def __init__(self, config, state={}): self._render_cbs = [] self._config = config self._canvas = None self._lock = Lock() self._width, self._height, \ face_pos, name_pos, status_pos = setup_display_specifics(config) self._state = State(state={ 'channel': LabeledValue(color=BLACK, label='CH', value='00', position=(0, 0), label_font=fonts.Bold, text_font=fonts.Medium), 'aps': LabeledValue(color=BLACK, label='APS', value='0 (00)', position=(30, 0), label_font=fonts.Bold, text_font=fonts.Medium), # 'epoch': LabeledValue(color=BLACK, label='E', value='0000', position=(145, 0), label_font=fonts.Bold, # text_font=fonts.Medium), 'uptime': LabeledValue(color=BLACK, label='UP', value='00:00:00', position=(self._width - 65, 0), label_font=fonts.Bold, text_font=fonts.Medium), # 'square': Rect([1, 11, 124, 111]), 'line1': Line([0, int(self._height * .12), self._width, int(self._height * .12)], color=BLACK), 'line2': Line( [0, self._height - int(self._height * .12), self._width, self._height - int(self._height * .12)], color=BLACK), # 'histogram': Histogram([4, 94], color = BLACK), 'face': Text(value=faces.SLEEP, position=face_pos, color=BLACK, font=fonts.Huge), 'friend_face': Text(value=None, position=(0, 90), font=fonts.Bold, color=BLACK), 'friend_name': Text(value=None, position=(40, 93), font=fonts.BoldSmall, color=BLACK), 'name': Text(value='%s>' % 'pwnagotchi', position=name_pos, color=BLACK, font=fonts.Bold), # 'face2': Bitmap( '/root/pwnagotchi/data/images/face_happy.bmp', (0, 20)), 'status': Text(value=voice.default(), position=status_pos, color=BLACK, font=fonts.Medium), 'shakes': LabeledValue(label='PWND ', value='0 (00)', color=BLACK, position=(0, self._height - int(self._height * .12) + 1), label_font=fonts.Bold, text_font=fonts.Medium), 'mode': Text(value='AUTO', position=(self._width - 25, self._height - int(self._height * .12) + 1), font=fonts.Bold, color=BLACK), }) for key, value in state.items(): self._state.set(key, value) _thread.start_new_thread(self._refresh_handler, ())
def __init__(self, config, impl, state=None): global ROOT # setup faces from the configuration in case the user customized them faces.load_from_config(config['ui']['faces']) self._agent = None self._render_cbs = [] self._config = config self._canvas = None self._frozen = False self._lock = Lock() self._voice = Voice(lang=config['main']['lang']) self._implementation = impl self._layout = impl.layout() self._width = self._layout['width'] self._height = self._layout['height'] self._state = State(state={ 'channel': LabeledValue(color=BLACK, label='CH', value='00', position=self._layout['channel'], label_font=fonts.Bold, text_font=fonts.Medium), 'aps': LabeledValue(color=BLACK, label='APS', value='0 (00)', position=self._layout['aps'], label_font=fonts.Bold, text_font=fonts.Medium), 'uptime': LabeledValue(color=BLACK, label='UP', value='00:00:00', position=self._layout['uptime'], label_font=fonts.Bold, text_font=fonts.Medium), 'line1': Line(self._layout['line1'], color=BLACK), 'line2': Line(self._layout['line2'], color=BLACK), 'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.Huge), 'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.Bold, color=BLACK), 'friend_name': Text(value=None, position=self._layout['friend_name'], font=fonts.BoldSmall, color=BLACK), 'name': Text(value='%s>' % 'pwnagotchi', position=self._layout['name'], color=BLACK, font=fonts.Bold), 'status': Text(value=self._voice.default(), position=self._layout['status']['pos'], color=BLACK, font=self._layout['status']['font'], wrap=True, # the current maximum number of characters per line, assuming each character is 6 pixels wide max_length=self._layout['status']['max']), 'shakes': LabeledValue(label='PWND ', value='0 (00)', color=BLACK, position=self._layout['shakes'], label_font=fonts.Bold, text_font=fonts.Medium), 'mode': Text(value='AUTO', position=self._layout['mode'], font=fonts.Bold, color=BLACK), }) if state: for key, value in state.items(): self._state.set(key, value) plugins.on('ui_setup', self) if config['ui']['fps'] > 0.0: _thread.start_new_thread(self._refresh_handler, ()) self._ignore_changes = () else: logging.warning("ui.fps is 0, the display will only update for major changes") self._ignore_changes = ('uptime', 'name') ROOT = self
def __init__(self, config, state={}): self._render_cbs = [] self._config = config self._canvas = None self._lock = Lock() self._voice = Voice(lang=config['main']['lang']) self._width, self._height, \ face_pos, name_pos, status_pos = setup_display_specifics(config) self._state = State( state={ 'channel': LabeledValue(color=BLACK, label='CH', value='00', position=(0, 0), label_font=fonts.Bold, text_font=fonts.Medium), 'aps': LabeledValue(color=BLACK, label='APS', value='0 (00)', position=(30, 0), label_font=fonts.Bold, text_font=fonts.Medium), # 'epoch': LabeledValue(color=BLACK, label='E', value='0000', position=(145, 0), label_font=fonts.Bold, # text_font=fonts.Medium), 'uptime': LabeledValue(color=BLACK, label='UP', value='00:00:00', position=(self._width - 65, 0), label_font=fonts.Bold, text_font=fonts.Medium), 'line1': Line([ 0, int(self._height * .12), self._width, int(self._height * .12) ], color=BLACK), 'line2': Line([ 0, self._height - int(self._height * .12), self._width, self._height - int(self._height * .12) ], color=BLACK), 'face': Text(value=faces.SLEEP, position=face_pos, color=BLACK, font=fonts.Huge), 'friend_face': Text( value=None, position=(0, 90), font=fonts.Bold, color=BLACK), 'friend_name': Text(value=None, position=(40, 93), font=fonts.BoldSmall, color=BLACK), 'name': Text(value='%s>' % 'pwnagotchi', position=name_pos, color=BLACK, font=fonts.Bold), 'status': Text( value=self._voice.default(), position=status_pos, color=BLACK, font=fonts.Medium, wrap=True, # the current maximum number of characters per line, assuming each character is 6 pixels wide max_length=(self._width - status_pos[0]) // 6), 'shakes': LabeledValue(label='PWND ', value='0 (00)', color=BLACK, position=(0, self._height - int(self._height * .12) + 1), label_font=fonts.Bold, text_font=fonts.Medium), 'mode': Text(value='AUTO', position=(self._width - 25, self._height - int(self._height * .12) + 1), font=fonts.Bold, color=BLACK), }) for key, value in state.items(): self._state.set(key, value) plugins.on('ui_setup', self) if config['ui']['fps'] > 0.0: _thread.start_new_thread(self._refresh_handler, ()) self._ignore_changes = () else: logging.warning( "ui.fps is 0, the display will only update for major changes") self._ignore_changes = ('uptime', 'name')