<commit_before>#!/usr/bin/env python

import sys
import os
import curses
import code
import readline
import rlcompleter
import time

sys.path.append('../src')

from Bybop_Discovery import *
import Bybop_Device

BAT_PRINT_X = 5
BAT_PRINT_Y = 2

KEY_PRINT_X = 5
KEY_PRINT_Y = 3

MAV_PRINT_X = 5
MAV_PRINT_Y = 5

GPS_PRINT_X = 5
GPS_PRINT_Y = 7

ALT_PRINT_X = 5
ALT_PRINT_Y = 12

ATT_PRINT_X = 5
ATT_PRINT_Y = 14

HOME_PRINT_X = 5
HOME_PRINT_Y = 19

#RST_HOME_PRINT_X = 5
#RST_HOME_PRINT_Y = 24

HOME_STATE_PRINT_X = 5
HOME_STATE_PRINT_Y = 24

IS_BACK_HOME_IN_PROCESS = True

def log(stdscr, str):
    stdscr.addstr(10, 20, '[DEBUG] : ' + str)

def input_processing(drone, key, stdscr):
    hometype = 2
    if key == 65 or key == curses.KEY_UP: #UP
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'UP')
        #stdscr.refresh()
        drone.up()
    elif key == 66 or key == curses.KEY_DOWN: #DOWN
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'DOWN')
        #stdscr.refresh()
        drone.down()
    elif key == 68 or key == curses.KEY_LEFT: #SIDE LEFT
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'SIDE LEFT')
        #stdscr.refresh()
        drone.side_left()
    elif key == 67 or key == curses.KEY_RIGHT: #SIDE RIGHT
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'SIDE RIGHT')
        #stdscr.refresh()
        drone.side_right()
    elif key == 101 or key == 'e': #EMERGENCY
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'EMERGENCY')
        #stdscr.refresh()
        drone.emergency()
        time.sleep(3)
    elif key == 116 or key == 't': #TAKEOFF
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'TAKE OFF')
        #stdscr.refresh()
        drone.take_off()
    elif key == 32 or key == '  ': #LAND
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'LAND')
        #stdscr.refresh()
        drone.land()
    elif key == 114 or key == 'r': #FORWARD
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'FORWARD')
        #stdscr.refresh()
        drone.forward()
    elif key == 102 or key == 'f': #REAR
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'REAR')
        #stdscr.refresh()
        drone.rear()
    elif key == 100 or key == 'd': #ROLL LEFT
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'ROLL LEFT')
        #stdscr.refresh()
        drone.roll_left()
    elif key == 103 or key == 'g': #ROLL RIGHT
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'ROLL RIGHT')
        #stdscr.refresh()
        drone.roll_right()
    elif key == 109 or key == 'm': #Mav Mode
        cnt = 1
        while drone.get_mav_state(stdscr) is not True:
            if cnt == 3:
                stdscr.clear()
                stdscr.addstr(MAV_PRINT_Y, MAV_PRINT_X, 'MAV Doesnt work :(')
                stdscr.refresh()
                time.sleep(2)
                break
            cnt = cnt +1
            stdscr.clear()
        if(cnt < 3):
            stdscr.clear()
            stdscr.addstr(MAV_PRINT_Y, MAV_PRINT_X, 'MAV WORKS GOOD!!!')
            stdscr.refresh()
            time.sleep(2)
    elif key == 104 or key == 'h': #home
        drone.send_contoller_gps()
        #drone.reset_node()
        hometype = drone.get_test_hometype(stdscr)
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'home type is ' + str(hometype))
        stdscr.refresh()
        time.sleep(1)
    elif key == 97 or key == 'a':
        drone.go_node()
        rtn = 'Processing'
        global IS_BACK_HOME_IN_PROCESS
        while IS_BACK_HOME_IN_PROCESS:
            stdscr.clear()
            rtn += '.'
            stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, rtn)
            stdscr.refresh()
        IS_BACK_HOME_IN_PROCESS = True
    else:
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X,'None : ' + str(key) + ' pressed')
        stdscr.refresh()
        #drone.trim()<commit_msg>[ANKER POINT] GOOD JOB KIDO!<commit_after>#!/usr/bin/env python

import sys
import os
import curses
import code
import readline
import rlcompleter
import time

sys.path.append('../src')

