예제 #1
0
    def __rpm_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(705, 278 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(305, 225), bimpy.Condition.Once)

        bimpy.begin("RPM",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "RPM")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(25, 0)
        bimpy.text(str(int(self.data.rpm)).rjust(4, "0"))
        bimpy.pop_font()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.same_line(175, 0)
        bimpy.text("RPM")
        bimpy.pop_font()

        self.rpm_datas.append(self.data.rpm)
        self.rpm_datas.pop(0)

        self.rpm_datas.reverse()
        bimpy.plot_lines("", self.rpm_datas, graph_size=bimpy.Vec2(288, 112))
        self.rpm_datas.reverse()
        bimpy.end()
예제 #2
0
    def visualize(self):
        bimpy.begin(type(self).__name__ + " - " + str(id(self)), bimpy.Bool(True))
        bimpy.input_text("Text", self.__state["text"], 256)

        button_pressed = bimpy.button("Plot", bimpy.Vec2(40, 20))

        if button_pressed or self.__state["toggle"]:
            if button_pressed:
                self.__state["toggle"] ^= True
            if len(self.__state["text"].value) > 0:
                bimpy.plot_lines("Graph", self.encode(self.__state["text"].value.encode()))
        bimpy.end()
예제 #3
0
파일: io.py 프로젝트: gfannes/subsoil
def show_io_plot(ui_input, model):
    if (not model.simulator):
        return
    bimpy.slider_float("Input", ui_input, *util.mm)

    outputs = model.compute_outputs(util.x_ary())
    bimpy.plot_lines("", outputs, 0, "", -1.0, 1.0, bimpy.Vec2(0,100))

    bimpy.same_line()

    output = bimpy.Float(model.compute_output(ui_input.value))
    bimpy.v_slider_float("Output", bimpy.Vec2(40,100), output, -1.0, 1.0)
