from pc7_keys import * fnop = lambda : None PC_spx, PC_show, PC_clr, PC_init, end, PC_drect, PC_frect, PC_tkey, PC_wnokey = fnop, fnop, fnop, fnop, fnop, fnop, fnop, fnop, fnop PC_sw, PC_sh = 128, 64 PC_hkey, PC_hgkey, need_init, need_end, PC_dirt = 1, 0, 0, 0, 0 d_key = {} def col3_2_rgb(c): return c[2]//8 + c[1]//4*32 + c[0]//8*512 try: import sys try: ########################## # Casio + KhiCAS/Micropy # ########################## if sys.platform == "prizm": import graphic PC_spx = graphic.set_pixel d_key = {K_LEFT:0, K_UP:1, K_DOWN:2, K_RIGHT:3, K_ESC:5} PC_fw, PC_fh, PC_fwn, PC_fwm = 6, 7, 6, 6 PC_show = graphic.show_screen def PC_drect(x1, y1, x2, y2, c): graphic.draw_rectangle(int(x1), int(y1), int(x2), int(y2), c) def PC_frect(x1, y1, x2, y2, c): graphic.draw_filled_rectangle(int(x1), int(y1), int(x2), int(y2), c) def PC_dstr(s, x, y, cf, cb=(255,255,255)): if cb: graphic.draw_string(int(x), int(y), s, cf, cb) else: graphic.draw_string(int(x), int(y), s, cf) need_init = 1 import ion PC_hgkey = 1 def PC_tkey(v): return ion.keydown(d_key[v]) >= 0 def PC_wkey(): key = ion.getkey() return key in d_key.values() and list(d_key.keys())[list(d_key.values()).index(key)] except: #################### # Casio + PythonEx # #################### if sys.implementation._machine == "sh7305 with sh-4a": import gint PC_show = gint.dupdate def PC_spx(x, y, c): gint.dpixel(int(x), int(y), col3_2_rgb(c)) PC_fw, PC_fh, PC_fwn, PC_fwm = 6, 5, 4, 3.5 need_init, PC_dirt = 1, 1 def PC_frect(x, y, w, h, c): gint.drect(int(x), int(y), int(x + w - 1), int(y + h - 1), col3_2_rgb(c)) def PC_dstr(s, x, y, cf, cb=None): if cb: PC_frect(x, y, PC_wstr(s), PC_fh, cb) gint.dtext(int(x), int(y), col3_2_rgb(cf), s) def PC_wkey(): d_key = {K_LEFT:133, K_UP:134, K_DOWN:117, K_RIGHT:118, K_ESC:116} key = gint.getkey().key return key in d_key.values() and list(d_key.keys())[list(d_key.values()).index(key)] except: try: ######### # Casio # ######### import casioplot PC_spx = casioplot.set_pixel PC_fw, PC_fh, PC_fwn, PC_fwm = 6, 5, 4, 3.5 PC_show, PC_clr = casioplot.show_screen, casioplot.clear_screen PC_hkey = 0 def PC_dstr(s, x, y, cf, cb=None): if cb: PC_frect(x, y, PC_wstr(s), PC_fh, cb) casioplot.draw_string(int(x), int(y), s, cf, "small") except Exception as e: print(e) pass def PC_wstr(s): try: i = int(s) cw = PC_fwn except: cw = len(s) <= 1 and PC_fw or PC_fwm return cw * len(s) if PC_frect == fnop: def PC_frect(x, y, w, h, c): for dy in range(h): for dx in range(w): PC_spx(int(x) + dx, int(y) + dy, c) if PC_drect == fnop: def PC_drect(x, y, w, h, c): for dy in (0, h - 1): PC_frect(x, y + dy, w, 1, c) for dx in (0, w - 1): PC_frect(x + dx, y, 1, h, c) if PC_clr == fnop: def PC_clr(): PC_frect(0, 0, PC_sw, PC_sh, (255, 255, 255)) if need_init: PC_init = PC_clr if need_end: end = pause if PC_tkey != fnop: def PC_gkey(): for k in d_key: if PC_tkey(k): return k return None def PC_tanykey(): return PC_gkey() != None def PC_wnokey(): while PC_tanykey(): pass