from Bybop_Discovery import *
import Bybop_Device

BAT_PRINT_X = 5
BAT_PRINT_Y = 2

KEY_PRINT_X = 5
KEY_PRINT_Y = 3

MAV_PRINT_X = 5
MAV_PRINT_Y = 5

GPS_PRINT_X = 5
GPS_PRINT_Y = 7

ALT_PRINT_X = 5
ALT_PRINT_Y = 12

ATT_PRINT_X = 5
ATT_PRINT_Y = 14

HOME_PRINT_X = 5
HOME_PRINT_Y = 19

#RST_HOME_PRINT_X = 5
#RST_HOME_PRINT_Y = 24

HOME_STATE_PRINT_X = 5
HOME_STATE_PRINT_Y = 24

IS_BACK_HOME_IN_PROCESS = True

def log(stdscr, str):
    stdscr.addstr(10, 20, '[DEBUG] : ' + str)

def input_processing(drone, key, stdscr):
    hometype = 2
    if key == 65 or key == curses.KEY_UP: #UP
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'UP')
        #stdscr.refresh()
        drone.up()
    elif key == 66 or key == curses.KEY_DOWN: #DOWN
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'DOWN')
        #stdscr.refresh()
        drone.down()
    elif key == 68 or key == curses.KEY_LEFT: #SIDE LEFT
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'SIDE LEFT')
        #stdscr.refresh()
        drone.side_left()
    elif key == 67 or key == curses.KEY_RIGHT: #SIDE RIGHT
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'SIDE RIGHT')
        #stdscr.refresh()
        drone.side_right()
    elif key == 101 or key == 'e': #EMERGENCY
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'EMERGENCY')
        #stdscr.refresh()
        drone.emergency()
        time.sleep(3)
    elif key == 116 or key == 't': #TAKEOFF
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'TAKE OFF')
        #stdscr.refresh()
        drone.take_off()
    elif key == 32 or key == '  ': #LAND
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'LAND')
        #stdscr.refresh()
        drone.land()
    elif key == 114 or key == 'r': #FORWARD
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'FORWARD')
        #stdscr.refresh()
        drone.forward()
    elif key == 102 or key == 'f': #REAR
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'REAR')
        #stdscr.refresh()
        drone.rear()
    elif key == 100 or key == 'd': #ROLL LEFT
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'ROLL LEFT')
        #stdscr.refresh()
        drone.roll_left()
    elif key == 103 or key == 'g': #ROLL RIGHT
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'ROLL RIGHT')
        #stdscr.refresh()
        drone.roll_right()
    elif key == 109 or key == 'm': #Mav Mode
        cnt = 1
        while drone.get_mav_state(stdscr) is not True:
            if cnt == 3:
                stdscr.clear()
                stdscr.addstr(MAV_PRINT_Y, MAV_PRINT_X, 'MAV Doesnt work :(')
                stdscr.refresh()
                time.sleep(2)
                break
            cnt = cnt +1
            stdscr.clear()
        if(cnt < 3):
            stdscr.clear()
            stdscr.addstr(MAV_PRINT_Y, MAV_PRINT_X, 'MAV WORKS GOOD!!!')
            stdscr.refresh()
            time.sleep(2)
    elif key == 104 or key == 'h': #home
        drone.send_contoller_gps()
        #drone.reset_node()
        hometype = drone.get_test_hometype(stdscr)
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, 'home type is ' + str(hometype))
        stdscr.refresh()
        time.sleep(1)
    elif key == 97 or key == 'a':
        drone.go_node()
        rtn = 'Processing...'
        global IS_BACK_HOME_IN_PROCESS
        while IS_BACK_HOME_IN_PROCESS:
            stdscr.clear()
            stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X, rtn)
            stdscr.refresh()
            time.sleep(1)
        IS_BACK_HOME_IN_PROCESS = True
    else:
        stdscr.addstr(KEY_PRINT_Y, KEY_PRINT_X,'None : ' + str(key) + ' pressed')
        stdscr.refresh()
        #drone.trim()
{'fraction_non_alphanumeric': 0.1196039603960396, 'fraction_numerical': 0.01914191419141914, 'mean_word_length': 2.293913043478261, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6681682', 'n_tokens_mistral': 2983, 'n_tokens_neox': 2806, 'n_words': 607}