예제 #4
0
    def __heart_rate_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(705, 5 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(305, 225), bimpy.Condition.Once)

        bimpy.begin("Heart Rate",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Heart Rate")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.text("")

        bimpy.same_line(30, -1)

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text(str(int(self.data.heart_rate)).rjust(3, "0"))
        bimpy.pop_font()

        bimpy.same_line(140, 20)

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("BPM")
        bimpy.pop_font()

        if (time.time() -
                self.heart_rate_start_monitor) >= (self.data.heart_rate / 60):
            self.heart_rate_data.append(-0.7)
            self.heart_rate_data.append(1)
            self.heart_rate_start_monitor = time.time()
            self.heart_rate_data.pop(0)
        else:
            self.heart_rate_data.append(0)

        self.heart_rate_data.pop(0)

        self.heart_rate_data.reverse()
        bimpy.plot_lines("",
                         self.heart_rate_data,
                         graph_size=bimpy.Vec2(288, 112),
                         scale_min=-1.0,
                         scale_max=1.3)
        self.heart_rate_data.reverse()

        bimpy.end()
예제 #5
0
    def __power_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(355, 278 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(345, 225), bimpy.Condition.Once)

        bimpy.begin("Power",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Power")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(25, 0)
        bimpy.text("{:.2f}".format(self.data.power).rjust(6, "0"))
        bimpy.pop_font()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.same_line(212, 0)
        bimpy.text("Watts")
        bimpy.pop_font()

        self.power_datas.append(self.data.power)
        self.power_datas.pop(0)

        self.power_datas.reverse()
        bimpy.plot_lines("",
                         self.power_datas,
                         graph_size=bimpy.Vec2(329, 112),
                         scale_min=-1.0,
                         scale_max=500.0)
        self.power_datas.reverse()

        bimpy.end()
예제 #6
0
파일: widgets.py 프로젝트: zakx/bimpy
            bimpy.text("Some text")
            bimpy.next_column()
            bimpy.text("Some text")
            bimpy.separator()
            bimpy.columns(1)

            if bimpy.button("Some button"):
                a = 0
                print("!!!")

            bimpy.progress_bar(a)

            bimpy.combo("Combo!", selectedItem, mylist)

            bimpy.push_item_width(-10.0)
            bimpy.plot_lines("Some plot", vals, graph_size=bimpy.Vec2(0, 300))
            bimpy.pop_item_width()

            a += 0.01
        bimpy.end()

        if bimpy.begin("Hello2!",
                       flags=(bimpy.WindowFlags.AlwaysAutoResize
                              | bimpy.WindowFlags.NoTitleBar)):
            bimpy.text("Some text")

            if bimpy.button("Some button"):
                print("!!!")

            bimpy.combo("Combo2!", selectedItem, mylist)
예제 #7
0
def show_demo_window():
    bp.begin_root(menu=True)

    #  Menu Bar
    if bp.begin_menu_bar():
        if bp.begin_menu("Menu"):
            bp.end_menu()

        if bp.begin_menu("Examples"):
            bp.end_menu()

        if bp.begin_menu("Tools"):
            bp.end_menu()

        bp.end_menu_bar()

    global clicked
    if bp.button("Button"):
        clicked += 1
    if clicked & 1:
        bp.same_line()
        bp.text("Thanks for clicking me!")

    bp.checkbox("checkbox", check)

    bp.radio_button("radio a", e, 0)
    bp.same_line()
    bp.radio_button("radio b", e, 1)
    bp.same_line()
    bp.radio_button("radio c", e, 2)

    #  Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style.
    for i in range(7):
        if i > 0:
            bp.same_line()
        bp.push_id_int(i)
        bp.push_style_color(bp.Colors.Button, bp.Vec4(i / 7.0, 0.6, 0.6, 1.0))
        bp.push_style_color(bp.Colors.ButtonHovered,
                            bp.Vec4(i / 7.0, 0.7, 0.7, 1.0))
        bp.push_style_color(bp.Colors.ButtonActive,
                            bp.Vec4(i / 7.0, 0.8, 0.8, 1.0))
        bp.button("Click")
        bp.pop_style_color(3)
        bp.pop_id()

    #  Use AlignTextToFramePadding() to align text baseline to the baseline of framed elements (otherwise a Text+SameLine+Button sequence will have the text a little too high by default)
    bp.align_text_to_frame_padding()
    bp.text("Hold to repeat:")
    bp.same_line()

    #  Arrow buttons with Repeater
    spacing = bp.get_style().item_inner_spacing.x
    bp.push_button_repeat(True)

    global counter
    if bp.arrow_button("##left", bp.Direction.Left):
        counter -= 1

    bp.same_line(0.0, spacing)
    if bp.arrow_button("##right", bp.Direction.Right):
        counter += 1

    bp.pop_button_repeat()
    bp.same_line()
    bp.text("%d" % counter)

    bp.text("Hover over me")
    if bp.is_item_hovered():
        bp.set_tooltip("I am a tooltip")

    bp.same_line()
    bp.text("- or me")
    if bp.is_item_hovered():
        bp.begin_tooltip()
        bp.text("I am a fancy tooltip")
        arr = [0.6, 0.1, 1.0, 0.5, 0.92, 0.1, 0.2]
        bp.plot_lines("Curve", arr)
        bp.end_tooltip()

    bp.separator()

    bp.label_text("label", "Value")

    #  Using the _simplified_ one-liner Combo() api here
    #  See "Combo" section for examples of how to use the more complete BeginCombo()/EndCombo() api.
    items = [
        "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII",
        "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO"
    ]
    bp.combo("combo", item_current, items)
    bp.same_line()
    help_marker(
        "Refer to the \"Combo\" section below for an explanation of the full BeginCombo/EndCombo API, and demonstration of various flags.\n"
    )

    #  To wire InputText() with std::string or any other custom string type,
    #  see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file.
    bp.input_text("input text", str0, 128)
    bp.same_line()
    help_marker(
        "USER:\nHold SHIFT or use mouse to select text.\n"
        "CTRL+Left/Right to word jump.\n"
        "CTRL+A or double-click to select all.\n"
        "CTRL+X,CTRL+C,CTRL+V clipboard.\n"
        "CTRL+Z,CTRL+Y undo/redo.\n"
        "ESCAPE to revert.\n\nPROGRAMMER:\nYou can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example (this is not demonstrated in imgui_demo.cpp)."
    )

    bp.end()
예제 #8
0
        if (minPWM.value > 255):
            minPWM = bimpy.Int(255)
        if (minPWM.value < 0):
            minPWM = bimpy.Int(0)
        if (maxPWM.value > 255):
            maxPWM = bimpy.Int(255)
        if (maxPWM.value < 1):
            maxPWM = bimpy.Int(1)
        if (minPWM.value > maxPWM.value):
            minPWM = bimpy.Int(maxPWM.value)
        bimpy.input_float('Light interval (seconds)', maxInterval, 0.100000000000000)
        if (maxInterval.value < 0.100000000):
            maxInterval = bimpy.Float(0.100000000000000)
        if bimpy.button(textToggleButton,bimpy.Vec2(208,0)):
                toggleLight = not toggleLight
                if (toggleLight == True):
                    plot_values = array('f',[])
                    textToggleButton = 'Stop flashing LED'
                    threading.Thread(target=flashLED, args=()).start()
                if (toggleLight == False):
                    textToggleButton = 'Start flashing LED'
        if (checkPWM() == 1):
            bimpy.input_int('PWM Min',minPWM,1)
            bimpy.input_int('PWM Max',maxPWM,1)
        bimpy.plot_lines("",plot_values,0,'(' + str(pinNumber.value) + ')',0,1,bimpy.Vec2(0,50))
        if bimpy.button('Exit',bimpy.Vec2(208,0)):
            currentBoard.exit()
            exit()
    bimpy.end()
    ctx.render()