static void Rescale(XmPannerWidget pw) { int hpad = 2 * (XmPanner_internal_border(pw) + pw->primitive.highlight_thickness + pw->primitive.shadow_thickness); int vpad = hpad; if (XmPanner_canvas_width(pw) < 1) XmPanner_canvas_width(pw) = pw->core.width; if (XmPanner_canvas_height(pw) < 1) XmPanner_canvas_height(pw) = pw->core.height; if ((int)pw->core.width <= hpad) hpad = 0; if ((int)pw->core.height <= vpad) vpad = 0; XmPanner_haspect(pw) = (double)(pw->core.width - hpad) / (double)XmPanner_canvas_width(pw); XmPanner_vaspect(pw) = (double)(pw->core.height - vpad) / (double)XmPanner_canvas_height(pw); ScaleKnob (pw, TRUE, TRUE); }
void MainMenu() { func = -1; while (!stop_button()) { funcLast = func; func = ScaleKnob(1, 27); if (FDispMenu(1, "Calibrate Lookdown")) CalibrateLookdown(); if (FDispMenu(2, "Compete!")) Compete(); if (FDispMenu(3, "Placebo")) Placebo(); if (FDispMenu(4, "Dance!")) Chop(10); if (FDispMenu(5, "Calibrate Soft")) CalibrateSoft(); if (FDispMenu(6, "Calibrate Hard")) CalibrateHard(); if (FDispMenu(7, "Speed Calibration")) CalibrateSpeed(); if (FDispMenu(8, "Lookdown Test")) LookdownTest(); if (FDispMenu(9, "Orientation")) Orient(); if (FDispMenu(10, "Straight 1000")) Move(1000,1000); if (FDispMenu(11, "Left 90 Soft")) Soft(90, 1); if (FDispMenu(12, "Left 90 Hard")) Hard(90); if (FDispMenu(13, "Find Line")) FindLine(); if (FDispMenu(14, "Line Follow")) LineFollower(); if (FDispMenu(15, "Record")) RecordMove(WSetting("Record move", 0, 9)); if (FDispMenu(16, "Playback")) PlayMove(WSetting("Play move", 0, 9)); /* hbtest.c functions */ if (FDispMenu(17, "Servo Test")) ServoTest(); if (FDispMenu(18, "Calibrate Gate")) CalibrateGate(); if (FDispMenu(19, "Soft Turn Test")) SoftTest(); if (FDispMenu(20, "Hard Turn Test")) HardTest(); if (FDispMenu(21, "Spin Test!")) Spinner(); if (FDispMenu(22, "Shake Test!")) Shaker(); if (FDispMenu(23, "Bump Test")) BumpTest(); if (FDispMenu(24, "Test Motors")) testmotors(); if (FDispMenu(25, "Test Digitals")) testdigitals(); if (FDispMenu(26, "Test Analogs")) testanalogs(); if (FDispMenu(27, "Assert Enable")) AssertEnable(); } }
void ServoRange() { int pos; int portServ = 0; while (!stop_button()) { if (start_button()) { portServ = 1 - portServ; while (start_button()); } pos = ScaleKnob(30, 3960); printf("Servo: %d\n", pos); servo(portServ, pos); } while (stop_button()); }
int WSetting(char st[], int wMin, int wMax) { int wSet; int wSetLast = -1; while (!start_button()) { wSet = ScaleKnob(wMin, wMax); if (wSet != wSetLast) { wSetLast = wSet; printf("%s: %d\n", st, wSet); } } while (start_button()); return wSet; }
/* ARGSUSED */ static Boolean SetValues (Widget gcur, Widget greq, Widget gset, ArgList args, Cardinal *num_args) { XmPannerWidget cur = (XmPannerWidget) gcur; XmPannerWidget set = (XmPannerWidget) gset; Boolean redisplay = FALSE; if (cur->primitive.foreground != set->primitive.foreground) { ResetSliderGC (set); if (cur->primitive.foreground != cur->core.background_pixel) ResetXorGC (set); redisplay = TRUE; } else if (cur->core.background_pixel != set->core.background_pixel) { ResetXorGC (set); redisplay = TRUE; } if (XmPanner_rubber_band(cur) != XmPanner_rubber_band(set)) { ResetXorGC (set); if (XmPanner_tmp(set).doing) redisplay = TRUE; } if (XmPanner_resize_to_pref(set) && (XmPanner_canvas_width(cur) != XmPanner_canvas_width(set) || XmPanner_canvas_height(cur) != XmPanner_canvas_height(set) || XmPanner_resize_to_pref(cur) != XmPanner_resize_to_pref(set))) { GetDefaultSize (set, &set->core.width, &set->core.height); redisplay = TRUE; } else if (XmPanner_canvas_width(cur) != XmPanner_canvas_width(set) || XmPanner_canvas_height(cur) != XmPanner_canvas_height(set) || XmPanner_internal_border(cur) != XmPanner_internal_border(set)) { Rescale (set); /* does a scale_knob as well */ redisplay = TRUE; } else { Boolean loc = (XmPanner_slider_x(cur) != XmPanner_slider_x(set) || XmPanner_slider_y(cur) != XmPanner_slider_y(set)); Boolean siz = (XmPanner_slider_width(cur) != XmPanner_slider_width(set) || XmPanner_slider_height(cur) != XmPanner_slider_height(set)); if (loc || siz) { /* Fake it as though user has made a page movement; works as long ** as we don't get a callback now with different X and Y values */ /* note! siz does change from the porthole, but if the app changes ** it programmatically, then the value is off */ XmPanner_tmp(set).doing = TRUE; XmPanner_tmp(set).x = XmPanner_knob_x(set) + PANNER_HSCALE (set, XmPanner_slider_x(set) - XmPanner_slider_x(cur)); XmPanner_tmp(set).y = XmPanner_knob_y(set) + PANNER_VSCALE (set, XmPanner_slider_y(set) - XmPanner_slider_y(cur)); ActionNotify((Widget)set, NULL, NULL, 0); XmPanner_tmp(set).doing = FALSE; ScaleKnob(set,loc,siz); redisplay = TRUE; } } return redisplay; }