Esempio n. 1
0
def setup():
    global background
    badge.init()
    ugfx.init()
    ugfx.input_init()
    ugfx.input_attach(ugfx.BTN_SELECT, reboot)
    ugfx.input_attach(ugfx.BTN_START, reboot)
    ugfx.input_attach(ugfx.JOY_DOWN, invert)
    ugfx.input_attach(ugfx.JOY_UP, invert)
    ugfx.input_attach(ugfx.JOY_RIGHT, invert)
    ugfx.input_attach(ugfx.JOY_LEFT, invert)
    ugfx.input_attach(ugfx.BTN_A, invert)
    ugfx.input_attach(ugfx.BTN_B, invert)
    ugfx.set_lut(ugfx.LUT_NORMAL)
    ugfx.clear(background)
    ugfx.flush()
    flip()
Esempio n. 2
0
 def badge_init(self):
     badge.init()
     ugfx.init()
     ugfx.input_init()
     ugfx.input_attach(ugfx.BTN_B, lambda pushed: home()
                       if pushed else False)
     ugfx.input_attach(ugfx.BTN_START, lambda pushed: self.shoot()
                       if pushed else False)
     ugfx.input_attach(ugfx.JOY_UP, lambda pushed: print("JOY_UP")
                       if pushed else False)
     ugfx.input_attach(
         ugfx.JOY_DOWN, lambda pushed: print("JOY_DOWN")
         if pushed else False)
     ugfx.input_attach(
         ugfx.JOY_RIGHT, lambda pushed: self.move(DIRECTION_RIGHT)
         if pushed else False)
     ugfx.input_attach(
         ugfx.JOY_LEFT, lambda pushed: self.move(DIRECTION_LEFT)
         if pushed else False)
def run_game():

    badge.eink_init()
    ugfx.init()
    ugfx.clear(ugfx.WHITE)
    ugfx.flush()

    badge.init()

    ugfx.clear(ugfx.WHITE)

    ugfx.input_init()

    ugfx.input_attach(ugfx.JOY_UP, lambda pressed: up(pressed, this_game))
    ugfx.input_attach(ugfx.JOY_DOWN, lambda pressed: down(pressed, this_game))
    ugfx.input_attach(ugfx.JOY_LEFT, lambda pressed: left(pressed, this_game))
    ugfx.input_attach(ugfx.JOY_RIGHT,
                      lambda pressed: right(pressed, this_game))
    ugfx.input_attach(ugfx.BTN_SELECT,
                      lambda pressed: exit_game(pressed, this_game))

    ugfx.string(50, 50, "Snake Game", "PermanentMarker22", ugfx.BLACK)
    ugfx.string(50, 72, "press SELECT to exit", "Roboto_Regular18", ugfx.BLACK)
    ugfx.flush()
    time.sleep(5)
    ugfx.clear(ugfx.WHITE)
    ugfx.flush()

    snake = Snake(True, Renderer())
    this_game = Game(snake, Border(), [Food.create_random_food(snake)])

    ugfx.flush()

    print("Start Log")

    while True:
        if (this_game.game_state == "FAIL"):
            FailGame(this_game)
        Step(this_game, 5)
Esempio n. 4
0
        self.ugfx.init()
        self.ugfx.input_init()
        for key in self.RANGE_ORDER + [self.ugfx.BTN_START,
                                       self.ugfx.BTN_SELECT]:
            def closure(is_pressed, k=key):
                if is_pressed:
                    self.key_pressed(k)
            self.ugfx.input_attach(key, closure)

    def run(self):
        self.init_input()
        self.display_state()


if MICROPYTHON:
    badge.init()
    Editor(ugfx).run()
    while True:
        time.sleep(0.1)

###########################################################################
# else
###########################################################################

class CharacterInputTest(unittest.TestCase):

    def setUp(self):
        self.c = CharacterInput(mock.Mock(), ascii_range=(0, 128))

    def test_select_range_2(self):
        s, e = self.c.start, self.c.end
def init():
    badge.init()
    ugfx.init()
    easywifi.enable()
    easyrtc.configure()
    clear_screen()